Skip to content

FLANN nearest neighbours

Organize descriptors so nearest-neighbour queries can avoid an exhaustive scan.

Try it on your image ↓

VISUAL WALKTHROUGHMatching
REFERENCE INPUTOne query, six descriptors

A short binary descriptor makes pairwise differences visible. Orange is the query; violet rows are candidates.

RESULTKeep the nearest candidates

The best match is evidence of similar appearance. Ambiguity filtering and geometric verification remain separate steps.

STEP 03 / 03

Return nearest candidates and their distances.

Illustrative example. The stages explain the method; they are not a live OpenCV execution.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Compute float SIFT descriptors and match them with FLANN. A ratio test removes ambiguous nearest neighbours.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Search larger descriptor collections where approximate neighbours are an acceptable speed tradeoff.

How it works

  1. 01Build an index suited to the descriptor representation.
  2. 02Visit promising parts of the index for each query.
  3. 03Return nearest candidates and their distances.

index build cost + reduced work per query

What to tune

Tree or hash settings govern indexing; search checks trade query cost against recall. Keep the training data valid as required by the index API.

Where it breaks down

Index type, distance and descriptor dtype must agree. Approximation can miss the exact nearest neighbour.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.