Brute Force Matching
Brute force compares every descriptor against every other one, which is slow but exact and the baseline every faster matcher must beat.
Why Does This Exist?
Approximate matchers trade recall for speed, which hides bugs during development. Brute force gives the exact answer: every query against every train vector with the right metric. That makes it the reference for testing faster indexes and the right default for small sets.
For the wider pipeline, read feature matching. Come here for exact knn semantics, cross check, and cost math.
Think of It Like This
Checking every locker
You lost a key with a red tag. Fast search checks likely lockers first and may quit early. Brute force opens every locker in order. Slow, certain, and simple to reason about.
Exact search plays that role for descriptors. The analogy stops at scale: lockers number in hundreds, while descriptor sets reach millions, where opening all doors stops being an option.
How It Actually Works
With query and train descriptors of dimension , cost is distance operations. OpenCV BFMatcher picks NORM_L2 for SIFT and SURF, NORM_HAMMING for ORB, BRIEF, and BRISK. knnMatch(k=2) returns the two best per query for the ratio test. Cross check mode keeps only mutual best pairs.
Worked numbers
Match SIFT queries against train vectors with . That is pairs times multiply adds, about million operations. On CPU that runs in tens of milliseconds, fine for a photo pair. Scale to database vectors and the same query needs million pairs, which pushes you to FLANN. A query with distances and passes ratio at threshold .
Watch Out For
Hamming flag on float descriptors
Passing SIFT floats with NORM_HAMMING compiles yet ranks garbage. Match the norm to the descriptor family, or exact search returns exactly wrong neighbors.
Using it as a production index
Brute force on a million image database means seconds per query and blown memory. Prototype with it, measure recall, then move large search to FLANN or a vector index.
The Quick Version
- Scores all pairs with the matching metric.
- Exact, simple, and the recall baseline.
- Cost grows as , fine for pairs, fatal for huge databases.
- Use knn with for ratio filtering.
- Cross check trims one way false friends.