New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BFMatcher raises error for Python interface when crossCheck option is enabled #46
Comments
I get this same error. Compiled OpenCV 3.0.0 from source on Ubuntu 14.04. |
Found explanation here: #5 crossCheck is an alternative to the ratio test. It breaks knnMatch. So either use crossCheck=False and then do the ratio test, or use crossCheck=True and use bf.match() instead of bf.knnMatch(). |
Cross-check does matching of two sets of descriptors D1 and D2 in both directions (D1 -> D2 and D2 <- D1) retaining matches that exists in both. Knn-match searches for N-best candidate for each descriptor. But it's impossible to make Cross-check between D1 and D2[N]. Therefore you have exception. As @dereks mentioned either you make cross-check or do knn-match with ratio test. |
I think it would be reasonable for crossCheck to compare D1[0] <-> D2[0] in the case of knnMatch(). That would validate the points by making sure the "best" matches were all crossChecked, and furthermore, they would then be subject to the distance ratio test between D[0] and D[1]. If I understand the algorithms correctly, this would apply two types of quality filtering, giving (perhaps?) better matching results with fewer outliers. Consider this a request to re-open this bug as a new wishlist feature. |
I too would like this feature of combining ratio test and crosscheck to improve matching results to be added to a new wishlist feature. If it would help in decreasing the outliers, then it is worth the effort. |
I am getting the same error(in opencv 3.x). I tried in opencv 2.x with crossCheck=True and bf.matcher.knnMatch(instead of bf.matcher.match). I got better results(less outliers). Is this problem, resolved or anyone has a solution?, please let me know. |
bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
matches = bf.knnMatch(descs,descs2, k=2)
raises
in ()
24 # BFMatcher with default params
25 bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
---> 26 matches = bf.knnMatch(descs,descs2, k=2)
27
28 # Apply ratio test
error: /home/retina18/Downloads/Install-OpenCV-master/Ubuntu/OpenCV/opencv-2.4.10/modules/core/src/stat.cpp:2500: error: (-215) K == 1 && update == 0 && mask.empty() in function batchDistance
If I remove crossCheck option this works fine but I really need cross checking :(
The text was updated successfully, but these errors were encountered: