Opencv - 从特征匹配获取像素坐标 [英] Opencv - Getting Pixel Coordinates from Feature Matching

查看:1993
本文介绍了Opencv - 从特征匹配获取像素坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我吗?我想获得特征匹配器在所提供的代码中使用c ++使用opencv选择的最佳像素的x和y坐标。

Can anyone help me? I want to get the x and y coordinates of the best pixels the feature matcher selects in the code provided, using c++ with opencv.

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

已经四处走动了,但是无法工作。

Been looking around, but can't get anything to work.

非常感谢任何帮助。

推荐答案

DMatch 类提供两个匹配的 KeyPoints (火车和查询)。因此,检测到的最佳对应具有最小距离。本教程抓取小于2 *(最小对距离)的所有匹配,并考虑最好的匹配。

The DMatch class gives you the distance between the two matching KeyPoints (train and query). So, the best pairs detected should have the smallest distance. The tutorial grabs all matches that are less than 2*(minimum pair distance) and considers those the best.

因此,要获得(x,y)坐标最佳匹配。您应该使用 good_matches (这是一个 DMatch 对象的列表)来查找两个不同 KeyPoint 向量( keypoints_1 keypoints_2 )。类似:

So, to get the (x, y) coordinates of the best matches. You should use the good_matches (which is a list of DMatch objects) to look up the corresponding indices from the two different KeyPoint vectors (keypoints_1 and keypoints_2). Something like:

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...
}

这篇关于Opencv - 从特征匹配获取像素坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆