我试图在算法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
> 发布于 2019-04-26 09:16:38
如果您查看代码迷你码
它需要featureType = CV_32F,描述符类型是uint8。因此,将des1和des2的数据类型更改为float32。
>>> des1 = des1.astype('float32')
>>> des2 = des2.astype('float32')https://stackoverflow.com/questions/55861454
复制相似问题