diff --git a/supervision/__init__.py b/supervision/__init__.py index eb04df36..6f7caf95 100644 --- a/supervision/__init__.py +++ b/supervision/__init__.py @@ -2,15 +2,16 @@ __version__ = "0.11.1" from supervision.annotators.composable import DetectionAnnotator, SegmentationAnnotator from supervision.annotators.core import ( - BoxAnnotator, + BoxLineAnnotator, BoxMaskAnnotator, - CorneredBoxAnnotator, + BoxCornerAnnotator, EllipseAnnotator, LabelAnnotator, MaskAnnotator, - PillowLabelAnnotator, + LabelAdvancedAnnotator, build_label_formatter, ) +from supervision.detection.annotate import BoxAnnotator, MaskAnnotator from supervision.classification.core import Classifications from supervision.dataset.core import ( BaseDataset, diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 1231bf07..78be2be5 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -15,8 +15,12 @@ class BaseAnnotator(ABC): def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray: pass + @staticmethod + def resolve_annotation_color(color: Union[Color, ColorPalette], by_track: bool, detections: Detections) -> Color: + pass -class BoxAnnotator(BaseAnnotator): + +class BoxLineAnnotator(BaseAnnotator): """ Basic bounding box annotation class """ @@ -41,18 +45,17 @@ class BoxAnnotator(BaseAnnotator): scene (np.ndarray): The image on which the bounding boxes will be drawn detections (Detections): The detections for which the bounding boxes will be drawn Returns: - np.ndarray: The image with the bounding boxes drawn on it + np.ndarray: The image with the bounding boxes drawn on it. Example: ```python >>> import supervision as sv - >>> classes = ['person', ...] >>> image = ... >>> detections = sv.Detections(...) - >>> box_annotator = sv.BoxAnnotator() - >>> annotated_frame = box_annotator.annotate( + >>> box_line_annotator = sv.BoxLineAnnotator() + >>> annotated_frame = box_line_annotator.annotate( ... scene=image.copy(), ... detections=detections ... ) @@ -405,7 +408,7 @@ def default_label_formatter(detections: Detections) -> List[str]: return [str(class_id) for class_id in detections.class_id] -class PillowLabelAnnotator(BaseAnnotator): +class LabelAdvancedAnnotator(BaseAnnotator): def __init__( self, color: Union[Color, ColorPalette] = ColorPalette.default(), @@ -448,7 +451,7 @@ class PillowLabelAnnotator(BaseAnnotator): >>> image = ... >>> detections = sv.Detections(...) - >>> pil_label_annotator = sv.PillowLabelAnnotator() + >>> pil_label_annotator = sv.LabelAdvancedAnnotator() >>> labels = [ ... f"{classes[class_id]} {confidence:0.2f}" ... for _, _, confidence, class_id, _ @@ -521,7 +524,7 @@ class PillowLabelAnnotator(BaseAnnotator): return scene -class CorneredBoxAnnotator(BaseAnnotator): +class BoxCornerAnnotator(BaseAnnotator): def __init__( self, color: Union[Color, ColorPalette] = ColorPalette.default(), diff --git a/test/detection/test_core.py b/test/detection/test_core.py index e03dd1b7..01e6b9f8 100644 --- a/test/detection/test_core.py +++ b/test/detection/test_core.py @@ -2,7 +2,8 @@ from contextlib import ExitStack as DoesNotRaise import pytest -from supervision import Detections, Position +from supervision.detection.core import Detections +from supervision.geometry.core import Position from typing import Optional, Union, List