I'm writing an image matching algorithm based on surf. I initialize surf with 400 hessian threshold:
surf = cv2.SURF(400)
and did flann matching.
But it is running too slow (on large sets of images). Then I decided to do light testing initially, followed by deep testing. So I changed the hessian threshold value to 1200.
surf = cv2.SURF(1200)
It is much faster now.
matches = flann.knnMatch(des1,des2,k=2)
But on some images it throws the following error:
OpenCV Error: Assertion failed ((globalDescIdx>=0) && (globalDescIdx < size())) in getLocalIdx, file /tmp/opencv-2.4.10/modules/features2d/src/matchers.cpp, line 163
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "indexThreadsDeep.py", line 97, in threadRun
if(imageMatch(qDes,tDes)):
File "indexThreadsDeep.py", line 69, in imageMatch
matches = flann.knnMatch(des1,des2,k=2)
error: /tmp/opencv-2.4.10/modules/features2d/src/matchers.cpp:163: error: (-215) (globalDescIdx>=0) && (globalDescIdx < size()) in function getLocalIdx
The issue was coming because due to high hession threshold there is only one keypoint in some images.But in knnMatch i was looking for 2 nearest neighbours.