Class Index
- Namespace
- OpenCvSharp.Flann
- Assembly
- OpenCvSharp.dll
The FLANN nearest neighbor index class.
public class Index : CvObject, IDisposable
- Inheritance
-
Index
- Implements
- Inherited Members
Constructors
Index()
Constructs an empty index. Call Build(InputArray, IndexParams, FlannDistance) or Load(InputArray, string) before searching.
public Index()
Index(InputArray, IndexParams, FlannDistance)
Constructs a nearest neighbor search index for a given dataset.
public Index(InputArray features, IndexParams @params, FlannDistance distType = FlannDistance.Euclidean)
Parameters
featuresInputArrayfeatures – Matrix of type CV _ 32F containing the features(points) to index. The size of the matrix is num _ features x feature _ dimensionality.
paramsIndexParamsStructure containing the index parameters. The type of index that will be constructed depends on the type of this parameter.
distTypeFlannDistance
Methods
Build(InputArray, IndexParams, FlannDistance)
Builds the index using the specified dataset and parameters.
public void Build(InputArray features, IndexParams @params, FlannDistance distType = FlannDistance.Euclidean)
Parameters
featuresInputArrayMatrix of type CV_32F containing the features(points) to index.
paramsIndexParamsStructure containing the index parameters.
distTypeFlannDistance
GetAlgorithm()
The algorithm used by the index.
public FlannAlgorithm GetAlgorithm()
Returns
GetDistance()
The distance metric used by the index.
public FlannDistance GetDistance()
Returns
KnnSearch(Mat, Mat, Mat, int, SearchParams)
Performs a K-nearest neighbor search for multiple query points.
public void KnnSearch(Mat queries, Mat indices, Mat dists, int knn, SearchParams @params)
Parameters
queriesMatThe query points, one per row
indicesMatIndices of the nearest neighbors found
distsMatDistances to the nearest neighbors found
knnintNumber of nearest neighbors to search for
paramsSearchParamsSearch parameters
KnnSearch(Mat, out int[], out float[], int, SearchParams)
Performs a K-nearest neighbor search for multiple query points.
public void KnnSearch(Mat queries, out int[] indices, out float[] dists, int knn, SearchParams @params)
Parameters
queriesMatThe query points, one per row
indicesint[]Indices of the nearest neighbors found
distsfloat[]Distances to the nearest neighbors found
knnintNumber of nearest neighbors to search for
paramsSearchParamsSearch parameters
KnnSearch(float[], out int[], out float[], int, SearchParams)
Performs a K-nearest neighbor search for multiple query points.
public void KnnSearch(float[] queries, out int[] indices, out float[] dists, int knn, SearchParams @params)
Parameters
queriesfloat[]The query points, one per row
indicesint[]Indices of the nearest neighbors found
distsfloat[]Distances to the nearest neighbors found
knnintNumber of nearest neighbors to search for
paramsSearchParamsSearch parameters
Load(InputArray, string)
Loads a previously saved index from a file.
public bool Load(InputArray features, string filename)
Parameters
featuresInputArrayThe dataset that was used to build the saved index.
filenamestringThe file to load the index from.
Returns
- bool
true if the load succeeded.
RadiusSearch(Mat, Mat, Mat, double, int, SearchParams)
Performs a radius nearest neighbor search for a given query point.
public void RadiusSearch(Mat queries, Mat indices, Mat dists, double radius, int maxResults, SearchParams @params)
Parameters
queriesMatThe query point
indicesMatIndices of the nearest neighbors found
distsMatDistances to the nearest neighbors found
radiusdoubleNumber of nearest neighbors to search for
maxResultsintparamsSearchParamsSearch parameters
RadiusSearch(Mat, int[], float[], double, int, SearchParams)
Performs a radius nearest neighbor search for a given query point.
public void RadiusSearch(Mat queries, int[] indices, float[] dists, double radius, int maxResults, SearchParams @params)
Parameters
queriesMatThe query point
indicesint[]Indices of the nearest neighbors found
distsfloat[]Distances to the nearest neighbors found
radiusdoubleNumber of nearest neighbors to search for
maxResultsintparamsSearchParamsSearch parameters
RadiusSearch(float[], int[], float[], double, int, SearchParams)
Performs a radius nearest neighbor search for a given query point.
public void RadiusSearch(float[] queries, int[] indices, float[] dists, double radius, int maxResults, SearchParams @params)
Parameters
queriesfloat[]The query point
indicesint[]Indices of the nearest neighbors found
distsfloat[]Distances to the nearest neighbors found
radiusdoubleNumber of nearest neighbors to search for
maxResultsintparamsSearchParamsSearch parameters
Release()
Releases the inner search structures. Reserved for future use.
public void Release()
Save(string)
Saves the index to a file.
public void Save(string filename)
Parameters
filenamestringThe file to save the index to