【问题标题】:CV2 ORB ParametersCV2 ORB 参数
【发布时间】:2018-06-09 01:17:34
【问题描述】:

我已经实现了 cv2 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

【问题讨论】:

  • 你检查stackoverflow.com/questions/32702433/…了吗?发布您的代码以用于复制目的?
  • 是的,我已经做到了,还根据帖子更改了参数,结果没有任何变化。代码将更新

标签: python-3.x cv2 orb


【解决方案1】:

您应该使用 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

【讨论】:

    猜你喜欢
    • 2023-03-14
    • 1970-01-01
    • 2023-03-28
    • 2013-10-31
    • 2012-04-12
    • 1970-01-01
    • 2017-03-26
    • 2018-09-12
    • 2021-07-06
    相关资源
    最近更新 更多