fix: estimatePose misaligned ids and corners when other markers are in view - #116
Merged
Merged
Conversation
The ID filter zipped the already-filtered corners list against the original, unfiltered ids, so as soon as a marker not on the board was detected before one that was, the two lists got out of step (OpenCV then failed in aruco_board.cpp with a corners/ids length mismatch). Filter each marker's corners and id together in a single pass. Also raise the documented ValueError when no marker on this board is detected, instead of a TypeError (ids is None) or a raw cv2.error. Adds the first test coverage of FiducialCollection.estimatePose(): the existing test_estimatePose exercises Image.fiducial() only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 9 |
| Duplication | 2 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #52.
FiducialCollection.estimatePose()filtered markers by board ID with:The second
zippairs the already-filtered corners with the original ids. As soon as a marker not on this board was detected before one that is (exactly the multi-board case the docstring advertises), the lists went out of step. Now each marker's corners and id are filtered together in one pass.Also raises the documented
ValueErrorwhen no marker on this board is detected; previously that case gave aTypeError(ids is None) or a rawcv2.error.Tests
The existing
test_estimatePoseonly exercisesImage.fiducial();FiducialCollection.estimatePose()had no coverage. Two new tests:test_board_estimatePose_ignores_other_markers: a 2x2 board plus two larger extraneous markers (OpenCV returns detections largest-first, so these arrive before the board's markers, which is the order that exposes the bug). Asserts only the board's ids are reported, the pose and RMSE equal the board-only reference, and each id keeps its own corners.test_board_estimatePose_no_board_markers:ValueErrorfor a scene containing only other markers, and for a blank scene.Verification
Clean isolated venvs, Python 3.12, OpenCV 4.14.0 and 5.0.0:
cv2.errorfromaruco_board.cpp) and pass after, on both versions.tests/test_image_fiducials.py: 9 passed on both.Note: I could only provoke a crash, not a silent misalignment, because OpenCV rejects the length mismatch. The per-id corner comparison in the test would also catch a silent one.
Checklist
🤖 Generated with Claude Code