From 61a29bb99476e1d67cbe860feb2d819ea581d736 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Tue, 5 Dec 2023 11:22:03 +0100 Subject: [PATCH] Refactor ColorAnnotator default color and enhance documentation Changed the default color for ColorAnnotator from RGB(0,0,0) to the black color constant. Also improved the clarity of initialisation comment (color used for region painting, not replacing). A wrong variable name 'blur_annotator' is also rectified to 'color_annotator'. --- docs/annotators.md | 25 +++++++++++++++++++++++++ supervision/annotators/core.py | 6 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/annotators.md b/docs/annotators.md index 7dd8124d6..67e3939f2 100644 --- a/docs/annotators.md +++ b/docs/annotators.md @@ -229,6 +229,27 @@ +=== "Color" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> color_annotator = sv.ColorAnnotator() + >>> annotated_frame = color_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![color-annotator-example](https://media.roboflow.com/supervision-annotator-examples/color-annotator-example-purple.png){ align=center width="800" } + +
+ === "Trace" ```python @@ -337,6 +358,10 @@ :::supervision.annotators.core.BlurAnnotator +## ColorAnnotator + +:::supervision.annotators.core.ColorAnnotator + ## TraceAnnotator :::supervision.annotators.core.TraceAnnotator diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index e48ae3875..331a62834 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1205,10 +1205,10 @@ class ColorAnnotator(BaseAnnotator): using provided detections. """ - def __init__(self, color: Color = Color(r=0, g=0, b=0)): + def __init__(self, color: Color = Color.black()): """ Args: - color (Color): The color to replace the regions with. + color (Color): The color to paint the regions with. """ self.color: Color = color @@ -1235,7 +1235,7 @@ def annotate( >>> image = ... >>> detections = sv.Detections(...) - >>> blur_annotator = sv.ColorAnnotator() + >>> color_annotator = sv.ColorAnnotator() >>> annotated_frame = color_annotator.annotate( ... scene=image.copy(), ... detections=detections