OpenCV ORB 参数

4

我已经实现了OpenCV orb检测器和暴力匹配器,它们都适用于大图像。

然而,当我将图像裁剪到我的感兴趣区域并再次运行时,没有找到任何特征。

我想调整参数,但我无法访问orb描述符的变量,因为它只是一个引用。

ORB: > ORB00000297D3FD3EF0 <

我还尝试了cpp文档,但没有结果。我想知道描述符使用哪些默认参数,然后使用交叉验证来适应它们。

提前谢谢。

"ORB Features"
def getORB(img):
    #Initiate ORB detector
    orb = cv2.ORB_create()

    #find keypoints
    kp = orb.detect(img)

    #compute despriptor
    kp, des = orb.compute(img,kp)
    # draw only keypoints location,not size and orientation
    img2 = cv2.drawKeypoints(img, kp, None, color=(0,255,0), flags=0)
    plt.imshow(img2), plt.show()
    return kp,des

你有检查过 https://dev59.com/h1wY5IYBdhLWcg3wWmxn 吗?为了再现问题,请发布你的代码。 - ZF007
是的,我已经做了那个,并且根据帖子改变了参数,但结果没有任何改变。代码将会得到更新。 - Max Krappmann
1个回答

2

您应该使用Python的dir(...)函数来检查不透明对象 - 它返回属于该对象的方法列表:

>>> dir(orb)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', ...]

提示:过滤所有以下划线开头的方法(私有方法的约定)。
>>> [item for item in dir(orb) if not item.startswith('_')]
['compute', 'create', 'defaultNorm', 'descriptorSize', 'descriptorType',
'detect', 'detectAndCompute', 'empty', 'getDefaultName', 'getEdgeThreshold',
'getFastThreshold', 'getFirstLevel', 'getMaxFeatures', 'getNLevels', ...]

这将展示您所需的所有getter和setter。以下是一个设置示例 - MaxFeatures参数:

>>> kp = orb.detect(frame)

>>> len(kp)
1000

>>> orb.getMaxFeatures
<built-in method getMaxFeatures of cv2.ORB object at 0x1115d5d90>

>>> orb.getMaxFeatures()
1000

>>> orb.setMaxFeatures(200)

>>> kp = orb.detect(frame)

>>> len(kp)
200

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接