Skip to content

test: raise coverage of ImagePointFeatures from 54% to 97% - #221

Merged
petercorke merged 1 commit into
mainfrom
test/image-coverage-point-features
Nov 22, 2026
Merged

petercorke merged 1 commit into
mainfrom
test/image-coverage-point-features

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Second of three changes to lift coverage of the Image*.py modules. ImagePointFeatures.py goes from 54% to 97%. It is the largest of the modules (608 statements), and held nearly 40% of the missed lines.

The tests are in a new file, tests/test_image_point_features_extra.py. Most build the feature objects by hand from cv2.KeyPoint values with known coordinates, scale, angle, strength and descriptors, so the expected answers are exact and do not depend on the detector or the OpenCV version. They cover indexing, the properties, printing, adding, gridify, subset, sort, filter, distance, match (with each metric, crosscheck, top and sort), support, the drawing methods, and the whole of FeatureMatch (indexing, inliers, by_id1 and by_id2, printing, plotting, estimate). The detector tests use a blurred checkerboard whose corners are at multiples of 40 pixels: Harris must find all 25 of them to within 2 pixels, and SIFT, ORB, BRISK and AKAZE must return keypoints and descriptors for it. The id and nfeat options are tested too.

Five bugs found while writing these are recorded as strict xfail tests, not fixed here, so whoever fixes one has to remove its marker:

  1. distance() raises IndexError unless both feature sets are the same size.
  2. filter(minstrength=x) keeps the features weaker than x; minscale is the right way round.
  3. The descriptor property raises TypeError when there are no descriptors.
  4. str() of a FeatureMatch with a single match raises IndexError.
  5. draw(..., filled=True, hand=True) draws the hand vertically whatever the orientation.

Not covered: ComboFeature, which is marked work in progress (it fails on OpenCV 5 with AttributeError, since AgastFeatureDetector_create is gone), and the SURF paths, which need a non-free OpenCV build.

Testing

pytest tests: 1745 passed, 33 skipped, 6 xfailed. black, ruff check and mypy report no issues. Nothing is mocked. Not run: CI on Windows or OpenCV 4 (CI will).

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

🤖 Generated with Claude Code

The tests build feature objects by hand from cv2.KeyPoint values with known
coordinates, scale, angle, strength and descriptors, so the answers are exact
whichever detector or OpenCV version is installed. The detector tests use a
blurred checkerboard whose corners are at multiples of 40 pixels.

Five bugs are recorded as strict xfail tests: distance() with feature sets of
different sizes, filter(minstrength=...) keeping the weaker features,
descriptor with no descriptors, str() of a one-match FeatureMatch, and the
direction of the hand drawn by draw().

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

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 4 high

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

Results:
4 new issues

Category Results
ErrorProne 4 high

View in Codacy

🟢 Metrics 128 complexity · 0 duplication

Metric Results
Complexity 128
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 52a581b into main Nov 22, 2026
31 of 32 checks passed
@petercorke
petercorke deleted the test/image-coverage-point-features branch November 22, 2026 09:08
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