feat(color): add support for RGBA color representation and methods #1856
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
This pull request introduces an
opacity
parameter to various annotators in thesupervision/annotators/core.py
file, enabling control over the transparency of overlay masks. It also refines the color handling by switching fromas_bgr()
toas_bgra()
to support alpha channels. Additionally, input validation has been added to ensure thescene
parameter is notNone
.Enhancements to Annotators:
Opacity Parameter Added: Introduced an
opacity
parameter (default0.5
) to all annotators, allowing users to control the transparency of overlay masks. This parameter is validated to ensure values are between0
and1
.Overlay Blending: Updated the
annotate
methods to blend overlays with the original scene usingcv2.addWeighted
, incorporating the newopacity
parameter for smooth transparency effects.Improvements to Color Handling:
color.as_bgr()
withcolor.as_bgra()
across all annotators to support alpha channels, which is essential for blending transparency.Input Validation:
scene
parameter is notNone
before proceeding with annotation. AValueError
is raised if this condition is not met.Type of change
Please delete options that are not relevant.
Any specific deployment considerations
For example, documentation changes, usability, usage/costs, secrets, etc.
Docs