[英]Replacing SIFT with BRISK is OpenCV causing error
I am trying to replace SIFT
with BRISK
in my algorithm since according to what I've read it's a good substitute. 我试图在我的算法中用BRISK
替换SIFT
, 因为根据我所读到的它是一个很好的替代品。 However, when I change SIFT_create()
to BRISK_create()
, I get error -201
. 但是,当我将SIFT_create()
更改为BRISK_create()
,我得到error -201
。 Anyone know what this means / how to fix this? 任何人都知道这意味着什么/如何解决这个问题?
RELEVANT CODE 相关代码
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
ERROR MESSAGE 错误信息
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
>
If you look into the code miniflann code 如果你看一下代码miniflann代码
It needs featureType = CV_32F and your descriptor type is uint8. 它需要featureType = CV_32F,你的描述符类型是uint8。 So change datatype of des1 and des2 to float32. 所以将des1和des2的数据类型更改为float32。
>>> des1 = des1.astype('float32')
>>> des2 = des2.astype('float32')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.