处理DMatch向量,访问数据Opencv

发布于 2025-01-06 23:33:07 字数 457 浏览 1 评论 0原文

我已经计算了描述符,但现在,我想在将其从关键点转换为浮点之前清除异常值。

我知道这可以通过以下方式自动完成

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放低过去 2025-01-13 23:33:07

使用 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文