Skip to content

fix: FeatureMatch.estimate keeps only an inlier mask as the inlier status - #272

Merged
petercorke merged 2 commits into
mainfrom
bug/featurematch-estimate-inliers
Nov 23, 2026
Merged

petercorke merged 2 commits into
mainfrom
bug/featurematch-estimate-inliers

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Fixes FeatureMatch.estimate treating the last value that the estimator returns as the inlier mask, whatever it is. Found while typing ImagePointFeatures.py (Issue 60); a follow-up to PR 265 (merged).

CentralCamera.points2F and points2H return an inlier mask only for the robust methods, "ransac" and "lmeds". With any other method the last value is the residual, or, with residual=False, the estimate itself. I ran estimate on ORB matches of the two Eiffel images:

call returned before inlier status before
points2F, method="8p" (F,), the residual is lost the residual, a float
points2F, method="8p", residual=False (), the estimate is lost the 3x3 matrix F
points2H, method="leastsquares" (H,), the residual is lost the residual, a float

matches.inliers then raised a confusing ValueError about the index type.

The change. The last value is kept as the inlier status only if it is a bool array with one element per match. In that case it is not returned, as before, so "ransac" and "lmeds" behave as they did. Otherwise everything the estimator returns is returned, and the inlier status is cleared, so a mask from an earlier call does not stay attached to a new estimate. A single value that is not a tuple or list (an array on its own) is accepted. .. versionchanged:: 2.5.0 is added; the :return: text now says "if there is one".

Calls that worked still work: the book calls (points2F/points2H with "ransac") return the same values and keep the same inliers.

Tests: 15 new in tests/test_image_point_features_extra.py: the mask kept and not returned; a list, a wrong-length array and an integer array refused as masks; no mask returns everything; a single array result; a later call clearing an old mask; the options passed on; and the six real estimator calls above on real matches. 10 of them fail on the old code. mypy reports no issues and the full suite passes (2292 passed, 30 skipped).

AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.

🤖 Generated with Claude Code

…atus

It took the last value func returned as the inlier mask. Only the robust
methods (ransac, lmeds) return one, so with method='8p' or 'leastsquares' the
residual became the inlier status and was dropped from the result, and with
residual=False the estimate itself was. Keep the last value only if it is a
bool array with one element per match; otherwise return everything and clear
the inlier status.

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 0 complexity · 0 duplication

Metric Results
Complexity 0
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 6055f56 into main Nov 23, 2026
33 checks passed
@petercorke
petercorke deleted the bug/featurematch-estimate-inliers branch November 23, 2026 22:39
@github-actions github-actions Bot mentioned this pull request Nov 23, 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