Skip to content

feat: Image.ComboFeature joins any supported detector to any descriptor - #286

Merged
petercorke merged 5 commits into
mainfrom
feat/combofeature
Nov 25, 2026
Merged

petercorke merged 5 commits into
mainfrom
feat/combofeature

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Image.ComboFeature was a stub that raised NotImplementedError. It now detects keypoints with one algorithm and describes them with another. There are 8 detectors (FAST, AGAST, GFTT, Harris, SIFT, ORB, BRISK, AKAZE) and 10 descriptors (SIFT, ORB, BRISK, AKAZE, FREAK, BRIEF, DAISY, LATCH, LUCID, BOOST). 73 of the 80 pairs work. The result is a feature set of the descriptor's class, so img.ComboFeature("FAST", "BRIEF") returns a BRIEFFeature.

The docstring has a table of the combinations, a table of what each detector provides (position, scale, orientation, strength), and a References section. The References section has the Paul et al. comparison of detectors and descriptors, then a paper for each of the 14 algorithms, taken from OpenCV's bibliography. The ORB docstring had no reference, so this adds one.

The seven pairs that fail are the AKAZE descriptor with any other detector. It raises a ValueError that says why. SIFT keypoints with the ORB descriptor works by resetting each keypoint's octave to 0, which means ORB ignores their scale. SIFT with ORB gives 81% geometrically consistent matches between eiffel-1.png and eiffel-2.png, as good as the other pairs I tried. LUCID needs a color image.

A feature is a detected keypoint with its descriptor, so str() now names the algorithm once when it provides both ("SIFT features, 2985 points", as in the book) and as "FAST+BRIEF features, 462 points" for a combination. This replaces "SIFTFeature features". A single feature prints "SIFT feature: (u, v), …" instead of "SIFTFeature: (u, v), …".

BaseFeature2D.match now raises a ValueError naming both descriptor kinds when two sets have different kinds, for example BRIEF and DAISY. Before, OpenCV raised an opaque error.

Tests: one for each supported pair, plus tests for options, nfeat, id, the scale and orientation flags, matching, naming, and each error. The full suite and mypy are clean. OpenCV 4.14 and 5.0 behave the same for the pairs that work, from the OpenCV-only probe. The Toolbox test suite ran on OpenCV 5 only, and CI covers OpenCV 4.

AI-assisted: written with Claude Code.

🤖 Generated with Claude Code

petercorke and others added 5 commits November 25, 2026 10:09
Detectors: FAST, AGAST, GFTT, Harris, SIFT, ORB, BRISK, AKAZE.  Descriptors:
SIFT, ORB, BRISK, AKAZE, FREAK, BRIEF, DAISY, LATCH, LUCID, BOOST.  The result is
a feature set of the descriptor's class.  The two pairs OpenCV cannot make
(AKAZE descriptor with another detector, ORB descriptor with SIFT) raise a
ValueError that says why.  BaseFeature2D.match now raises a clear ValueError
for two sets with different kinds of descriptor, instead of an OpenCV error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The octave of a SIFT keypoint is reset to full resolution before ORB reads it,
which makes the pair work in OpenCV 4 and 5.  The docstring has a table of the
8 detectors by 10 descriptors, and its wording and the errors now say keypoints.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nts what it joins

A feature is a detected keypoint with its descriptor, so str() names the algorithm
once when it provides both ("SIFT features, 2985 points", as in the book) and as
"detector+descriptor" for ComboFeature ("FAST+BRIEF features, 462 points").  The
ComboFeature docstring has a table of descriptors by detectors, a table of what each
detector provides, and an example that prints the result.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…scriptors

Fifteen entries: the comparison of detectors and descriptors by Paul et al., then one
paper for each of the 14 algorithms, in alphabetical order.  The references come from
OpenCV's own bibliography.  The ORB docstring had none.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 high

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
ErrorProne 2 high

View in Codacy

🟢 Metrics 54 complexity · 0 duplication

Metric Results
Complexity 54
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 2c58570 into main Nov 25, 2026
33 of 34 checks passed
@petercorke
petercorke deleted the feat/combofeature branch November 25, 2026 02:45
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant