Python - 使用特征向量匹配关键点

Python - Matching keypoints using feature vectors

我正在尝试使用特征向量和欧氏距离作为相似性度量来匹配 2 个网格的关键点,

我试过的,这里是一个简单的实例,我做了一个主要数据的例子:

a = [0,1,4,6]
    fv_a = [[2.1,4],
            [0.7,3.1],
            [2.23,6],
            [0,1.11]]
    b = [1,3,0,4]
    fv_b = [[0.7,3.1],
            [4.1,3.3],
            [2.1,4],
            [2.23,6]]
    fv_a = (fv_a - np.min(fv_a)) / np.ptp(fv_a)
    fv_b = (fv_b - np.min(fv_b)) / np.ptp(fv_b)
    distances = scipy.spatial.distance.cdist(fv_a,fv_b)
    print(distances)
    # print(np.amax(distances,1))
    # print(np.argmax(distances,1))
    matched = np.argmax(distances,1)
    print(matched)
    for i,j in enumerate(matched):
        print(i, "linked to : ",j)
        print("point in a",a[i]," is matched to: ",b[j])

所以重点是,对于 a 中的每个点,我都有一个特征向量表示在 fv_a 中,并且我正在尝试将其与 b

匹配

但是结果是这样的:

 [0.1329895  0.52549136 0.18161024 0.51302967]
 [0.6614612  0.57648771 0.39237617 0.08298742]
 [0.26783019 0.71056665 0.5111808  0.86461593]]
[0 1 0 3]
0 linked to :  0
point in a 0  is matched to:  1
1 linked to :  1
point in a 1  is matched to:  3
2 linked to :  0
point in a 4  is matched to:  1
3 linked to :  3
point in a 6  is matched to:  4

这是不正确的,因为 0 应该匹配 0,1 应该匹配 1,等等。

请问我做错了什么?

是的,我正在尝试一对一匹配。有什么推荐吗?

使用 Scikit Library 成功了。

这个功能让我得到了我需要的:)

from skimage.feature import match_descriptors