10

我从 OpenCV 教程页面复制了Feature Matching with FLANN的代码,并进行了以下更改:

  • 我使用了 SIFT 功能,而不是 SURF;
  • 我修改了“匹配良好”的检查。代替

    if( matches[i].distance < 2*min_dist )
    

我用了

    if( matches[i].distance <= 2*min_dist )

否则,在将图像与其自身进行比较时,我会得到零匹配。

  • 绘制关键点的修改参数:

    drawMatches( img1, k1, img2, k2,
                     good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
                     vector<char>(), DrawMatchesFlags::DEFAULT);
    

我从INRIA-Holidays dataset的 Ireland 文件夹中的所有图像中提取了 SIFT 。然后我将每个图像与所有其他图像进行比较并绘制匹配项。

但是,我在过去使用的任何其他 SIFT/Matcher 实现中从未遇到过一个奇怪的问题:

  • 我与自己匹配的图像的匹配很好。除了一些关键点之外,每个关键点都映射到自身。见上图。与自身匹配的图像
  • 当我将 I 与另一个图像 J 匹配时(J 不等于 I),许多点被映射到同一个图像上。下面是一些示例。 火柴 火柴火柴

有没有人使用 OpenCV 教程中的相同代码并且可以报告与我不同的体验?

4

1 回答 1

1

查看 matcher_simple.cpp 示例。它使用了一个蛮力匹配器,看起来效果很好。这是代码:

// detecting keypoints
SurfFeatureDetector detector(400);
vector<KeyPoint> keypoints1, keypoints2;
detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2);

// computing descriptors
SurfDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);

// matching descriptors
BFMatcher matcher(NORM_L2);
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);

// drawing the results
namedWindow("matches", 1);
Mat img_matches;
drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
imshow("matches", img_matches);
waitKey(0);
于 2013-02-20T17:41:46.547 回答