Reputation: 19843
I'm training a BFMatcher with 4 descriptors:
bf = cv2.BFMatcher()
bf.clear()
bf.add(des1)
bf.add(des2)
bf.add(des3)
bf.add(des4)
bf.train()
bf.match(des1)
The code bf.match(des1)
throws this error:
error: ..\..\..\..\opencv\modules\core\src\stat.cpp:2473: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function cv::batchDistance
What could be the cause of this ? The descriptors are ORB descriptors.
Upvotes: 3
Views: 5378
Reputation: 64
You are right, you can add descriptors in lists but you can only match with single descriptors, so, go over the whole des1 array and match every single descriptor and save the matches in a list, or a set if you don't want them to be repeated!
matches = set()
for desc in desc1:
matches_img = bf.knnMatch(desc,k=2)
for match in matches_img:
matches.add(match)
Upvotes: 4
Reputation: 808
you should use:
bf = cv2.BFMatcher(cv2.NORM_HAMMING)
when using ORB. The error shows that the type used for ORB descriptor is not supported with the defualt L2 distance of the matcher.
Upvotes: 0