Repository navigation
Conversation
Co-authored-by: Codex <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2433 +/- ##
========================================
Coverage 86% 86%
========================================
Files 81 82 +1
Lines 11376 11507 +131
========================================
+ Hits 9837 9951 +114
- Misses 1539 1556 +17 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends supervision._cv2’s fallback backend with Pillow-based implementations of key OpenCV drawing primitives so Supervision drawing utilities can continue to work when cv2 is unavailable, and adds tests to validate behavior and facade bindings.
Changes:
- Added Pillow-based in-place drawing fallbacks for
line,rectangle,circle,ellipse,polylines,fillPoly, anddrawContours. - Wired the new drawing fallbacks into the
_cv2facade when OpenCV is not present. - Added/extended tests for fallback bindings and drawing behavior (with OpenCV as reference where available).
Review scores (n/5):
- Code quality: 4/5
- Testing: 3/5
- Docs: 4/5
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/supervision/_cv2/_drawing.py |
Introduces Pillow-based fallback implementations for drawing APIs. |
src/supervision/_cv2/__init__.py |
Exposes the new fallback drawing functions through the _cv2 facade when cv2 is unavailable. |
tests/cv2/test_drawing.py |
Adds reference comparisons against OpenCV and a subprocess consumer test to validate fallback behavior. |
tests/cv2/test_constants.py |
Extends facade binding checks to include the new drawing fallbacks. |
[resolve group] PR #2433 — items 3 --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: OpenAI Codex <[email protected]>
[resolve group] PR #2433 — items 2 --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Merged
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.
This pull request introduces comprehensive Pillow-based fallback implementations for several OpenCV drawing functions in the
supervision._cv2module. These fallbacks allow drawing operations such as lines, rectangles, circles, ellipses, polygons, and contours to work even when OpenCV is not available, ensuring broader compatibility and robustness. The PR also adds extensive tests to verify the correctness and compatibility of these fallbacks with OpenCV's behavior.New Pillow-based drawing fallbacks:
_circle,_draw_contours,_ellipse,_fill_poly,_line,_polylines, and_rectangleimplementations insrc/supervision/_cv2/_drawing.py, providing in-place drawing operations using Pillow that closely mimic OpenCV's API and conventions.Integration into the OpenCV facade:
src/supervision/_cv2/__init__.pyto expose the new fallback drawing functions in the module's public API, replacing previous_unavailablestubs. [1] [2] [3]Testing and validation:
tests/cv2/test_drawing.pywith comprehensive tests for all new fallback drawing functions, ensuring their correctness and compatibility with OpenCV's reference implementation.tests/cv2/test_constants.pyto verify that the OpenCV facade correctly binds the new fallback drawing operations when OpenCV is not present.These changes significantly improve the reliability and portability of the drawing utilities in the absence of OpenCV, and ensure their correctness through robust testing.