【发布时间】:2015-04-09 02:02:58
【问题描述】:
我一直致力于检测场景中的基准标记。我的基准标记的一个例子在这里: http://tinypic.com/view.php?pic=4r6k3q&s=8#.VNgsgzVVK1F
我已经能够很好地检测场景中的单个基准标记。在一个场景中检测多个基准标记的方法是什么?进行特征检测、提取和匹配非常适合找到单个匹配项,但它似乎是检测多个匹配项的错误方法,因为很难确定哪些特征属于哪个标记?
基准标记将是相同的,并且不会位于场景中的已知位置。
更新:
下面是一些示例代码。我试图将第一个基准标记与 x 个关键点进行匹配,然后使用剩余的关键点匹配第二个标记。但是,这根本不可靠。有人有什么建议吗?
OrbFeatureDetector detector;
vector<KeyPoint> keypoints1, keypoints2;
detector.detect(im1, keypoints1);
detector.detect(im2, keypoints2);
Mat display_im1, display_im2;
drawKeypoints(im1, keypoints1, display_im1, Scalar(0,0,255));
drawKeypoints(im2, keypoints2, display_im2, Scalar(0,0,255));
SiftDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute( im1, keypoints1, descriptors1 );
extractor.compute( im2, keypoints2, descriptors2 );
BFMatcher matcher;
vector< DMatch > matches1, matches2;
matcher.match( descriptors1, descriptors2, matches1 );
sort (matches1.begin(), matches1.end());
matches2 = matches;
int numElementsToSave = 50;
matches1.erase(matches1.begin()+numElementsToSave,matches1.end());
matches2.erase(matches2.begin(),matches2.begin()+numElementsToSave);
Mat match_im1, match_im2;
drawMatches( im1, keypoints1, im2, keypoints2,
matches1, match_im1, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
drawMatches( im1, keypoints1, im2, keypoints2,
matches2, match_im2, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
【问题讨论】:
-
在此处查看我的答案:stackoverflow.com/questions/28407828/… 这对您来说可能是个不错的解决方案。
-
感谢您的意见。从表面上看,我不知道如何将您的答案应用于我的问题,但我会进一步探索。