![]() |
OpenCV 4.12.0
开源计算机视觉
|
FLANN 最近邻索引类。此类的模板是用于构建索引的元素类型。 更多...
#include <opencv2/flann.hpp>
公共类型 | |
| typedef Distance::ResultType | DistanceType |
| typedef Distance::ElementType | ElementType |
公共成员函数 | |
| GenericIndex (const Mat &features, const ::cvflann::IndexParams ¶ms, Distance distance=Distance()) | |
| 为给定数据集构造最近邻搜索索引。 | |
| ~GenericIndex () | |
| const ::cvflann::IndexParams * | getIndexParameters () |
| ::cvflann::IndexParams | getParameters () |
| void | knnSearch (const Mat &queries, Mat &indices, Mat &dists, int knn, const ::cvflann::SearchParams ¶ms) |
| void | knnSearch (const std::vector< ElementType > &query, std::vector< int > &indices, std::vector< DistanceType > &dists, int knn, const ::cvflann::SearchParams ¶ms) |
| 使用索引对给定查询点执行 K-最近邻搜索。 | |
| int | radiusSearch (const Mat &query, Mat &indices, Mat &dists, DistanceType radius, const ::cvflann::SearchParams ¶ms) |
| int | radiusSearch (const std::vector< ElementType > &query, std::vector< int > &indices, std::vector< DistanceType > &dists, DistanceType radius, const ::cvflann::SearchParams ¶ms) |
| 使用索引对给定查询点执行半径最近邻搜索。 | |
| void | save (String filename) |
| int | size () const |
| int | veclen () const |
FLANN 最近邻索引类。此类的模板是用于构建索引的元素类型。
Distance 仿函数指定用于计算两点之间距离的度量。有几种现成的 Distance 仿函数可用
cv::cvflann::L2_Simple - 平方欧几里德距离仿函数。这是更简单、展开的版本。对于非常低维的数据(例如 3D 点)更推荐使用此版本。
cv::flann::L2 - 平方欧几里德距离仿函数,优化版本。
cv::flann::L1 - 曼哈顿距离仿函数,优化版本。
cv::flann::MinkowskiDistance - 闵可夫斯基距离仿函数。通过循环展开进行了高度优化。为了提高效率,末尾省略了平方根的计算。
cv::flann::MaxDistance - 最大距离仿函数。它计算两个向量之间的最大距离。此距离不是有效的 kdtree 距离,它不是按维度累加的。
cv::flann::HammingLUT - 汉明距离仿函数。它使用查找表实现来计算两个字符串之间的位差异。
cv::flann::Hamming - 汉明距离仿函数。如果可用,通过库调用执行位计数。查找表实现用作备选方案。
cv::flann::Hamming2 - 汉明距离仿函数。位计数通过 12 个算术操作(其中一个是乘法)实现。
cv::flann::DNAmmingLUT - 汉明距离仿函数在 DNA 比较中的改编。由于 DNA 的四个碱基 A、C、G、T(或 RNA 的 A、G、C、U)可以用 2 位编码,它使用查找表实现来计算两个序列之间的位对差异。
cv::flann::DNAmming2 - 汉明距离仿函数在 DNA 比较中的改编。由于使用标准寄存器的算术运算(AVX2 和 AVX-512 即将推出),碱基差异计数已向量化。
cv::flann::HistIntersectionDistance - 直方图交集距离仿函数。
cv::flann::HellingerDistance - 海林格距离仿函数。
cv::flann::ChiSquareDistance - 卡方距离仿函数。
cv::flann::KL_Divergence - Kullback-Leibler 散度仿函数。
尽管提供的实现涵盖了广泛的用例,也可以使用自定义实现。距离仿函数是一个类,其 operator() 计算两个特征之间的距离。如果该距离也是 kd-tree 兼容距离,它还应提供一个 accum_dist() 方法,用于计算单个特征维度之间的距离。
除了 operator() 和 accum_dist() 之外,距离仿函数还应将 ElementType 和 ResultType 定义为其操作的元素的类型以及其计算结果的类型。如果距离仿函数可以用作 kd-tree 距离(这意味着一对特征之间的完整距离可以从单个维度之间的部分距离累加),则距离仿函数内部应存在 typedef is_kdtree_distance。如果距离不是 kd-tree 距离,但它是向量空间中的距离(其操作的元素的单个维度可以独立访问),则仿函数内部应定义 typedef is_vector_space_distance。如果两者都没有定义,则假定该距离是度量距离,并且仅用于对通用度量距离进行操作的索引。
| Distance::ResultType cv::flann::GenericIndex< Distance >::DistanceType |
| Distance::ElementType cv::flann::GenericIndex< Distance >::ElementType |
| cv::flann::GenericIndex< Distance >::GenericIndex | ( | const Mat & | features, |
| const ::cvflann::IndexParams & | params, | ||
| Distance | distance = Distance() ) |
为给定数据集构造最近邻搜索索引。
| features | 包含待索引特征(点)的矩阵。矩阵的大小为 num_features x feature_dimensionality,且矩阵中元素的数据类型必须与索引类型一致。 |
| params | 包含索引参数的结构。将要构建的索引类型取决于此参数的类型。请参阅描述。 |
| distance |
该方法使用指定算法和由 params 定义的参数,从一组特征构造一个快速搜索结构。params 是以下 IndexParams 类后代之一的引用:
| cv::flann::GenericIndex< Distance >::~GenericIndex | ( | ) |
|
inline |
|
inline |
| void cv::flann::GenericIndex< Distance >::knnSearch | ( | const Mat & | 查询, |
| Mat & | 索引, | ||
| Mat & | 距离, | ||
| int | knn, | ||
| const ::cvflann::SearchParams & | params ) |
| void cv::flann::GenericIndex< Distance >::knnSearch | ( | const std::vector< ElementType > & | query, |
| std::vector< int > & | 索引, | ||
| std::vector< DistanceType > & | 距离, | ||
| int | knn, | ||
| const ::cvflann::SearchParams & | params ) |
使用索引对给定查询点执行 K-最近邻搜索。
| query | 查询点 |
| 索引 | 将包含找到的 K-最近邻索引的向量。其大小必须至少为 knn。 |
| 距离 | 将包含找到的 K-最近邻距离的向量。其大小必须至少为 knn。 |
| knn | 要搜索的最近邻数量。 |
| params | SearchParams |
| int cv::flann::GenericIndex< Distance >::radiusSearch | ( | const Mat & | query, |
| Mat & | 索引, | ||
| Mat & | 距离, | ||
| DistanceType | radius, | ||
| const ::cvflann::SearchParams & | params ) |
| int cv::flann::GenericIndex< Distance >::radiusSearch | ( | const std::vector< ElementType > & | query, |
| std::vector< int > & | 索引, | ||
| std::vector< DistanceType > & | 距离, | ||
| DistanceType | radius, | ||
| const ::cvflann::SearchParams & | params ) |
使用索引对给定查询点执行半径最近邻搜索。
| query | 查询点。 |
| 索引 | 将包含找到的最近邻索引的向量。 |
| 距离 | 将包含找到的最近邻距离的向量。其元素数量与索引相同。 |
| radius | 搜索半径。 |
| params | SearchParams |
此函数返回找到的最近邻数量。
|
inline |
|
inline |
|
inline |