When I tried to use drawMatchesKnn function as mentioned in this tutorial for FLANN feature matching, I get the following error
AttributeError: 'module' object has no attribute 'drawMatchesKnn'
I checked with other resources that drawMatchesKnn method is present in opencv.
Why am I getting this error?
Thanks in advance
The functions
cv2.drawMatches
andcv2.drawMatchesKnn
are not available in newer versions of OpenCV 2.4. @rayryeng provided a lightweight alternative which works as is for the output ofDescriptorMatcher.match
. The difference withDescriptorMatcher.knnMatch
is that the matches are returned as a list of lists. To use the @rayryeng alternative, the matches must be extracted into a 1-D list.For example, the Brute-Force Matching with SIFT Descriptors and Ratio Test tutorial could be amended as such:
You need to use OpenCV version 3.
drawMatchesKnn()
is present in 3.0.0-alpha but not in 2.4.11That error is there, because you are using an old version of OpenCV.