【发布时间】:2017-12-07 12:07:09
【问题描述】:
我正在尝试在两个图像上使用 SIFT,并在 OpenCV 中使用 BFMatcher 匹配关键点。
但是,匹配的数量不等于查询描述符的数量。有人能解释一下为什么他们不相等吗?
根据docs
match() function “从查询集中找到每个描述符的最佳匹配。”
import cv2
import numpy as np
im1 = cv2.imread("trex1.png", cv2.IMREAD_GRAYSCALE)
im2 = cv2.imread("trex2.png", cv2.IMREAD_GRAYSCALE)
sift = cv2.xfeatures2d.SIFT_create()
kp1, des1 = sift.detectAndCompute(im1, None)
kp2, des2 = sift.detectAndCompute(im2, None)
im_kp1 = np.zeros(im1.shape, dtype=np.uint8)
im_kp2 = np.zeros(im1.shape, dtype=np.uint8)
im_kp1 = cv2.drawKeypoints(im1,kp1,None)
im_kp2 = cv2.drawKeypoints(im2,kp2,None)
bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
matches = bf.match(des1,des2)
print len(des1)
# Result : 78
print len(des2)
# Result : 71
print len(matches)
# Result : 55
【问题讨论】: