OpenCV BFMatcher - 忽略误报

3

有人能描述一下BFMatcher中忽略假阳性的良好流程吗?

enter image description here

我定义了一个在场景中要查找的图像,使用SiftFeatureDetector、SiftDescriptorExtractor然后使用BFMatcher。当搜索正确的标记时,我可以很容易地找到匹配,但我希望使我的代码更加强大,以应对假阳性。

//Detect keypoints using ORB Detector
SiftFeatureDetector detector;
vector<KeyPoint> keypoints1, keypoints2; 
detector.detect(im1, keypoints1);
detector.detect(im2, keypoints2);

//Draw keypoints on images
Mat display1, display2;
drawKeypoints(im1, keypoints1, display1, Scalar(0,0,255));
drawKeypoints(im2, keypoints2, display2, Scalar(0,0,255));

//Extract descriptors
SiftDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute( im1, keypoints1, descriptors1 );
extractor.compute( im2, keypoints2, descriptors2 );

BFMatcher matcher(NORM_L1, true);
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);

我试图通过跳过来过滤掉假阳性:

if (matches.size() < 50) {
     //false positive - skip
} else {
     //perform actions
}

但这并不是非常健壮的方法。我记得见过一些使用半径匹配器的文章,但我找不到一个很好的描述如何将半径匹配与Brute Force一起使用的文章。我查看了文档:http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html,但对我来说如何决定此应用程序的好min_dist/max_dist并不清楚。
我相信对于你们中的一些人来说,这是一个相当简单的答案 - 您的帮助将不胜感激!
1个回答

0

您需要根据匹配的距离进行过滤。 请注意,距离取决于您在BFMatcher中选择的范数。

这里是来自openCV样例的一个例子:

double min_dist = 100;
for( int i = 0; i < descriptors_object.rows; i++ )
   { double dist = matches[i].distance;
        if( dist < min_dist ) min_dist = dist;
   }

 /** Keep only "good" matches (i.e. whose distance is less than 3*min_dist ) **/
  std::vector< DMatch > good_matches;
  for( int i = 0; i < descriptors_object.rows; i++ )
  { if( matches[i].distance < 3*min_dist )
     { good_matches.push_back( matches[i]); }
  }

请问您能解释一下“要注意距离取决于BFMatcher中所选择的范数”的含义吗?我选择了NORM_L1。 - P3d0r
你要求最小/最大距离,但没有通用的最大/最小距离。 你有两个选择:
  • 找到适合你需求的最大/最小距离
  • 使用上面的代码找到最小/最大值。 距离取决于范数(NORM_L1、NORM_HAMMING等),如果使用NORM_HAMMING,则不应该找到相同的最小/最大距离。
- Whysmerhill

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接