Repository navigation
fix(cv2): draw ellipses like OpenCV without OpenCV - #2740
Merged
Merged
Conversation
px12811
force-pushed
the
fix/ellipse-opencv-parity
branch
from
October 16, 2026 09:38
5b3660c to
d14c717
Compare
px12811
force-pushed
the
fix/ellipse-opencv-parity
branch
from
October 16, 2026 09:40
d14c717 to
1f30072
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2740 +/- ##
========================================
Coverage 94% 94%
========================================
Files 83 83
Lines 13491 13612 +121
========================================
+ Hits 12675 12796 +121
Misses 816 816 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Filled fractional-angle arcs can select the wrong rasterization path and break OpenCV pixel parity.
1 open finding
What changed in this PR
Aligns Supervision’s NumPy ellipse fallback with OpenCV’s rasterization without changing the public API.
Changes:
- Ports fixed-point ellipse sampling, strokes, and fills.
- Adds pixel-equality tests for representative and randomized ellipses.
- Documents the correction; circle drawing remains unchanged.
| File | Description |
|---|---|
| tests/cv2/test_drawing.py | Adds OpenCV parity tests. |
| src/supervision/_cv2/_drawing.py | Implements OpenCV-style ellipse rasterization. |
| docs/changelog.md | Records the fallback correction. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Changes: - Integrate the fetched 0.31.0 release metadata and current documentation updates from develop into the ellipse parity branch. - Preserve the PR ellipse note under Unreleased while retaining the target release notes and documentation examples. Impact: - Bring the PR branch up to the verified develop target while preserving the post-release boundary for the ellipse change. - Keep the full target documentation and version updates in the local PR branch history. Verification: - Canonical gates: lint, format, types, tests, and review all passed. - Full tests: 5694 passed, 123 skipped; 93% coverage. - All-files pre-commit passed; no unmerged paths remain and staged diff checks passed. Residual limits: - Prior review limitations remain: independent specialist coverage was not validated, and local OpenCV reference execution was unavailable. --- Co-authored-by: Codex <[email protected]>
Changes: - Add negative-axis tests for both axes and assert failure leaves the image unchanged. - Add a partial filled-arc test for center inclusion and sector boundaries. Impact: - Protects ellipse fallback argument validation and pie-slice fill behavior from regression. Verification: - Targeted drawing tests: 33 passed, 65 skipped, 1 warning. - Canonical gates: lint, format, types, and review passed; full suite 5,697 passed, 123 skipped, 39 warnings. - git diff --check passed. Residual limits: - OpenCV-dependent parity tests skipped locally because OpenCV is unavailable; the historical Codecov comment does not identify its fourth uncovered line. --- Co-authored-by: Codex <[email protected]>
Changes: - Expand seven ellipse and fixed-point rasterizer docstrings with coordinate units, rounding rules, scanline filling, clipping, cap scheduling, parameters, and return contracts. - Add 33 doctest prompts covering arc sampling, degenerate geometry, sector filling, stroke caps, path closure, in-place painting, and fractional-angle fill selection. Impact: - Make the low-level ellipse fallback understandable through executable examples while preserving executable code unchanged. Verification: - Drawing module doctests and drawing tests: 44 passed, 65 skipped. - Full pytest suite with coverage: 5704 passed, 123 skipped, 39 warnings; 94% total coverage. - Repository-wide pre-commit hooks and git diff --check passed. - AST comparison confirmed only docstrings changed. - A temporary-copy mutation restoring the old unrounded fill-path condition failed the new rounding doctest as expected. Residual limits: - OpenCV is not installed, so reference parity checks were skipped; fallback doctests passed. - The full suite emitted fallback, deprecation, plotting, and scenario-specific warnings. --- Co-authored-by: Codex <[email protected]>
Borda
approved these changes
Oct 16, 2026
jorge-asenjo
added a commit
to jorge-asenjo/supervision
that referenced
this pull request
Oct 17, 2026
Merge develop at ffd0ac0, which released 0.31.0 and merged roboflow#2741, roboflow#2740 and roboflow#2743. Only docs/changelog.md conflicted: the CompactMask.area entry now opens the new Unreleased section and the rest matches develop. roboflow#2741 now filters MaskAnnotator ROI crops with CompactMask.area > 0, so that path uses the vectorized area; its tests pass unchanged. Verification: full suite 5,735 passed, 123 skipped, 94% coverage (NumPy fallback); compact mask, mask utility and annotator tests 601 passed with both the fallback and OpenCV 5.0.0; pre-commit passed on the PR files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Borda
added a commit
to Lingikaushikreddy/supervision
that referenced
this pull request
Oct 17, 2026
Changes: - Merge the fetched develop target into the Pascal VOC rounding branch, including the Unreleased notes for PRs roboflow#2740, roboflow#2741, and roboflow#2743. - Integrate OpenCV-compatible ellipse rasterization and its regression coverage. - Integrate mask ROI handling that excludes all-False masks and its tests. - Integrate overflow-safe mean-average-precision box extents and dtype regression tests. Impact: - Keeps the PR branch current so the roboflow#2748 changelog note can be added beside the target's Unreleased entries. - Brings the target's drawing, mask annotation, and metric fixes into the local PR branch. Verification: - The three-tree merge completed automatically without conflicts. - The staged merge diff check passed; all eight staged paths were reviewed. Residual limits: - None known. --- Co-authored-by: Codex <[email protected]>
Borda
added a commit
that referenced
this pull request
Oct 20, 2026
* fix: draw ellipses like OpenCV without OpenCV * fix: round ellipse arc angles before choosing the fill path * test: cover ellipse fallback edge paths * docs: explain ellipse rasterization and add doctests --------- Co-authored-by: jirka <[email protected]> Co-authored-by: Codex <[email protected]>
2 of 3 tasks
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.

Description
The NumPy
ellipsefallback did not match OpenCV. It sampled the ellipse with itsown angle grid, used Pillow's inward-growing strokes for thick outlines, and filled
arcs with Pillow's polygon rule.
cv2.ellipseis reached bysv.EllipseAnnotator,sv.RoundBoxAnnotatorand the key-point ellipse annotators, so a plainpip install supervisiondrew different pixels from the OpenCV backend.This ports OpenCV's
Ellipse2Poly/EllipseExpath:SinTable, stored as a compact float32 constant. It cannot beregenerated exactly from
numpy.sin: 242 of the 451 entries differ in the last bit.ellipse2Polyfixed-point sampling: step snapping, angle and arc normalization,and the 1/65536 rounding plus deduplication done by
EllipseEx.ThickLinefor fixed-point ellipse points, where OpenCV skips the integer pre-clipbecause the line's own shift is 16, reusing the
FillConvexPolyand disc-caphelpers from fix(cv2): draw thick lines and polylines like OpenCV without OpenCV #2727.
FillEdgeCollectionfor filled partial arcs, including the clipped-edge xcorrection that
CollectPolyEdgesapplies.thickness <= 1follows the same OpenCVPolyLine -> Linepath, so thin ellipsesare fixed too. No public API changes.
circleis deliberately untouched; it is beinghandled separately.
Refs #2674.
Minimal reproduction
Testing
pytest tests/cv2/test_drawing.py -q-> 92 passed.pytest tests/cv2 -q --ignore=tests/cv2/test_integration.py-> 522 passed.pytest src tests -q-> 5962 passed, 1 skipped, 10 failed. All ten failures areImportError: metrics extra is requiredintests/metrics/utils/test_aggregate.py;the
metricsextra is not installed in this environment and the failures areunrelated to the changed files.
partial arcs, off-canvas centers and degenerate axes) with 0 differing pixels.
pre-commit run --files src/supervision/_cv2/_drawing.py tests/cv2/test_drawing.py docs/changelog.md: all hooks pass, including ruff, docformatter, mypy and codespell.modules/imgproc/src/drawing.cppin the test environment.New tests cover full and filled ellipses, rotation, partial and past-full-turn arcs,
off-canvas geometry, zero axes, half-degree angle inputs and a seeded random sweep.
UnreleasedAI assistance: Codex helped port OpenCV's fixed-point routines and draft the tests.
I reviewed the implementation and ran the verification above.