Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assertion failed (queryDescriptors.type() == trainDescCollection[0].type()) in knnMatchImpl,

when using BOWImgDescriptorExtractor with DescriptorExtractor as SIFT and DescriptorMatcher as ButeForce i am getting error as

OpenCV Error: Assertion failed (queryDescriptors.type() == trainDescCollection[0].type()) in knnMatchImpl,

what could me my error.

when i am trying to compute eg.

bowide->compute(img, keypoints, response_hist);

like image 366
user2467804 Avatar asked Mar 11 '14 22:03

user2467804


2 Answers

I had the same error using the Surf feature detector and extractor with BFMatcher.

The error occurs because the query descriptor mat and train descriptor mat doesn't have the same type - as stated in your error message. This happened to me only when no keypoints for the train or query image could be calculated by the feature detector. Check that the size of your keypoints vector is not zero before doing the matching.

like image 109
Frik Avatar answered Oct 06 '22 08:10

Frik


I also had the same error. There is another possible reason: the dtype of the dictionary should be float32. It turns out that I did some operations with the dictionary with numpy before calling the setVocabulary function, which changed the dtype of the dictionary implicitly.

like image 31
Kaiwen Avatar answered Oct 06 '22 08:10

Kaiwen