Skip to content

flann_Index

flannclassOpenCV 5.0.0
import { flann_Index } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

A nearest-neighbor search index over feature vectors. Choose index and search parameters for the descriptor type and distance metric.

Constructors and members

static new

Create an owned flann_Index object. Release native handles with using or delete().

new(features: Mat, params: flann_IndexParams, distType: flann_DistanceType): flann_Index;
3 available overloads
new(): flann_Index;
new(features: Mat, params: flann_IndexParams): flann_Index;
new(features: Mat, params: flann_IndexParams, distType: flann_DistanceType): flann_Index;
features

features argument (Mat).

params

params argument (flann_IndexParams).

distType

dist type argument (flann_DistanceType).

Returns

The flann_Index result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

build

Build or replace the search index from rows of feature descriptors and the chosen index parameters.

build(features: Mat, params: flann_IndexParams, distType: number): void;
2 available overloads
build(features: Mat, params: flann_IndexParams): void;
build(features: Mat, params: flann_IndexParams, distType: number): void;
features

features argument (Mat).

params

params argument (flann_IndexParams).

distType

dist type argument (number).

knnSearch

Find up to knn nearest indexed feature vectors for each query row. Write their row indices and distances into the supplied output matrices.

knnSearch(query: Mat, indices: Mat, dists: Mat, knn: number, params: flann_SearchParams): void;
2 available overloads
knnSearch(query: Mat, indices: Mat, dists: Mat, knn: number): void;
knnSearch(query: Mat, indices: Mat, dists: Mat, knn: number, params: flann_SearchParams): void;
query

query argument (Mat).

indices

Output destination, filled by the native operation. indices argument (Mat).

dists

Output destination, filled by the native operation. dists argument (Mat).

knn

knn argument (number).

params

params argument (flann_SearchParams).

radiusSearch

Find indexed feature vectors within the distance radius of the query. Write up to maxResults indices and distances and return the native match count.

radiusSearch(query: Mat, indices: Mat, dists: Mat, radius: number, maxResults: number, params: flann_SearchParams): number;
2 available overloads
radiusSearch(query: Mat, indices: Mat, dists: Mat, radius: number, maxResults: number): number;
radiusSearch(query: Mat, indices: Mat, dists: Mat, radius: number, maxResults: number, params: flann_SearchParams): number;
query

query argument (Mat).

indices

Output destination, filled by the native operation. indices argument (Mat).

dists

Output destination, filled by the native operation. dists argument (Mat).

radius

radius argument (number).

maxResults

max results argument (number).

params

params argument (flann_SearchParams).

Returns

The number result.

save

Save the index structure to a path in this instance's virtual filesystem. Keep the original feature data for loading it again.

save(filename: EmbindString): void;
filename

filename argument (EmbindString).

load

Load a saved index using its original feature matrix. Return whether loading succeeded.

load(features: Mat, filename: EmbindString): boolean;
features

features argument (Mat).

filename

filename argument (EmbindString).

Returns

The boolean result.

release

Release the built search index while keeping this handle available for rebuilding.

release(): void;

getDistance

Return the FLANN distance metric selected when the index was built.

getDistance(): number;
Returns

The number result.

getAlgorithm

Return the FLANN index algorithm selected by the index parameters.

getAlgorithm(): number;
Returns

The number result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.