Using The FLANN Benchmarking Programs

FLANN has a very nice and generic interface to work with various indexing algorithms. One only needs to specify the index method and parameters when building the index, and the same API can be used to load the index and conduct online search.

Here's how to use the "flann_index" and "flann_search" programs provided in the KGraph SDK.

The following command will build a KDtree and save that to the file sift.kdtree.

$ flann_index sift.kdtree -A kdtree -P trees%=4

And the following for kmeans index.

$ flann_index sift.kmeans -A kmeans -P branching%=4 -P cb_index!=0.2

All Supported Indices

The index algorithm is specified with "-A", and parameters to the algorithm is passed with multiple "-P" in the form of "-P name%=integer" or "-P name!=float". (It is unfortunate that I haven't figured out a way to uniformly deal with integer parameters and float ones, so a little bit Basic-like modifiers need to be used.)

For search, one only need to provide the index file no matter how it was built.

$ flann_search sift.index sift.query  [sift.output] [--eval goldstandard]

"sift.index" is "sift.kdtree" or "sift.kmeans" or other indices previously built. Goldstandard is generated by searching with brutal force (a index created with "-A linear".)

All FLANN Indices Supported

$ ./flann_index --help
flann_index [-A algo] [-P key=value ...] <data> [output]
General options:
  -h [ --help ]                    produce help message.
  --data arg                       input path
  --output arg                     output path
  -A [ --algorithm ] arg (=linear) linear, kdtree, kmeans, hier, comp, auto,
  -P arg                           parameters passed to flann
  -v [ --verbose ]

Algorithm specific parameters are passed as '-P name%=value' (integer) or '-P name!=value' (float).
Available parameters and their default values:
           center_init=0 (RANDOM 0, GONZALES 1, KEMANSPP 2)
           center_init=0 (RANDOM 0, GONZALES 1, KEMANSPP 2)
           center_init=0 (RANDOM 0, GONZALES 1, KEMANSPP 2)