[英]How to find matches in descriptors using L2 norm (python)?
I need some clarification in order to understand how image matching work.我需要一些说明以了解图像匹配的工作原理。 Basically, I calculated keypoints (keypoints1, keypoints2) of img1 and img2.
基本上,我计算了img1和img2的关键点(keypoints1,keypoints2)。 After I calculated descriptors (desc1, desc2).
在我计算了描述符(desc1,desc2)之后。 After that I used cdist function from scipy library to calculate the L2 norm of those descriptors.
之后,我使用 scipy 库中的 cdist 函数来计算这些描述符的 L2 范数。 Now I do not understand how to find the matches using distances calculated.
现在我不明白如何使用计算的距离找到匹配项。 I don't understand how to find appropriate indexes that match.
我不明白如何找到匹配的适当索引。 If possible can you show in python vector examples?
如果可能,您可以在 python 向量示例中显示吗? (Like desc1 = [[1,2],[3,4]] and desc2 = [[5,6],[0.9, 2.1]]. Clearly here desc1[0] and desc2[1] has the minimum distance.)
(例如 desc1 = [[1,2],[3,4]] 和 desc2 = [[5,6],[0.9, 2.1]]。很明显这里 desc1[0] 和 desc2[1] 具有最小距离。 )
Do you mean something along those lines?你的意思是这样吗?
scores=scipy.spatial.distance.cdist(desc1,desc2)
matches=scores.argsort(1)
In the snippet above, scores[i,j]
contains the matching score between desc1[i]
and desc2[j]
, and在上面的代码片段中,
scores[i,j]
包含desc2[j]
desc1[i]
和desc2[j]
之间的匹配分数,以及
matches[i]=[index_1, ..., index_k]
is such that desc2[index_1]
is the closest match to desc1[i]
, desc2[index_2]
is the second best match to desc1[i]
and so on.是这样的,
desc2[index_1]
是最匹配desc1[i]
desc2[index_2]
是与第二最佳匹配desc1[i]
等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.