opencv FLANN with ORB descriptors?

dynamic picture dynamic · Jul 19, 2012 · Viewed 18k times · Source

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

Answer

hans picture hans · Aug 3, 2012

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