OpenCV for Unity 3.0.4
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/5.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.FeaturesModule.ANNIndex Class Reference

Public Member Functions

void addItems (Mat features)
 Add feature vectors to index.
 
void build ()
 Build the index.
 
void build (int trees)
 Build the index.
 
int getItemNumber ()
 Return the number of feature vectors in the index.
 
IntPtr getNativeObjAddr ()
 
int getTreeNumber ()
 Return the number of trees in the index.
 
void knnSearch (Mat query, Mat indices, Mat dists, int knn)
 Performs a K-nearest neighbor search for given query vector(s) using the index.
 
void knnSearch (Mat query, Mat indices, Mat dists, int knn, int search_k)
 Performs a K-nearest neighbor search for given query vector(s) using the index.
 
void load (string filename)
 Loads (mmaps) an index from disk.
 
void load (string filename, bool prefault)
 Loads (mmaps) an index from disk.
 
void save (string filename)
 Save the index to disk and loads it. After saving, no more vectors can be added.
 
void save (string filename, bool prefault)
 Save the index to disk and loads it. After saving, no more vectors can be added.
 
bool setOnDiskBuild (string filename)
 Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
 
void setSeed (int seed)
 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().
 
- Public Member Functions inherited from OpenCVForUnity.DisposableObject
void Dispose ()
 Releases resources used by this object.
 
void ThrowIfDisposed ()
 Throws ObjectDisposedException if this object has been disposed.
 

Static Public Member Functions

static ANNIndex __fromPtr__ (IntPtr addr)
 
static ANNIndex create (int dim)
 Creates an instance of annoy index class with given parameters.
 
static ANNIndex create (int dim, int distType)
 Creates an instance of annoy index class with given parameters.
 
- Static Public Member Functions inherited from OpenCVForUnity.DisposableObject
static IntPtr ThrowIfNullIntPtr (IntPtr ptr)
 Returns the native pointer, or throws CoreModule.CvException if it is zero.
 

Static Public Attributes

const int DIST_ANGULAR = 2
 C++: enum Distance (cv.ANNIndex.Distance)
 
const int DIST_DOTPRODUCT = 4
 C++: enum Distance (cv.ANNIndex.Distance)
 
const int DIST_EUCLIDEAN = 0
 C++: enum Distance (cv.ANNIndex.Distance)
 
const int DIST_HAMMING = 3
 C++: enum Distance (cv.ANNIndex.Distance)
 
const int DIST_MANHATTAN = 1
 C++: enum Distance (cv.ANNIndex.Distance)
 

Protected Member Functions

override void Dispose (bool disposing)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableOpenCVObject
 DisposableOpenCVObject ()
 Initializes a new instance with a zero native pointer and dispose enabled.
 
 DisposableOpenCVObject (bool isEnabledDispose)
 Initializes a new instance with a zero native pointer.
 
 DisposableOpenCVObject (IntPtr ptr)
 Initializes a new instance with the specified native pointer and dispose enabled.
 
 DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose)
 Initializes a new instance with the specified native pointer.
 
override void Dispose (bool disposing)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableObject
 DisposableObject ()
 Initializes a new instance with dispose enabled.
 
 DisposableObject (bool isEnabledDispose)
 Initializes a new instance.
 

Additional Inherited Members

- Package Attributes inherited from OpenCVForUnity.DisposableOpenCVObject
- Properties inherited from OpenCVForUnity.DisposableObject
bool IsDisposed [get, protected set]
 
bool IsEnabledDispose [get, set]
 

Detailed Description

*************************************************************************************\ Approximate Nearest Neighbors * ***************************************************************************************

Member Function Documentation

◆ __fromPtr__()

static ANNIndex OpenCVForUnity.FeaturesModule.ANNIndex.__fromPtr__ ( IntPtr addr)
static

◆ addItems()

void OpenCVForUnity.FeaturesModule.ANNIndex.addItems ( Mat features)

Add feature vectors to index.

Parameters
featuresMatrix containing the feature vectors to index. The size of the matrix is num_features x feature_dimension.

◆ build() [1/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.build ( )

Build the index.

Parameters
treesNumber 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.

◆ build() [2/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.build ( int trees)

Build the index.

Parameters
treesNumber 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() [1/2]

static ANNIndex OpenCVForUnity.FeaturesModule.ANNIndex.create ( int dim)
static

Creates an instance of annoy index class with given parameters.

Parameters
dimThe dimension of the feature vector.
distTypeMetric to calculate the distance between two feature vectors, can be DIST_EUCLIDEAN, DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, or DIST_DOTPRODUCT.

◆ create() [2/2]

static ANNIndex OpenCVForUnity.FeaturesModule.ANNIndex.create ( int dim,
int distType )
static

Creates an instance of annoy index class with given parameters.

Parameters
dimThe dimension of the feature vector.
distTypeMetric to calculate the distance between two feature vectors, can be DIST_EUCLIDEAN, DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, or DIST_DOTPRODUCT.

◆ Dispose()

override void OpenCVForUnity.FeaturesModule.ANNIndex.Dispose ( bool disposing)
protectedvirtual

Reimplemented from OpenCVForUnity.DisposableObject.

◆ getItemNumber()

int OpenCVForUnity.FeaturesModule.ANNIndex.getItemNumber ( )

Return the number of feature vectors in the index.

◆ getNativeObjAddr()

IntPtr OpenCVForUnity.FeaturesModule.ANNIndex.getNativeObjAddr ( )

◆ getTreeNumber()

int OpenCVForUnity.FeaturesModule.ANNIndex.getTreeNumber ( )

Return the number of trees in the index.

◆ knnSearch() [1/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.knnSearch ( Mat query,
Mat indices,
Mat dists,
int knn )

Performs a K-nearest neighbor search for given query vector(s) using the index.

Parameters
queryThe query vector(s).
indicesMatrix that will contain the indices of the K-nearest neighbors found, optional.
distsMatrix that will contain the distances to the K-nearest neighbors found, optional.
knnNumber of nearest neighbors to search for.
search_kThe maximum number of nodes to inspect, which defaults to trees x knn if not provided.

◆ knnSearch() [2/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.knnSearch ( Mat query,
Mat indices,
Mat dists,
int knn,
int search_k )

Performs a K-nearest neighbor search for given query vector(s) using the index.

Parameters
queryThe query vector(s).
indicesMatrix that will contain the indices of the K-nearest neighbors found, optional.
distsMatrix that will contain the distances to the K-nearest neighbors found, optional.
knnNumber of nearest neighbors to search for.
search_kThe maximum number of nodes to inspect, which defaults to trees x knn if not provided.

◆ load() [1/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.load ( string filename)

Loads (mmaps) an index from disk.

Parameters
filenameFilename of the index to be loaded.
prefaultIf prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.

◆ load() [2/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.load ( string filename,
bool prefault )

Loads (mmaps) an index from disk.

Parameters
filenameFilename of the index to be loaded.
prefaultIf prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.

◆ save() [1/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.save ( string filename)

Save the index to disk and loads it. After saving, no more vectors can be added.

Parameters
filenameFilename of the index to be saved.
prefaultIf prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.

◆ save() [2/2]

void OpenCVForUnity.FeaturesModule.ANNIndex.save ( string filename,
bool prefault )

Save the index to disk and loads it. After saving, no more vectors can be added.

Parameters
filenameFilename of the index to be saved.
prefaultIf prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.

◆ setOnDiskBuild()

bool OpenCVForUnity.FeaturesModule.ANNIndex.setOnDiskBuild ( string filename)

Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)

Parameters
filenameFilename of the index to be built.

◆ setSeed()

void OpenCVForUnity.FeaturesModule.ANNIndex.setSeed ( int seed)

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
seedThe given seed of the random number generator. Its value should be within the range of uint32_t.

Member Data Documentation

◆ DIST_ANGULAR

const int OpenCVForUnity.FeaturesModule.ANNIndex.DIST_ANGULAR = 2
static

C++: enum Distance (cv.ANNIndex.Distance)

◆ DIST_DOTPRODUCT

const int OpenCVForUnity.FeaturesModule.ANNIndex.DIST_DOTPRODUCT = 4
static

C++: enum Distance (cv.ANNIndex.Distance)

◆ DIST_EUCLIDEAN

const int OpenCVForUnity.FeaturesModule.ANNIndex.DIST_EUCLIDEAN = 0
static

C++: enum Distance (cv.ANNIndex.Distance)

◆ DIST_HAMMING

const int OpenCVForUnity.FeaturesModule.ANNIndex.DIST_HAMMING = 3
static

C++: enum Distance (cv.ANNIndex.Distance)

◆ DIST_MANHATTAN

const int OpenCVForUnity.FeaturesModule.ANNIndex.DIST_MANHATTAN = 1
static

C++: enum Distance (cv.ANNIndex.Distance)


The documentation for this class was generated from the following file: