查找两个定向梯度特征直方图之间的距离

Finding distance between two Histogram of Oriented Gradients Features

我有两个 4000 维的 HOG 特征,由 cv2.HOGDescriptor 创建。我需要找到这两个向量之间的距离。

def getDistances(firstFace,secondFace):
EuclideanDistance = distance.euclidean(firstFace,secondFace)
print("Euclidean distance from x to y: ", EuclideanDistance)

我试过类似的方法,但结果对我来说似乎是错误的。如果我需要解释,我有 3 张图片。 A和B几乎一模一样。 C就完全不一样了

Euclidean distance from x to y:  232.5758819580078 # A and C
Euclidean distance from x to y:  238.22845458984375 # B and C
Euclidean distance from x to y:  249.4779052734375 # A and B

A​​和B的距离应该小于那个。

试试这个。

from scipy.spatial import distance
a = (1, 2, 3)
b = (4, 5, 6)
dst = distance.euclidean(a, b)