HBST (Hamming Binary Search Tree)

HBST (Schlegel & Grisetti, 2018) is a binary search tree for binary descriptors (ORB, BRIEF, BRISK, FREAK) that answers approximate nearest-neighbour queries in Hamming space at logarithmic cost, and — crucially for SLAM — supports incremental insertion while searching. It was proposed as a lightweight, vocabulary-free alternative to bag-of-visual-words (DBoW2) and FLANN-LSH for loop closure detection: instead of quantizing descriptors against a pre-trained vocabulary, it indexes the raw descriptors of the trajectory as they arrive.

How the tree is built

A binary descriptor is a fixed-length bit string d{0,1}D\mathbf{d} \in \{0,1\}^D (e.g., D=256D = 256 for ORB) compared with the Hamming distance — the number of differing bits, computed with XOR + popcount.

The splitting bit is chosen for balance: compute the mean value dˉk\bar{d}_k of every candidate bit over the descriptors in the leaf and pick the bit whose mean is closest to 0.50.5 — the bit that partitions the set most evenly. A balanced tree over NN descriptors then has depth around log2N\log_2 N, and each query touches one root-to-leaf path.

Search — and why it is approximate

A query descriptor q\mathbf{q} descends the tree by reading its own bits at each node’s index (hh bit tests for depth hh), lands in a single leaf, and is matched exhaustively by Hamming distance against only that leaf’s descriptors (accepting matches below a distance threshold τ\tau). Total cost is O(logN+L)O(\log N + L) for leaf size LL, versus O(N)O(N) for brute force.

The price is approximation: a true match whose descriptor differs from the query in one of the bits used for splitting is routed to a different leaf and missed. The probability of this grows with tree depth and with descriptor noise. HBST accepts this because place recognition does not need every match — it needs enough consistent matches to vote for the right keyframe, and geometric verification cleans up afterwards.

Incremental search-and-insert

The operation that makes HBST fit SLAM’s online setting: for each new image, its descriptors are dropped down the tree once, and in the same pass the tree (1) reports matches against everything indexed so far and (2) inserts the new descriptors (splitting leaves that overflow). The database grows with the trajectory with no offline training phase, no vocabulary file, and no periodic rebuild. Matches are aggregated per past image — each matched descriptor casts a vote for the keyframe it belongs to — and keyframes with high vote counts become loop closure candidates, which are then verified geometrically (e.g., essential matrix or PnP within RANSAC).

Summarizing the costs for a database of NN descriptors with maximum leaf size LL:

Where it sits among its alternatives

Why it matters for SLAM

Loop closure detection must query “have I seen this before?” against an ever-growing database, every few frames, within a real-time budget. HBST is a clean, self-contained answer for feature-based systems that already compute binary descriptors: no vocabulary shipping (a DBoW2 ORB vocabulary is a large binary artifact), image-level and keypoint-level correspondences from a single structure, and logarithmic growth in query time along the trajectory. It is also an instructive case study in the accuracy-speed trade-offs of indexing Hamming space — comparing it with LSH and BoW sharpens your understanding of all three.