[英]python OpenCV(3.4.2) error: (-215:Assertion failed)
I'm trying to use the SIFT descriptors for image matching. 我正在尝试使用SIFT描述符进行图像匹配。 I am planning to match one image with another.
我打算将一个图像与另一个图像进行匹配。
This is the code with which I am trying to make the match 这是我尝试匹配的代码
sift = cv2.xfeatures2d.SIFT_create()
kp_1, desc_1 = sift.detectAndCompute(original, None)
kp_2, desc_2 = sift.detectAndCompute(image_to_compare, None)
index_params = dict(algorithm=0, trees=5)
search_params = dict()
flann = cv2.FlannBasedMatcher(index_params, search_params)
matches = flann.knnMatch(desc_1, desc_2, k=2)
but I get the following error: 但我收到以下错误:
<ipython-input-6-1f81512d446c> in AlgSift(imagen, imagentocompare, umbral)
21 search_params = dict()
22 flann = cv2.FlannBasedMatcher(index_params, search_params)
---> 23 matches = flann.knnMatch(desc_1, desc_2, k=2)
24
25
error: OpenCV(3.4.2) /io/opencv/modules/flann/src/miniflann.cpp:487: error:
(-215:Assertion failed) (size_t)knn <= index_->size() in function
'runKnnSearch_'
An error such as Assertion failed occurred in my case because the position of the image to be loaded was not correct. 我的情况下发生了诸如断言失败的错误,因为要加载的图像位置不正确。 Please check your storage location and code once.
请检查一次您的存储位置和代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.