First time here? Check out the FAQ!

Ask Your Question
0

_queryDescriptors.type() == trainDescType [closed]

asked Nov 11 '19

HelloWorld gravatar image

updated Nov 11 '19

berak gravatar image

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() << endl;
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;
    }
Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by HelloWorld
close date 2019-11-11 07:20:53.617342

Comments

what is "extractor" ?

berak gravatar imageberak (Nov 11 '19)edit

1 answer

Sort by » oldest newest most voted
0

answered Nov 11 '19

berak gravatar image

updated Nov 11 '19

descriptors type: 0

which kind of keypoints/descriptors did you use ? you can use BOW only with SIFT,SURF or AKAZE(UPRIGHT), float descriptors. it does NOT make any sense to try with ORB or the like, there is no kmeans for bitstring descriptors. (so please don't try to convert them)

Preview: (hide)

Comments

Sorry, my reply is very late, I use ORB, now I can, thank you.

My technology is too weak.

HelloWorld gravatar imageHelloWorld (Nov 11 '19)edit

Question Tools

1 follower

Stats

Asked: Nov 11 '19

Seen: 2,034 times

Last updated: Nov 11 '19