简体   繁体   English

OpenCV Python功能检测和匹配

[英]OpenCV Python Feature Detection and Matching

I don't understand the feature matching API in FLANN. 我不了解FLANN中的功能匹配API。 I found this code and I am using it as a base line for my development: Image stitching Python 我找到了这段代码,并将其用作开发的基准: 图像拼接Python

But I can't figure out what the flann.knnMatch() function is returning. 但是我不知道flann.knnMatch()函数返回什么。 It's a list of tuples of the DMatch type. 这是DMatch类型的元组的列表。 I don't understand why there are two matches in each tuple. 我不明白为什么每个元组都有两个匹配项。 I also don't understand why Lowe's ratio is applied to compare the two items in the tuple and then we only use the first item in the tuple. 我也不明白为什么应用Lowe比率来比较元组中的两项,然后我们仅使用元组中的第一项。

I can't seem to find any information on the flann python bindings in the OpenCV doc, so I've been struggling to figure out what all of this is. 我似乎在OpenCV文档中找不到有关flann python绑定的任何信息,因此我一直在努力弄清所有这些内容。

Any explanation of this would be greatly appreciated. 任何对此的解释将不胜感激。

Thanks. 谢谢。

  1. The function flann.knnMatch() method (with k=2) is returning two best matching points. 函数flann.knnMatch()方法(k = 2)返回两个最佳匹配点。
  2. For image stitching you might have to do matching in two directions ie for each point in first image we need to find two best matches in second image and we do the same for the feature points in second image finding their two best matches in the first image. 对于图像拼接,您可能必须在两个方向上进行匹配,即,对于第一幅图像中的每个点,我们需要在第二幅图像中找到两个最佳匹配,而对于第二幅图像中的特征点,则要执行相同的操作,以便找到第一幅图像中的两个最佳匹配。
  3. The two best matches are returned based on distance between the descriptors. 根据描述符之间的距离返回两个最佳匹配。 If the measured distance is very low for the best match and much larger for the second best match then first match is unambiguously the best choice. 如果测得的距离对于最佳匹配而言非常低,而对于第二最佳匹配而言则远大于第一匹配无疑是最佳选择。
  4. If the two best matches are relatively close in distance to each other then you perform ratio test of the distance of best match over the distance of the second match is not greater than a given threshold(This generally is what ratio test is done for) 如果两个最佳匹配在距离上相对接近,则您要对最佳匹配的距离与第二个匹配的距离进行比率测试,该比率不大于给定的阈值(通常是进行比率测试的目的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM