Table of Contents

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

features InputArray

features – Matrix of type CV _ 32F containing the features(points) to index. The size of the matrix is num _ features x feature _ dimensionality.

params IndexParams

Structure containing the index parameters. The type of index that will be constructed depends on the type of this parameter.

distType FlannDistance

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

features InputArray

Matrix of type CV_32F containing the features(points) to index.

params IndexParams

Structure containing the index parameters.

distType FlannDistance

GetAlgorithm()

The algorithm used by the index.

public FlannAlgorithm GetAlgorithm()

Returns

FlannAlgorithm

GetDistance()

The distance metric used by the index.

public FlannDistance GetDistance()

Returns

FlannDistance

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

queries Mat

The query points, one per row

indices Mat

Indices of the nearest neighbors found

dists Mat

Distances to the nearest neighbors found

knn int

Number of nearest neighbors to search for

params SearchParams

Search 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

queries Mat

The query points, one per row

indices int[]

Indices of the nearest neighbors found

dists float[]

Distances to the nearest neighbors found

knn int

Number of nearest neighbors to search for

params SearchParams

Search 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

queries float[]

The query points, one per row

indices int[]

Indices of the nearest neighbors found

dists float[]

Distances to the nearest neighbors found

knn int

Number of nearest neighbors to search for

params SearchParams

Search parameters

Load(InputArray, string)

Loads a previously saved index from a file.

public bool Load(InputArray features, string filename)

Parameters

features InputArray

The dataset that was used to build the saved index.

filename string

The 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

queries Mat

The query point

indices Mat

Indices of the nearest neighbors found

dists Mat

Distances to the nearest neighbors found

radius double

Number of nearest neighbors to search for

maxResults int
params SearchParams

Search 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

queries Mat

The query point

indices int[]

Indices of the nearest neighbors found

dists float[]

Distances to the nearest neighbors found

radius double

Number of nearest neighbors to search for

maxResults int
params SearchParams

Search 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

queries float[]

The query point

indices int[]

Indices of the nearest neighbors found

dists float[]

Distances to the nearest neighbors found

radius double

Number of nearest neighbors to search for

maxResults int
params SearchParams

Search 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

filename string

The file to save the index to