ORB compute bug: it removes all keypoints with a s

2019-07-21 21:39发布

问题:

I have a small image 50x50. I find ORB keypoints with:

(Notice that I have to change the default param of patchSize from 31 to 14 to get some keypoints detected):

 OrbFeatureDetector det(500,1.2f,8,14,0,2,0,14);   //> (From 31 to 14)
 OrbDescriptorExtractor desc;

 det.detect(image,kp)
 //> kp.size() is about 50 keypoints

Now If i pass my keypoints to orb.compute I get all keypoints erased.

 desc.compute(image,kp,kpDesc);
 //> Now kp.size() == 0

This mean that after I have called .compute the method has deleted all keypoints.

The Image I am using is this:

I believe this is some sort of bug. Someone can confirm? I am using OpenCV 2.4.5

回答1:

No it is not a bug.

The problem is that OrbDescriptorExtractor doesn't know that you have changed the param in the FeatureDetector. So you have to set the right params again:

OrbFeatureDetector      det(500,1.2f,8,14,0,2,0,14);   //> (From 31 to 14)
OrbDescriptorExtractor desc(500,1.2f,8,14,0,2,0,14); 


回答2:

You are creating two objects, a feature detector and a descriptor extractor. These must be initialized with the same parameters.

You can reduce the code duplication in having to set identical parameters twice by creating a single instance of cv::ORB and then calling cv::ORB::operator(), like so:

cv::ORB orb(500,1.2f,8,14,0,2,0,14);
orb(image,cv::noArray(),kp,kpDesc);

This will be identical to your initial solution, since the feature detector and extractor are really the same object. From the OpenCV headers:

typedef ORB OrbFeatureDetector;
typedef ORB OrbDescriptorExtractor;