处理DMatch向量,访问数据Opencv
我已经计算了描述符,但现在,我想在将其从关键点转换为浮点之前清除异常值。
我知道这可以通过以下方式自动完成
BruteForceMatcher<cv::L2<float> > matcher;
std::vector<cv::DMatch> matches;
matcher.match(descriptors1,descriptors2, matches);
std::nth_element(matches.begin(),matches.begin()+24, matches.end());
matches.erase(matches.begin()+25, matches.end());`
,但这仅在下一步绘制匹配时才有用,实际上我想做的是在某些图像配准内容中获得用于后处理的最佳 25 个匹配。
任何帮助都会有用的。谢谢伊万
I already calculate the descriptors, but now, I would like to clean the outliers, before of transforming it from keypoint to float.
I know that this can be done automatically by
BruteForceMatcher<cv::L2<float> > matcher;
std::vector<cv::DMatch> matches;
matcher.match(descriptors1,descriptors2, matches);
std::nth_element(matches.begin(),matches.begin()+24, matches.end());
matches.erase(matches.begin()+25, matches.end());`
But this is only useful if the next step is drawing the matches, and actually what I would like to do is obtain the best 25 matches for posprocessing in some image registration stuff.
Any help would be useful. Thanks
Iván
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Dmatch 向量中每个元素的 trainIdx 和 queryIdx 属性从您提供的关键点向量中提取相应的匹配索引。
基本上, matches.at(i).trainIdx 和 matches.at(i).queryIdx 将为您提供第 'i' 个相应匹配的索引。最好的部分是,匹配按质量降序排列,例如,i=1 会比 i=3 更好,依此类推。因此,在您的代码中,您将提取最佳的 24 个匹配项。
我不知道你是否还需要帮助解决这个问题,自从你问这个问题以来已经一年了。但我也有同样的问题,并且偶然发现了你的问题。我也花了一些时间才弄清楚。我认为回答这个问题是我的责任,以免其他人也遇到同样的问题并需要帮助。要有光!
Use the trainIdx and queryIdx attributes of each element in the Dmatch vector to extract corresponding indexes of matching from the vector of keypoints you provided.
Basically, matches.at(i).trainIdx and matches.at(i).queryIdx will give you the indices of the 'i'th corresponding match. The best part is, the matches are arranged in descending order of quality, as in, i=1 will be a better match than i=3, and so on. So, in your code, you are extracting the best 24 matches.
I don't know if you still need help with this question, it's been a year since you asked it. But I had the same question and I chanced upon your question. It took me time to figure out as well. I thought it was my duty to answer this question lest someone else also chance upon the same question and needs help. Let there be light!