31

I would like to know what is the difference in term of precision or quality of the matches between the BFMatcher and FlannBasedMatcher in openCV. I know the FlannBasedMatcher might be faster when applied to a large data base but are the two matcher going to find the same matches at the end regardless of the time of execution?

2 Answers 2

38

BFMatcher is going to try all the possibilities (which is the meaning of "Brute Force" and hence it will find the best matches.

FLANN, meaning "Fast Library for Approximate Nearest Neighbors", will be much faster but will find an approximate nearest neighbors. It will find a good matching, but not necessarily the best possible one. You can play with FLANN's parameters in order to increase the precision (i.e. the "quality" of the matchings), but it will be at the cost of slowing the algorithm.

In other words: FLANN is much faster than BFMatcher but it only finds an approximate nearest neighbor, which is a good matching but not necessarily the best. You can play with the parameters of FLANN in order to increase its speed or its precision.

1
  • 6
    How big should the database be to make BFMather to slow? If you have a list of 1000 descriptors? more, less?
    – Metalzero2
    Commented Jun 18, 2015 at 12:03
15

To add to the above answer, FLANN builds an efficient data structure (KD-Tree) that will be used to search for an approximate neighbour, while cv::BFMatcher does an exhaustive search and is guaranteed to find the best neighbour. The real benefit of FLANN is seen with large data sets. In my experience, I've seen a justifiable benefit is the number of descriptors is larger than 1K.

1
  • Could you please update the FLANN link? It seems dead. Thanks in advance!
    – Milan
    Commented Oct 11, 2022 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.