Skip to content

feat: add Image.SURF and SURFFeature - #201

Merged
petercorke merged 1 commit into
mainfrom
feat/surf-features
Nov 21, 2026
Merged

petercorke merged 1 commit into
mainfrom
feat/surf-features

Conversation

@petercorke

@petercorke petercorke commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds Image.SURF() and SURFFeature, mirroring SIFT (scale and orientation on), and lists SURFFeature in the support-classes docs. Closes #113 (Image.SURF() documented but not implemented).

SURF is patented, so it is left out of standard OpenCV builds, including the opencv-contrib-python wheels on PyPI. Rather than fail with an obscure OpenCV error:

  • if the contrib modules are installed but SURF is excluded, SURF() raises a RuntimeError that says to use a build with the contrib modules and OPENCV_ENABLE_NONFREE=ON, or another detector such as SIFT, ORB, BRISK or AKAZE;
  • if the contrib modules are missing, the existing error says to install opencv-contrib-python.

Also changes _image2feature to resolve the BRISK and AKAZE detectors only when they are used. They were resolved eagerly on every call, so on OpenCV 5 without the contrib modules every detector, including SIFT, would have failed.

The docstring example is a code-block, not a runblock, because SURF cannot run on the standard wheels.

Testing

mypy passes with zero errors and the 24 tests in tests/test_image_point_features.py pass, run on OpenCV 5.0 only. The real SURF test runs only if the OpenCV in use has SURF, which it does not here, so real SURF has never been run. The other three tests are mocked: the non-free error message, the missing contrib modules, and the wiring (SIFT standing in for the SURF detector). Not run: OpenCV 4, the docs build, and the full suite (left to CI).

This change was written with AI assistance (Claude Code) and the diff has been reviewed by the maintainer.

🤖 Generated with Claude Code

SURF is patented and absent from standard OpenCV builds, so SURF() raises a
clear error that says to use a build with the contrib modules and
OPENCV_ENABLE_NONFREE, or another detector, and the contrib-missing error
still says to install opencv-contrib-python. BRISK and AKAZE are now resolved
only when used, so a detector missing from OpenCV 5 without contrib no longer
breaks every other feature detector.

Closes #113

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

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 7 complexity · 0 duplication

Metric Results
Complexity 7
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 09042f4 into main Nov 21, 2026
35 checks passed
@petercorke
petercorke deleted the feat/surf-features branch November 21, 2026 20:22
@github-actions github-actions Bot mentioned this pull request Nov 21, 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.

Image.SURF() is documented but not implemented (and non-free in pip OpenCV builds)

1 participant