diff --git a/docs/annotators.md b/docs/annotators.md index 11bdfc17d..2fb1ccee3 100644 --- a/docs/annotators.md +++ b/docs/annotators.md @@ -124,6 +124,27 @@ +=== "Blur" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> blur_annotator = sv.BlurAnnotator() + >>> annotated_frame = blur_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![blur-annotator-example](https://media.roboflow.com/supervision-annotator-examples/blur-annotator-example-2.png){ align=center width="800" } + +
+ === "Trace" ```python @@ -172,3 +193,7 @@ ## TraceAnnotator :::supervision.annotators.core.TraceAnnotator + +## BlurAnnotator + +:::supervision.annotators.core.BlurAnnotator diff --git a/docs/changelog.md b/docs/changelog.md index 98f00178d..b55bc85b8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index b21a92270..0573dac5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] maintainers = ["Piotr Skalski "] diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index f285b4ed0..8edca92b5 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -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 @@ -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)