Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

_queryDescriptors.type() == trainDescType

Error message: terminate called after throwing an instance of 'cv::Exception'

what(): OpenCV(4.1.2-dev) /home/ztftrue/Downloads/opencv/modules/features2d/src/matchers.cpp:756: error: (-215:Assertion failed) _queryDescriptors.type() == trainDescType in function 'knnMatchImpl'

Code:

Mat input = cv::imread("input.jpg",IMREAD_COLOR);

cout << "input type: "<<input.type() &lt;&lt;="" endl;<="" p="">

cout << "descriptors type: " << descriptors.type() << endl;

bowide.compute(input, keypoints, descriptors);

Out put:

input type: 21 descriptors type: 0

I try:

input.convertTo(input, CV_32F, 1 / 255.0);

or

input.convertTo(input, CV_32F);

and filter keypoint vector

    if (!keypoints.empty() && keypoints.size() > 10) {

      cv::Mat descriptors;

      extractor->compute(it, keypoints, descriptors);

      if (!descriptors.empty()) {

          descriptors.convertTo(descriptors, CV_32F);

          trainingDescriptors.push_back(descriptors);

      } else {

          std::cout << "- No descriptors found." << std::endl;

      }
  } else {

      std::cout << "- No keypoints found." << std::endl;
  }
click to hide/show revision 2
None

updated 2019-11-11 04:59:40 -0600

berak gravatar image

_queryDescriptors.type() == trainDescType

Error message: terminate called after throwing an instance of 'cv::Exception'

what(): OpenCV(4.1.2-dev) /home/ztftrue/Downloads/opencv/modules/features2d/src/matchers.cpp:756: error: (-215:Assertion failed) _queryDescriptors.type() == trainDescType in function 'knnMatchImpl'

Code:

Mat input = cv::imread("input.jpg",IMREAD_COLOR);

cv::imread("input.jpg",IMREAD_COLOR); cout << "input type: "<<input.type() &lt;&lt;="" endl;<="" p="">

<< endl; cout << "descriptors type: " << descriptors.type() << endl;

endl; bowide.compute(input, keypoints, descriptors);

descriptors);

Out put:

input type: 21 descriptors type: 0

I try:

input.convertTo(input, CV_32F, 1 / 255.0);

255.0);

or

input.convertTo(input, CV_32F);

CV_32F);

and filter keypoint vector

     if (!keypoints.empty() && keypoints.size() > 10) {
        cv::Mat descriptors;
        extractor->compute(it, keypoints, descriptors);
        if (!descriptors.empty()) {
            descriptors.convertTo(descriptors, CV_32F);
            trainingDescriptors.push_back(descriptors);
        } else {
            std::cout << "- No descriptors found." << std::endl;
        }
   } else {
        std::cout << "- No keypoints found." << std::endl;
   }