Skip to content

fix: gridify keeps the descriptors and flags, and copes with features at the far edge - #277

Merged
petercorke merged 1 commit into
mainfrom
bug/gridify-drops-descriptors
Nov 24, 2026
Merged

petercorke merged 1 commit into
mainfrom
bug/gridify-drops-descriptors

Conversation

@petercorke

Copy link
Copy Markdown
Owner

gridify built its result with self.__class__(keep). That put whole feature objects into _kp, left the descriptors as None and lost the scale, orientation and strength flags. So a gridded ORB set of 500 features gave 45 "keypoints" that were really ORBFeature objects, and it could not be matched.

It also divided by the integer cell size (width // nw). When the image size is not a multiple of the number of cells, a feature in the last few pixels fell in a cell past the grid and raised IndexError. For a 1280-pixel-wide image with 13 cells, any feature at x of 1274 or more would fail.

Now gridify collects the indices of the kept features and returns self[keep], the same path slicing uses, so keypoints, descriptors and flags survive. The last cell takes the leftover pixels.

Tests: the result has real keypoints, descriptors and flags, each kept feature has its own descriptor row, the result can be matched, no cell holds more than nfeat, and features at the far edges don't raise. Five of the six new tests fail on the old code. I ran the full suite and mypy, and both are clean.

AI-assisted: written with Claude Code.

🤖 Generated with Claude Code

… at the far edge

gridify built its result with self.__class__(keep), which put whole feature
objects into _kp, left the descriptors as None and lost the scale, orientation
and strength flags.  It also divided by the integer cell size, so when the image
size was not a multiple of the number of cells a feature in the last few pixels
fell in a cell past the grid and raised IndexError.  It now collects indices and
returns self[keep], and the last cell takes the leftover pixels.

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

Metric Results
Complexity 9
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 0f404f4 into main Nov 24, 2026
33 of 34 checks passed
@petercorke
petercorke deleted the bug/gridify-drops-descriptors branch November 24, 2026 04:31
@github-actions github-actions Bot mentioned this pull request Nov 24, 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