What distance function does the FlannBasedMatcher use and how to change it?

What distance function does openCVs flannBasedMatcher perform, and is it possible to change the default value? There are several different types of distances (flann_distance_t) in the user manual from the original Muji and Lowan flan, and I don’t see a way in opencv to change them: - /

+4
source share
1 answer

This is very poorly documented in the code for openCV, but the default settings for flannBasedMatcher are in these two functions

Flann :: SearchParams (); // 32 checks, 0, sorted = true Flann :: KDTreeIndexParams (); // uses 4 randomized KD trees

The default distance function is FLANN_DIST_L2.

I think this code snippet explains why you cannot change it yet printf("[WARNING] You are using cv::flann::Index (or cv::flann::GenericIndex) and have also changed the distance using cvflann::set_distance_type. This is no longer working as expected cv::flann::Index always uses L2). You should create the index templated on the distance, for example for L1 distance use: GenericIndex< L1<float> > \n"); \ printf("[WARNING] You are using cv::flann::Index (or cv::flann::GenericIndex) and have also changed the distance using cvflann::set_distance_type. This is no longer working as expected cv::flann::Index always uses L2). You should create the index templated on the distance, for example for L1 distance use: GenericIndex< L1<float> > \n"); \

+3
source

Source: https://habr.com/ru/post/1416143/


All Articles