Ask Your Question
0

_queryDescriptors.type() == trainDescType [closed]

asked 2019-11-11 04:51:59 -0600

HelloWorld gravatar image

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

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;
    }
edit retag flag offensive reopen merge delete

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 ( 2019-11-11 05:37:04 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-11-11 05:02:31 -0600

berak gravatar image

updated 2019-11-11 05:13:18 -0600

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)

edit flag offensive delete link more

Comments

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

My technology is too weak.

HelloWorld gravatar imageHelloWorld ( 2019-11-11 07:20:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-11 04:51:59 -0600

Seen: 1,995 times

Last updated: Nov 11 '19