Opencv - 从特征匹配中获取像素坐标

use*_*410 9 c++ opencv image-processing

谁能帮我?我想获得功能匹配器在提供的代码中选择的最佳像素的x和y坐标,使用带有opencv的c ++.

http://opencv.itseez.com/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html#feature-flann-matcher

一直在环顾四周,但无法得到任何工作.

任何帮助是极大的赞赏!

mev*_*ron 14

DMatch类为您提供了两个匹配之间的距离关键点(火车和查询).因此,检测到的最佳对应具有最小距离.本教程抓取所有小于2*(最小对距离)的匹配并认为最佳匹配.

因此,要获得最佳匹配的(x,y)坐标.您应该使用good_matches(这是一个DMatch对象列表)从两个不同的KeyPoint向量(keypoints_1keypoints_2)中查找相应的索引.就像是:

for(size_t i = 0; i < good_matches.size(); i++)
{
    Point2f point1 = keypoints_1[good_matches[i].queryIdx].pt;
    Point2f point2 = keypoints_2[good_matches[i].trainIdx].pt;
    // do something with the best points...
}
Run Code Online (Sandbox Code Playgroud)