template<typename Distance >
cv::flann::GenericIndex< Distance >::GenericIndex | ( | const Mat & | features, |
const ::cvflann::IndexParams & | params, | ||
Distance | distance = Distance() | ||
) |
类的作用:根据给定数据集构建最近邻搜索索引
参数:
features 包含特征(点)的矩阵,用于索引。矩阵的大小等于num_feature(特征数)× feature_dimensionality(特征维数)(原文:The size of the matrix is num_features x feature_dimensionality) 矩阵元素的数据类型必须和索引类型相同。
params 包含索引参数的结构体(原文:Structure containing the index parameters)索引的类型将取决于该参数的类型。
distance 该方法使用具有指定参数的指定算法从一组特征构造快速搜索结构,如params所定义。
params是对以下类IndexParams后代之一的引用:
- LinearIndexParams When passing an object of this type, the index will perform a linear, brute-force search. :
- KDTreeIndexParams When passing an object of this type the index constructed will consist of a set of randomized kd-trees which will be searched in parallel. :
- KMeansIndexParams When passing an object of this type the index constructed will be a hierarchical k-means tree. :
{KMeansIndexParams(int branching = 32,int iterations = 11,flann_centers_init_t centers_init = CENTERS_RANDOM,float cb_index = 0.2 );};
- CompositeIndexParams When using a parameters object of this type the index created combines the randomized kd-trees and the hierarchical k-means tree. :
{CompositeIndexParams(int trees = 4,int branching = 32,int iterations = 11,flann_centers_init_t centers_init = CENTERS_RANDOM,float cb_index = 0.2 );};
- LshIndexParams When using a parameters object of this type the index created uses multi-probe LSH (by Multi-Probe LSH: Efficient Indexing for High-Dimensional Similarity Search by Qin Lv, William Josephson, Zhe Wang, Moses Charikar, Kai Li., Proceedings of the 33rd International Conference on Very Large Data Bases (VLDB). Vienna, Austria. September 2007) :
{LshIndexParams(unsigned int table_number,unsigned int key_size,unsigned int multi_probe_level );};
- AutotunedIndexParams When passing an object of this type the index created is automatically tuned to offer the best performance, by choosing the optimal index type (randomized kd-trees, hierarchical kmeans, linear) and parameters for the dataset provided. :
{AutotunedIndexParams(float target_precision = 0.9,float build_weight = 0.01,float memory_weight = 0,float sample_fraction = 0.1 );};
- SavedIndexParams This object type is used for loading a previously saved index from the disk. :