Ask Your Question

FLANN error in OpenCV 3

asked 2015-04-16 14:02:08 -0500

Metalzero2 gravatar image

Hello all, I am running Ubuntu 14.04. I am trying to run FLANN with openCV 3 but I get an error.

After I use ORB to find points, I use the following code to find matches:

  FlannBasedMatcher matcher;
  std::vector< DMatch > matches;
  matcher.match( descriptors_1, descriptors_2, matches );

The code builds fine and everything. When I run the code I get this error:

OpenCV Error: Unsupported format or combination of formats (type=0
) in buildIndex_, file /home/jim/opencv/modules/flann/src/miniflann.cpp, line 315
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/jim/opencv/modules/flann/src/miniflann.cpp:315: error: (-210) type=0
 in function buildIndex_

Aborted (core dumped)

Can anybody tell me why? Is it something with OpenCV 3 being in BETA state? Is there an alternative to FLANN (expect BFMetcher)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-04-16 17:58:58 -0500

Eduardo gravatar image

updated 2015-04-16 19:12:14 -0500


ORB is a binary descriptor and for the matching step you could use:

  • FLANN + LSH index (doc-2.4.11, doc-3.0), for e.g.: cv::Ptr<cv::DescriptorMatcher> matcher = cv::makePtr<cv::FlannBasedMatcher>(cv::makePtr<cv::flann::LshIndexParams>(12, 20, 2));
  • Brute Force + Hamming distance, for e.g.: cv::Ptr<DescriptorMatcher> matcher = cv::DescriptorMatcher::create("BruteForce-Hamming");

Also, for small database size, the difference in processing time between a brute force approach and the FLANN library is very small (LSH matching very slow), and keep in mind that FLANN means Fast Library for Approximate Nearest Neighbors.

For floating point descriptors (SIFT or SURF for example), the distance between two descriptors is computed using the Euclidean distance:

Euclidean distance

For binary descriptors, the Euclidean distance can be "simplified" with the Hamming distance:

Hamming distance

On modern CPU architecture, the two operations involved, xor and bits count is normally implemented in such a way that these operations are cheap in term of CPU time.

This seems to be the way that normHamming is implemented currently in OpenCV 3.0.

edit flag offensive delete link more


@Eduardo I do understand the theory but I cant implement this. I created the "matcher" in the way to suggested but what function of the object will find the matches? With my code I used "matcher.match(...)", what do I use now?

Metalzero2 gravatar imageMetalzero2 ( 2015-04-17 04:18:03 -0500 )edit

You can use:

Eduardo gravatar imageEduardo ( 2015-04-17 04:50:50 -0500 )edit

I had the same problem it seems that Flann needs the descriptors to be of type CV_32F. Try doing this before matching descriptors_1.convertTo(descriptors_1, CV_32F); descriptors_2.convertTo(descriptors_2, CV_32F);

annusachan24 gravatar imageannusachan24 ( 2017-07-19 01:30:02 -0500 )edit

Question Tools



Asked: 2015-04-16 14:02:08 -0500

Seen: 8,262 times

Last updated: Apr 16 '15