Skip to content

Commit

Permalink
Refactor ColorAnnotator default color and enhance documentation
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
SkalskiP committed Dec 5, 2023
1 parent 628914d commit 61a29bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions docs/annotators.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,27 @@

</div>

=== "Color"

```python
>>> import supervision as sv

>>> image = ...
>>> detections = sv.Detections(...)

>>> color_annotator = sv.ColorAnnotator()
>>> annotated_frame = color_annotator.annotate(
... scene=image.copy(),
... detections=detections
... )
```

<div class="result" markdown>

![color-annotator-example](https://media.roboflow.com/supervision-annotator-examples/color-annotator-example-purple.png){ align=center width="800" }

</div>

=== "Trace"

```python
Expand Down Expand Up @@ -337,6 +358,10 @@

:::supervision.annotators.core.BlurAnnotator

## ColorAnnotator

:::supervision.annotators.core.ColorAnnotator

## TraceAnnotator

:::supervision.annotators.core.TraceAnnotator
Expand Down
6 changes: 3 additions & 3 deletions supervision/annotators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 61a29bb

Please sign in to comment.