gpt4 book ai didi

python - OpenCV (Python) 解压 SIFT Octave

转载 作者:太空宇宙 更新时间:2023-11-03 22:21:41 24 4
gpt4 key购买 nike

我刚发现 SIFT 写了 Octave as packed value ( Octave 、层和音阶)。
我需要解压这个值,因为我必须将 SIFT 检测器与其他描述符(ORB、BRIEF、SURF、BRISK)结合使用。 Here你可以找到一个类似的问题。
我已经尝试过不同的解决方案(见下面的代码),但似乎没有一个在 python 中工作(也是 this one)。
有什么建议吗?

unpackOctave(keypoints[i], octave, layer, scale)     

或者:

unpackOctave(const KeyPoint& kpt, int& octave, int& layer, float& scale){    
octave = kpt.octave & 255;
layer = (kpt.octave >> 8) & 255;
octave = octave < 128 ? octave : (-128 | octave);
scale = octave >= 0 ? 1.f/(1 << octave) : (float)(1 << -octave);
}

最佳答案

我定义了一个 Python 函数来解压 SIFT Octave:

#!/usr/bin/python3
## 2018.01.23 11:12:30 CST
## created by Silencer

def unpackSIFTOctave(kpt):
"""unpackSIFTOctave(kpt)->(octave,layer,scale)
@created by Silencer at 2018.01.23 11:12:30 CST
@brief Unpack Sift Keypoint by Silencer
@param kpt: cv2.KeyPoint (of SIFT)
"""
_octave = kpt.octave
octave = _octave&0xFF
layer = (_octave>>8)&0xFF
if octave>=128:
octave |= -128
if octave>=0:
scale = float(1/(1<<octave))
else:
scale = float(1<<-octave)
return (octave, layer, scale)

比如我检测 Pandas 上的sift kpts。

enter image description here

使用 unpackSiftOctave 解压筛选 kpts,获取( Octave 、层、比例)列表。部分解包结果。

[(0, 3, 1.0),
(1, 3, 0.5),
(-1, 3, 2.0),
(-1, 3, 2.0),
(2, 1, 0.25),
(2, 1, 0.25),
(-1, 1, 2.0),
(-1, 1, 2.0),
(0, 2, 1.0),
(1, 3, 0.5),
...
]

关于python - OpenCV (Python) 解压 SIFT Octave,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48385672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com