ORB example fails [closed]

asked 2015-03-15 19:54:24 -0500

Barry gravatar image

updated 2015-03-15 23:42:53 -0500

Hello, I am working through the examples in chapter 8 of the book Practical OpenCV by Samarth Brahmbhatt.

I'm running example 8.4, copied from their included source code:

vector<KeyPoint> train_kp;
Mat train_desc;

OrbFeatureDetector featureDetector;
featureDetector.detect(train_g, train_kp);

cout << "Key Point size" << train_kp.size() << endl;

OrbDescriptorExtractor featureExtractor;
featureExtractor.compute(train_g, train_kp, train_desc);

cout << "Descriptor depth " << train_desc.depth() << endl;

flann::Index flannIndex(train_desc, flann::LshIndexParams(12, 20, 2), cvflann::FLANN_DIST_HAMMING);

For train_kp.size(), I get 496. For train_descr.depth(), I get 0.

When executing I get an exception at the line, flann:: ...

I'm using their supplied image. I'm running on Windows compiling with Visual Studio 2012, while I believe they wrote and tested their code running on Linux. I have successfully run previous examples in the book.

I'm guessing that the 0 descriptors is at the heart of the problem and causes the exception at flann::.

Does anyone know why I'm getting this error? Is the problem, in fact, 0 descriptors?

Thanks, Barry.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-01 04:11:20.523552



"For train_descr.depth(), I get 0." - well, that should be correct, ORB descriptors are uchar, CV_8U.

did you confuse depth() and size() there ?

what exception do you get exactly ?

berak gravatar imageberak ( 2015-03-16 01:55:40 -0500 )edit

Thanks for your response. Yes, I was thinking that depth for a Mat was the same as size for a vector. I am very new to C++, I'll have to dig through some docs. I upgraded from OpenCV 2.4.10 to 2.4.11. The example now works as expected. Thanks.

Barry gravatar imageBarry ( 2015-03-17 18:54:43 -0500 )edit