0

据我所知,汉明距离越小越好。当我运行这段代码时:

# Initiate ORB detector
orb = cv2.ORB_create()

# find the keypoints and descriptors with ORB
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)

# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

# Match descriptors.
matches = bf.match(des1,des2)

# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)
print(matches[0].distance)
print(matches[len(matches)-1].distance)
good=[]
# filter the good matches by distance in [min,2*min]
# set a limited min 30 avoid the min being too closer to 0
# TODO why '>' is more accurate
for obj in matches:
    if(obj.distance>2*max(matches[0].distance,30.0)):
        good.append(obj)

print(len(good))

两个图像越相似,输出越大。为什么?如果图像相似,结果不应该更关注小部分吗?

4

0 回答 0