This section documents OpenCV’s interface to the FLANN library. FLANN (Fast Library for Approximate Nearest Neighbors) is a library that contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features. More information about FLANN can be found in muja_flann_2009 .
The FLANN nearest neighbor index class. This class is templated with the type of elements for which the index is built.
namespace cv
{
namespace flann
{
template <typename T>
class Index_
{
public:
Index_(const Mat& features, const IndexParams& params);
~Index_();
void knnSearch(const vector<T>& query,
vector<int>& indices,
vector<float>& dists,
int knn,
const SearchParams& params);
void knnSearch(const Mat& queries,
Mat& indices,
Mat& dists,
int knn,
const SearchParams& params);
int radiusSearch(const vector<T>& query,
vector<int>& indices,
vector<float>& dists,
float radius,
const SearchParams& params);
int radiusSearch(const Mat& query,
Mat& indices,
Mat& dists,
float radius,
const SearchParams& params);
void save(std::string filename);
int veclen() const;
int size() const;
const IndexParams* getIndexParameters();
};
typedef Index_<float> Index;
} } // namespace cv::flann
Constructs a nearest neighbor search index for a given dataset.
Parameters: |
|
---|
Performs a K-nearest neighbor search for a given query point using the index.
Parameters: |
|
---|
struct SearchParams {
SearchParams(int checks = 32);
};
- checks The number of times the tree(s) in the index should be recursively traversed. A higher value for this parameter would give better search precision, but also take more time. If automatic configuration was used when the index was created, the number of checks required to achieve the specified precision was also computed, in which case this parameter is ignored.
Performs a radius nearest neighbor search for a given query point.
Parameters: |
|
---|
Saves the index to a file.
Parameters: |
|
---|