OpenCV ORB detector finds very few keypoints
Asked Answered
F

2

19

I'm trying to use the ORB keypoint detector and it seems to be returning much fewer points than the SIFT detector and the FAST detector.

This image shows the keypoints found by the ORB detector:

enter image description here

and this image shows the keypoints found by the SIFT detection stage (FAST returns a similar number of points).

enter image description here

Having such few points is resulting in very poor feature matching results across images. I'm just curious about the detection stage of ORB right now though because this seems like I'm getting incorrect results. I've tried using the ORB detector with default parameters and also custom parameters detailed below as well.

Why such a big difference?

Code:

orb = cv2.ORB_create(edgeThreshold=15, patchSize=31, nlevels=8, fastThreshold=20, scaleFactor=1.2, WTA_K=2,scoreType=cv2.ORB_HARRIS_SCORE, firstLevel=0, nfeatures=500)
#orb = cv2.ORB_create()
kp2 = orb.detect(img2)
img2_kp = cv2.drawKeypoints(img2, kp2, None, color=(0,255,0), \
        flags=cv2.DrawMatchesFlags_DEFAULT)

plt.figure()
plt.imshow(img2_kp)
plt.show()
Flyblown answered 21/9, 2015 at 18:43 Comment(3)
Just lower the threshold.Technology
I don't believe that's the issue. I've tried lowering the both thresholds and it doesn't make a significant difference in the number of key points detected.Flyblown
Hmmm. What about scoreType=cv2.ORB_HARRIS_SCORE -> FAST_SCORE? As an offtop, I could recommend to try AKAZE detector/descriptor - it is fast and robust.Technology
M
21

Increasing nfeatures increases the number of detected corners. The type of keypoint extractor seems irrelevant. I'm not sure how this parameter is passed to FAST or Harris but it seems to work.

orb = cv2.ORB_create(scoreType=cv2.ORB_FAST_SCORE)

enter image description here

orb = cv2.ORB_create(nfeatures=100000, scoreType=cv2.ORB_FAST_SCORE)

enter image description here

Monumentalize answered 12/10, 2016 at 1:47 Comment(0)
T
8

Even though this thread is quite old, i hope this may help someone with the same question:

I'm not sure how this parameter is passed to FAST or Harris but it seems to work.

That is explained very well by Rublee et al. in their paper "ORB: an efficient alternative to SIFT or SURF". Since i don't think to be able to explain it better, here's a direct quote from page 2565 of "2011 International Conference on Computer Vision":

FAST does not produce a measure of cornerness, and we have found that it has large responses along edges. We employ a Harris corner measure [11] to order the FAST keypoints. For a target number N of keypoints, we first set the threshold low enough to get more than N keypoints, then order them according to the Harris measure, and pick the top N points.

Theosophy answered 29/8, 2018 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.