OpenCV
4.5.4
Open Source Computer Vision

Classes  
struct  cv::flann::CvType< T > 
struct  cv::flann::CvType< char > 
struct  cv::flann::CvType< double > 
struct  cv::flann::CvType< float > 
struct  cv::flann::CvType< short > 
struct  cv::flann::CvType< unsigned char > 
struct  cv::flann::CvType< unsigned short > 
class  cv::flann::GenericIndex< Distance > 
The FLANN nearest neighbor index class. This class is templated with the type of elements for which the index is built. More...  
Functions  
template<typename Distance >  
int  cv::flann::hierarchicalClustering (const Mat &features, Mat ¢ers, const ::cvflann::KMeansIndexParams ¶ms, Distance d=Distance()) 
Clusters features using hierarchical kmeans algorithm. More...  
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 [179] .
int cv::flann::hierarchicalClustering  (  const Mat &  features, 
Mat &  centers,  
const ::cvflann::KMeansIndexParams &  params,  
Distance  d = Distance() 

) 
#include <opencv2/flann.hpp>
Clusters features using hierarchical kmeans algorithm.
features  The points to be clustered. The matrix must have elements of type Distance::ElementType. 
centers  The centers of the clusters obtained. The matrix must have type Distance::CentersType. The number of rows in this matrix represents the number of clusters desired, however, because of the way the cut in the hierarchical tree is chosen, the number of clusters computed will be the highest number of the form (branching1)*k+1 that's lower than the number of clusters desired, where branching is the tree's branching factor (see description of the KMeansIndexParams). 
params  Parameters used in the construction of the hierarchical kmeans tree. 
d  Distance to be used for clustering. 
The method clusters the given feature vectors by constructing a hierarchical kmeans tree and choosing a cut in the tree that minimizes the cluster's variance. It returns the number of clusters found.