In python, OpenCV's FlannBasedMatcher
constructor takes a dictionary of parametres, the first of which is algorithm
. The python tutorial suggests that one can specify different values of algorithm
by passing differently named variables, e.g. FLANN_INDEX_KDTREE
and FLANN_INDEX_LSH
, but the variable name cannot, of course, convey anything to the constructor. One might think that these names should instead be passed as strings, but in the example that follows, FLANN_INDEX_KDTREE
is initialised as 0, and so it is entirely unclear how the algorithm
parametre works.
OpenCV doesn't really have any python documentation. In C++, the constructor doesn't take a generic dictionary, but an object that instantiates IndexClass
, where each subclass of IndexClass
corresponds to a different algorithm.
algorithm
takes an integer, what is missing from the tutorial is the initialisation of FLANN_INDEX_KDTREE
and FLANN_INDEX_LSH
with different values. (The upper case should have been a hint that these are meant as descriptive labels of fixed integer values.)
The C++ source code has such a list of initialisations, from which it appears that the LSH algorithm corresponds to the value 6. It also initialises FLANN_INDEX_KDTREE
as 1, which means that either the python tutorial, which has 0, is wrong, or that the source code uses conflicting definitions in different places (that I missed), which would be unfortunate.
These are all the values in the source code:
FLANN_INDEX_LINEAR = 0
FLANN_INDEX_KDTREE = 1
FLANN_INDEX_KMEANS = 2
FLANN_INDEX_COMPOSITE = 3
FLANN_INDEX_KDTREE_SINGLE = 4
FLANN_INDEX_HIERARCHICAL = 5
FLANN_INDEX_LSH = 6
FLANN_INDEX_SAVED = 254
FLANN_INDEX_AUTOTUNED = 255
EDIT: I filed a pull request fixing both issues that has now been accepted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With