I am trying to use FLANN with ORB descriptors, but opencv crashes with this simple code:
vector<vector<KeyPoint> > dbKeypoints;
vector<Mat> dbDescriptors;
vector<Mat> objects;
/*
load Descriptors from images (with OrbDescriptorExtractor())
*/
FlannBasedMatcher matcher;
matcher.add(dbDescriptors);
matcher.train() //> Crash!
If I use SurfDescriptorExtractor()
it works well.
How can I solve this?
OpenCV says:
OpenCV Error: Unsupported format or combination of formats (type=0
) in unknown function, file D:\Value\Personal\Parthenope\OpenCV\modules\flann\sr
c\miniflann.cpp, line 299
FLANN stands for Fast Library for Approximate Nearest Neighbors. It contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features. It works faster than BFMatcher for large datasets.
Brute Force Matcher is used for matching the features of the first image with another image. It takes one descriptor of first image and matches to all the descriptors of the second image and then it goes to the second descriptor of first image and matches to all the descriptor of the second image and so on.
A brute-force matcher is a descriptor matcher that compares two sets of keypoint descriptors and generates a result that is a list of matches. It is called brute-force because little optimization is involved in the algorithm.
Flann needs the descriptors to be of type CV_32F so you need to convert them! find_object/example/main.cpp:
if(dbDescriptors.type()!=CV_32F) {
dbDescriptors.convertTo(dbDescriptors, CV_32F);
}
may work ;-)
It's a bug. It will be fixed soon.
http://answers.opencv.org/question/503/how-to-use-the-lshindexparams/
When using ORB you should construct your matcher like so:
FlannBasedMatcher matcher(new cv::flann::LshIndexParams(5, 24, 2));
I've also seen this constructor suggested:
FlannBasedMatcher matcher(new flann::LshIndexParams(20,10,2));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With