Reputation: 520
I have implemented the OpenCV 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
Upvotes: 4
Views: 1964
Reputation: 1786
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
Upvotes: 2