Merge pull request #410 from roboflow/feature/blur-annotator-docs-update

Refactor BlurAnnotator class and update documentation
This commit is contained in:
Piotr Skalski 2023-10-04 23:54:48 +02:00 committed by GitHub
commit 09c5407347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 8 deletions

View File

@ -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
@ -172,3 +193,7 @@
## TraceAnnotator
:::supervision.annotators.core.TraceAnnotator
## BlurAnnotator
:::supervision.annotators.core.BlurAnnotator

View File

@ -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

View File

@ -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 <piotr.skalski92@gmail.com>"]
maintainers = ["Piotr Skalski <piotr.skalski92@gmail.com>"]

View File

@ -567,13 +567,13 @@ class LabelAnnotator:
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
@ -583,25 +583,31 @@ class BlurAnnotator(BaseAnnotator):
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)