Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencv FLANN with ORB descriptors?

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
like image 227
dynamic Avatar asked Jul 19 '12 16:07

dynamic


People also ask

What is Flann in Opencv?

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.

What is BFMatcher?

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.

What is brute force matching?

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.


3 Answers

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 ;-)

like image 187
Hans Sperker Avatar answered Oct 01 '22 02:10

Hans Sperker


It's a bug. It will be fixed soon.

http://answers.opencv.org/question/503/how-to-use-the-lshindexparams/

like image 36
dynamic Avatar answered Oct 01 '22 01:10

dynamic


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));
like image 36
Rick Smith Avatar answered Oct 01 '22 02:10

Rick Smith