我正在尝试在算法since according to what I've read中将SIFT
替换为BRISK
,这是一个很好的替代方法。但是,当我将SIFT_create()
更改为BRISK_create()
时,我得到了error -201
。有谁知道这意味着什么/如何解决?
相关代码
img1 = cv2.imread("images/test/IMG_6651.JPG", 0)
img2 = cv2.imread("images/test/IMG_6652.JPG", 0)
# Initiate BRISK detector
brisk = cv2.BRISK_create()
kp1, des1 = brisk.detectAndCompute(img1, None)
kp2, des2 = brisk.detectAndCompute(img2, None)
# FLANN parameters
FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5)
search_params = dict(checks=30)
flann = cv2.FlannBasedMatcher(index_params, search_params)
matches = flann.knnMatch(des1, des2, k=2)
# store all the good matches as per Lowe's ratio test.
for m, n in matches:
if m.distance < 0.65 * n.distance:
mC = kp2[m.trainIdx].pt
nC = kp2[n.trainIdx].pt
# DO SOME STUFF WITH mC and nC
错误消息
File "siftMatching.py", line 83, in siftMatcher
matches = flann.knnMatch(des1, des2, k=2)
cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/flann/src/miniflann.cpp:315: error: (-210:Unsupported format or combination of formats) in function 'buildIndex_'
> type=0
>
答案 0 :(得分:0)
如果您查看代码miniflann code
它需要featureType = CV_32F并且您的描述符类型是uint8。因此,将des1和des2的数据类型更改为float32。
>>> des1 = des1.astype('float32')
>>> des2 = des2.astype('float32')