Repository navigation
fix(key_points): render three-coordinate points using x and y - #2759
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2759 +/- ##
=======================================
Coverage 94% 94%
=======================================
Files 83 83
Lines 13644 13644
=======================================
+ Hits 12839 12841 +2
+ Misses 805 803 -2 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The localized fix preserves existing two-coordinate behavior and includes focused regression coverage, with no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes rendering of accepted three-coordinate keypoints by using only x/y for pixel positions.
Changes:
- Updates vertex and shared ellipse rendering without modifying input coordinates.
- Adds 16 regression cases covering rendering, visibility, and input preservation.
- Clarifies docstrings and adds an Unreleased changelog entry.
| File | Description |
|---|---|
| tests/key_points/test_annotators.py | Adds regression coverage for all four affected annotators. |
| src/supervision/key_points/annotators.py | Restricts point unpacking to x/y coordinates. |
| docs/changelog.md | Documents the rendering fix. |
Review effort: Balanced
|
Thanks for fixing three-coordinate rendering in the vertex and ellipse annotators. Two related paths still need the same treatment:
This makes (0, 0, z) behave differently from the (0, 0) missing-point sentinel, and a nonfinite depth value suppresses drawing even when x/y are valid. Could you restrict these checks to x/y and add regression coverage for origin sentinels, nonfinite depth, explicit visibility, and input preservation? Not sure why, but your fork does not allow me to push changes to this PR |
|
Updated in c1079fa. The 48 added cases cover float32/float64, finite/NaN/infinite depth, default and explicit visibility, origin sentinels, and input preservation. All 143 annotator tests pass. The full suite has 6,180 passes and seven skips, with the same four Windows fallback-drawing failures as the prior head. All-file pre-commit passes. I also checked the PR setting: maintainer edits are already enabled. I haven't established why GitHub prevented your push. |
* fix(key_points): Render three-coordinate points * fix(key_points): Check x/y for edges and labels --------- Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Description
KeyPointsaccepts(N, K, 3)coordinates, butVertexAnnotatorand the shared covariance-ellipse renderer unpack every point into two values. They raiseValueError: too many values to unpack (expected 2)for this accepted representation.I use the first two coordinate columns for image-space drawing. This fixes vertex, ellipse area, ellipse outline and ellipse halo annotation. Edge and label annotators also use only x/y for missing-point and finiteness checks, so a third coordinate does not change visibility. Existing two-coordinate rendering and covariance handling stay unchanged.
Motivation and Context
The coordinate validator accepts both two and three channels. Image annotators place pixels using x and y, while callers retain the extra coordinate in the original container. Selection already preserves that coordinate depth.
Changes Made
Testing
I ran these checks on Windows, Python 3.13.3, NumPy 2.2.6 and OpenCV 4.12.0, with the source checkout first on
PYTHONPATH:The original 16 cases fail on pristine source. Of the new depth-check cases plus the two updated behavior tests, 32 fail on the prior PR head and 18 already pass. The complete annotator module now has 143 passes.
Current
developsync,pytest -q -p pytest_cov.plugin --cov=supervision: the prior PR head has 6,132 passes; the fix has 6,180 passes. Both have seven skips, 42 warnings and the same four reference drawing failures intests/cv2/test_drawing.py:TestFallbackThickLine::test_line_matches_opencv[clipped-at-canvas-edges]TestFallbackThickLine::test_random_lines_match_opencvTestFallbackEllipse::test_ellipse_matches_opencv[thin-full]TestFallbackEllipse::test_random_ellipses_match_opencvBoth full runs include doctests and report 94% rounded coverage. The blocked-OpenCV integration suite passes on both.
All-file pre-commit, final changed-file hooks and
git diff --checkpass.Added/updated tests, and the full suite passes locally (tests added; four failures reproduce on pristine upstream)
Updated relevant docstrings
Added an Unreleased changelog entry
Additional Notes
The fix preserves input coordinate data, visibility and covariance arrays. I did not run Linux/macOS or the supported-Python matrix locally.
AI assistance disclosure: AI-assisted development tools were used during investigation and implementation. The reported tests were run against the final diff.