【问题标题】:OpenCV BFMatcher - Ignore False PositivesOpenCV BFMatcher - 忽略误报
【发布时间】:2015-02-20 03:53:11
【问题描述】:

有人能描述一个忽略 BFMatcher 误报的好过程吗?

我定义了要在场景中查找的图像,使用 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
}

但这一点都不可靠。我想我看到了一些关于人们使用半径匹配器的文章,但我找不到一个很好的描述来使用蛮力的半径匹配。我查看了文档:http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html,但我非常清楚我如何决定这个应用程序的最佳 min_dist/max_dist 是什么?

我相信这对你们中的一些人来说是一个非常简单的答案 - 非常感谢您的帮助!

【问题讨论】:

    标签: opencv computer-vision sift brute-force


    【解决方案1】:

    您需要过滤匹配的距离。 注意距离取决于您在 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
    • 您要求最小最大距离,但没有通用的最大/最小距离。您有两个选择:-您发现自己需要的最大/最小距离-您使用上面的代码找到最小/最大距离取决于规范(NORM_L1,NORM_HAMMING ...),如果您采用 NORM_HAMMING 您不应该找到相同的最小/最大距离。
    猜你喜欢
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-27
    • 2019-12-19
    • 2018-11-18
    • 1970-01-01
    相关资源
    最近更新 更多