#include <opencv2/features.hpp>
|
virtual | ~ANNIndex ()=default |
|
virtual void | addItems (InputArray features)=0 |
| Add feature vectors to index.
|
|
virtual void | build (int trees=-1)=0 |
| Build the index.
|
|
virtual int | getItemNumber ()=0 |
| Return the number of feature vectors in the index.
|
|
virtual int | getTreeNumber ()=0 |
| Return the number of trees in the index.
|
|
virtual void | knnSearch (InputArray query, OutputArray indices, OutputArray dists, int knn, int search_k=-1)=0 |
| Performs a K-nearest neighbor search for given query vector(s) using the index.
|
|
virtual void | load (const String &filename, bool prefault=false)=0 |
| Loads (mmaps) an index from disk.
|
|
virtual void | save (const String &filename, bool prefault=false)=0 |
| Save the index to disk and loads it. After saving, no more vectors can be added.
|
|
virtual bool | setOnDiskBuild (const String &filename)=0 |
| Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
|
|
virtual void | setSeed (int seed)=0 |
| Initialize the random number generator with the given seed. Only necessary to pass this before adding the items. Will have no effect after calling build() or load().
|
|
◆ Distance
Metrics used to calculate the distance between two feature vectors.
Enumerator |
---|
DIST_EUCLIDEAN | |
DIST_MANHATTAN | |
DIST_ANGULAR | |
DIST_HAMMING | |
DIST_DOTPRODUCT | |
◆ ~ANNIndex()
virtual cv::ANNIndex::~ANNIndex |
( |
| ) |
|
|
virtualdefault |
◆ addItems()
virtual void cv::ANNIndex::addItems |
( |
InputArray |
features | ) |
|
|
pure virtual |
Python: |
---|
| cv.ANNIndex.addItems( | features | ) -> | None |
Add feature vectors to index.
- Parameters
-
features | Matrix containing the feature vectors to index. The size of the matrix is num_features x feature_dimension. |
◆ build()
virtual void cv::ANNIndex::build |
( |
int |
trees = -1 | ) |
|
|
pure virtual |
Python: |
---|
| cv.ANNIndex.build( | [, trees] | ) -> | None |
Build the index.
- Parameters
-
trees | Number of trees in the index. If not provided, the number is determined automatically in a way that at most 2x as much memory as the features vectors take is used. |
◆ create()
Python: |
---|
| cv.ANNIndex.create( | dim[, distType] | ) -> | retval |
| cv.ANNIndex_create( | dim[, distType] | ) -> | retval |
Creates an instance of annoy index class with given parameters.
- Parameters
-
dim | The dimension of the feature vector. |
distType | Metric to calculate the distance between two feature vectors, can be DIST_EUCLIDEAN, DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, or DIST_DOTPRODUCT. |
◆ getItemNumber()
virtual int cv::ANNIndex::getItemNumber |
( |
| ) |
|
|
pure virtual |
Python: |
---|
| cv.ANNIndex.getItemNumber( | | ) -> | retval |
Return the number of feature vectors in the index.
◆ getTreeNumber()
virtual int cv::ANNIndex::getTreeNumber |
( |
| ) |
|
|
pure virtual |
Python: |
---|
| cv.ANNIndex.getTreeNumber( | | ) -> | retval |
Return the number of trees in the index.
◆ knnSearch()
Python: |
---|
| cv.ANNIndex.knnSearch( | query, knn[, indices[, dists[, search_k]]] | ) -> | indices, dists |
Performs a K-nearest neighbor search for given query vector(s) using the index.
- Parameters
-
query | The query vector(s). |
indices | Matrix that will contain the indices of the K-nearest neighbors found, optional. |
dists | Matrix that will contain the distances to the K-nearest neighbors found, optional. |
knn | Number of nearest neighbors to search for. |
search_k | The maximum number of nodes to inspect, which defaults to trees x knn if not provided. |
◆ load()
virtual void cv::ANNIndex::load |
( |
const String & |
filename, |
|
|
bool |
prefault = false |
|
) |
| |
|
pure virtual |
Python: |
---|
| cv.ANNIndex.load( | filename[, prefault] | ) -> | None |
Loads (mmaps) an index from disk.
- Parameters
-
filename | Filename of the index to be loaded. |
prefault | If prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false. |
◆ save()
virtual void cv::ANNIndex::save |
( |
const String & |
filename, |
|
|
bool |
prefault = false |
|
) |
| |
|
pure virtual |
Python: |
---|
| cv.ANNIndex.save( | filename[, prefault] | ) -> | None |
Save the index to disk and loads it. After saving, no more vectors can be added.
- Parameters
-
filename | Filename of the index to be saved. |
prefault | If prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false. |
◆ setOnDiskBuild()
virtual bool cv::ANNIndex::setOnDiskBuild |
( |
const String & |
filename | ) |
|
|
pure virtual |
Python: |
---|
| cv.ANNIndex.setOnDiskBuild( | filename | ) -> | retval |
Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
- Parameters
-
filename | Filename of the index to be built. |
◆ setSeed()
virtual void cv::ANNIndex::setSeed |
( |
int |
seed | ) |
|
|
pure virtual |
Python: |
---|
| cv.ANNIndex.setSeed( | seed | ) -> | None |
Initialize the random number generator with the given seed. Only necessary to pass this before adding the items. Will have no effect after calling build() or load().
- Parameters
-
seed | The given seed of the random number generator. Its value should be within the range of uint32_t. |
The documentation for this class was generated from the following file: