简体   繁体   中英

CV2 ORB Parameters

I have implemented the cv2 orb detector and a brute force matcher. Both is working on large images.

However, when I crop the images to my region of interest and run it again no features are found.

I would like to adjust the parameters but I cant access the variables of my orb descriptor which is only a reference

ORB: >ORB00000297D3FD3EF0\\<

I also tried the cpp documentation without any result. I want to know which parameters the descriptor uses as default and then adapting them using cross validation.

Thank you in advance

"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

You should use python's dir(...) function to inspect the opaque object - It returns a list of methods that belong to that object:

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

Tip: filter all methods that start with underscore (convention for private ones)

>>> [item for item in dir(orb) if not item.startswith('_')]
['compute', 'create', 'defaultNorm', 'descriptorSize', 'descriptorType',
'detect', 'detectAndCompute', 'empty', 'getDefaultName', 'getEdgeThreshold',
'getFastThreshold', 'getFirstLevel', 'getMaxFeatures', 'getNLevels', ...]

That reveals all the getters and setters you will need. Here's an example setting - MaxFeatures parameter:

>>> 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM