Skip to content

Commit

Permalink
Merge pull request #410 from roboflow/feature/blur-annotator-docs-update
Browse files Browse the repository at this point in the history
Refactor BlurAnnotator class and update documentation
  • Loading branch information
SkalskiP authored Oct 4, 2023
2 parents 3a52f7b + bfcf646 commit 09c5407
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
25 changes: 25 additions & 0 deletions docs/annotators.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@

</div>

=== "Blur"

```python
>>> import supervision as sv

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

>>> blur_annotator = sv.BlurAnnotator()
>>> annotated_frame = blur_annotator.annotate(
... scene=image.copy(),
... detections=detections
... )
```

<div class="result" markdown>

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

</div>

=== "Trace"

```python
Expand Down Expand Up @@ -172,3 +193,7 @@
## TraceAnnotator

:::supervision.annotators.core.TraceAnnotator

## BlurAnnotator

:::supervision.annotators.core.BlurAnnotator
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- Added [#354](https://github.com/roboflow/supervision/pull/354): [`sv.TraceAnnotator`](https://supervision.roboflow.com/annotators/#supervision.annotators.core.TraceAnnotator) allowing to draw path of moving objects on videos.

- Added [#405](https://github.com/roboflow/supervision/pull/405): [`sv.BlurAnnotator`](https://supervision.roboflow.com/annotators/#supervision.annotators.core.TraceAnnotator) allowing to blur objects on images and videos.

```python
>>> import supervision as sv

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "supervision"
version = "0.15.0rc3"
version = "0.15.0rc4"
description = "A set of easy-to-use utils that will come in handy in any Computer Vision project"
authors = ["Piotr Skalski <[email protected]>"]
maintainers = ["Piotr Skalski <[email protected]>"]
Expand Down
20 changes: 13 additions & 7 deletions supervision/annotators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,13 @@ def annotate(

class BlurAnnotator(BaseAnnotator):
"""
A class for blurring annotator.
A class for blurring regions in an image using provided detections.
"""

def __init__(self, kernel_size: int = 15):
"""
Args:
kernel_size: the size of the average pooling kernel used for blurring
kernel_size (int): The size of the average pooling kernel used for blurring.
"""
self.kernel_size: int = kernel_size

Expand All @@ -583,25 +583,31 @@ def annotate(
detections: Detections,
) -> np.ndarray:
"""
Annotates the given scene with circles based on the provided detections.
Annotates the given scene by blurring regions based on the provided detections.
Args:
scene (np.ndarray): The image where box corners will be drawn.
scene (np.ndarray): The image where blurring will be applied.
detections (Detections): Object detections to annotate.
Returns:
np.ndarray: The annotated image.
Example:
```python
>>> import supervision as sv
>>> image = ...
>>> detections = sv.Detections(...)
>>> blue_annotator = sv.BlurAnnotator()
>>> blur_annotator = sv.BlurAnnotator()
>>> annotated_frame = blur_annotator.annotate(
... scene=image.copy(),
... detections=detections
... )
```
![circle-annotator-example](https://media.roboflow.com/
supervision-annotator-examples/circle-annotator-example.png)
![blur-annotator-example](https://media.roboflow.com/
supervision-annotator-examples/blur-annotator-example-2.png)
"""
for detection_idx in range(len(detections)):
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
Expand Down

0 comments on commit 09c5407

Please sign in to comment.