opencv on mbed
KMeansIndex< Distance > Class Template Reference
Hierarchical kmeans index. More...
#include <kmeans_index.h>
Inherits cvflann::NNIndex< Distance >.
Public Member Functions | |
void | chooseCentersRandom (int k, int *indices, int indices_length, int *centers, int ¢ers_length) |
Chooses the initial centers in the k-means clustering in a random manner. | |
void | chooseCentersGonzales (int k, int *indices, int indices_length, int *centers, int ¢ers_length) |
Chooses the initial centers in the k-means using Gonzales' algorithm so that the centers are spaced apart from each other. | |
void | chooseCentersKMeanspp (int k, int *indices, int indices_length, int *centers, int ¢ers_length) |
Chooses the initial centers in the k-means using the algorithm proposed in the KMeans++ paper: Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding. | |
flann_algorithm_t | getType () const |
KMeansIndex (const Matrix< ElementType > &inputData, const IndexParams ¶ms=KMeansIndexParams(), Distance d=Distance()) | |
Index constructor. | |
virtual | ~KMeansIndex () |
Index destructor. | |
size_t | size () const |
Returns size of index. | |
size_t | veclen () const |
Returns the length of an index feature. | |
int | usedMemory () const |
Computes the inde memory usage Returns: memory used by the index. | |
void | buildIndex () |
Builds the index. | |
void | saveIndex (FILE *stream) |
Saves the index to a stream. | |
void | loadIndex (FILE *stream) |
Loads the index from a stream. | |
void | findNeighbors (ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &searchParams) |
Find set of nearest neighbors to vec. | |
int | getClusterCenters (Matrix< DistanceType > ¢ers) |
Clustering function that takes a cut in the hierarchical k-means tree and return the clusters centers of that clustering. | |
IndexParams | getParameters () const |
virtual void | knnSearch (const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, int knn, const SearchParams ¶ms) |
Perform k-nearest neighbor search. | |
virtual int | radiusSearch (const Matrix< ElementType > &query, Matrix< int > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams ¶ms) |
Perform radius search. | |
virtual void | findNeighbors (ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &searchParams)=0 |
Method that searches for nearest-neighbours. | |
Data Fields | |
centersAlgFunction | chooseCenters |
The function used for choosing the cluster centers. |
Detailed Description
template<typename Distance>
class cvflann::KMeansIndex< Distance >
Hierarchical kmeans index.
Contains a tree constructed through a hierarchical kmeans clustering and other information for indexing a set of points for nearest-neighbour matching.
Definition at line 80 of file kmeans_index.h.
Constructor & Destructor Documentation
KMeansIndex | ( | const Matrix< ElementType > & | inputData, |
const IndexParams & | params = KMeansIndexParams() , |
||
Distance | d = Distance() |
||
) |
Index constructor.
Params: inputData = dataset with the input features params = parameters passed to the hierarchical k-means algorithm
Definition at line 346 of file kmeans_index.h.
virtual ~KMeansIndex | ( | ) | [virtual] |
Index destructor.
Release the memory used by the index.
Definition at line 388 of file kmeans_index.h.
Member Function Documentation
void buildIndex | ( | ) | [virtual] |
void chooseCentersGonzales | ( | int | k, |
int * | indices, | ||
int | indices_length, | ||
int * | centers, | ||
int & | centers_length | ||
) |
Chooses the initial centers in the k-means using Gonzales' algorithm so that the centers are spaced apart from each other.
Params: k = number of centers vecs = the dataset of points indices = indices in the dataset Returns:
Definition at line 148 of file kmeans_index.h.
void chooseCentersKMeanspp | ( | int | k, |
int * | indices, | ||
int | indices_length, | ||
int * | centers, | ||
int & | centers_length | ||
) |
Chooses the initial centers in the k-means using the algorithm proposed in the KMeans++ paper: Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding.
Implementation of this function was converted from the one provided in Arthur's code.
Params: k = number of centers vecs = the dataset of points indices = indices in the dataset Returns:
Definition at line 199 of file kmeans_index.h.
void chooseCentersRandom | ( | int | k, |
int * | indices, | ||
int | indices_length, | ||
int * | centers, | ||
int & | centers_length | ||
) |
Chooses the initial centers in the k-means clustering in a random manner.
Params: k = number of centers vecs = the dataset of points indices = indices in the dataset indices_length = length of indices vector
Definition at line 107 of file kmeans_index.h.
virtual void findNeighbors | ( | ResultSet< DistanceType > & | result, |
const ElementType * | vec, | ||
const SearchParams & | searchParams | ||
) | [pure virtual, inherited] |
Method that searches for nearest-neighbours.
void findNeighbors | ( | ResultSet< DistanceType > & | result, |
const ElementType * | vec, | ||
const SearchParams & | searchParams | ||
) |
Find set of nearest neighbors to vec.
Their indices are stored inside the result object.
Params: result = the result object in which the indices of the nearest-neighbors are stored vec = the vector for which to search the nearest neighbors searchParams = parameters that influence the search algorithm (checks, cb_index)
Definition at line 498 of file kmeans_index.h.
int getClusterCenters | ( | Matrix< DistanceType > & | centers ) |
Clustering function that takes a cut in the hierarchical k-means tree and return the clusters centers of that clustering.
Params: numClusters = number of clusters to have in the clustering computed Returns: number of cluster centers
Definition at line 532 of file kmeans_index.h.
IndexParams getParameters | ( | ) | const [virtual] |
- Returns:
- The index parameters
Implements NNIndex< Distance >.
Definition at line 557 of file kmeans_index.h.
flann_algorithm_t getType | ( | ) | const [virtual] |
- Returns:
- The index type (kdtree, kmeans,...)
Implements NNIndex< Distance >.
Definition at line 269 of file kmeans_index.h.
virtual void knnSearch | ( | const Matrix< ElementType > & | queries, |
Matrix< int > & | indices, | ||
Matrix< DistanceType > & | dists, | ||
int | knn, | ||
const SearchParams & | params | ||
) | [virtual, inherited] |
Perform k-nearest neighbor search.
- Parameters:
-
[in] queries The query points for which to find the nearest neighbors [out] indices The indices of the nearest neighbors found [out] dists Distances to the nearest neighbors found [in] knn Number of nearest neighbors to return [in] params Search parameters
Definition at line 68 of file nn_index.h.
void loadIndex | ( | FILE * | stream ) | [virtual] |
Loads the index from a stream.
- Parameters:
-
stream The stream from which the index is loaded
Implements NNIndex< Distance >.
Definition at line 463 of file kmeans_index.h.
virtual int radiusSearch | ( | const Matrix< ElementType > & | query, |
Matrix< int > & | indices, | ||
Matrix< DistanceType > & | dists, | ||
float | radius, | ||
const SearchParams & | params | ||
) | [virtual, inherited] |
Perform radius search.
- Parameters:
-
[in] query The query point [out] indices The indinces of the neighbors found within the given radius [out] dists The distances to the nearest neighbors found [in] radius The radius used for search [in] params Search parameters
- Returns:
- Number of neighbors found
Definition at line 102 of file nn_index.h.
void saveIndex | ( | FILE * | stream ) | [virtual] |
Saves the index to a stream.
- Parameters:
-
stream The stream to save the index to
Implements NNIndex< Distance >.
Definition at line 451 of file kmeans_index.h.
size_t size | ( | ) | const [virtual] |
Returns size of index.
Implements NNIndex< Distance >.
Definition at line 401 of file kmeans_index.h.
int usedMemory | ( | ) | const [virtual] |
Computes the inde memory usage Returns: memory used by the index.
Implements NNIndex< Distance >.
Definition at line 424 of file kmeans_index.h.
size_t veclen | ( | ) | const [virtual] |
Returns the length of an index feature.
Implements NNIndex< Distance >.
Definition at line 409 of file kmeans_index.h.
Field Documentation
centersAlgFunction chooseCenters |
The function used for choosing the cluster centers.
Definition at line 93 of file kmeans_index.h.
Generated on Tue Jul 12 2022 16:42:45 by 1.7.2