|
9 | 9 | from PIL import Image, ImageDraw, ImageFont |
10 | 10 | from scipy.interpolate import splev, splprep |
11 | 11 |
|
12 | | -from supervision.annotators.base import BaseAnnotator, ImageType |
| 12 | +from supervision.annotators.base import BaseAnnotator |
13 | 13 | from supervision.annotators.utils import ( |
14 | 14 | PENDING_TRACK_ID, |
15 | 15 | ColorLookup, |
|
29 | 29 | polygon_to_mask, |
30 | 30 | xyxy_to_polygons, |
31 | 31 | ) |
| 32 | +from supervision.draw.base import ImageType |
32 | 33 | from supervision.draw.color import Color, ColorPalette |
33 | 34 | from supervision.draw.utils import draw_polygon, draw_rounded_rectangle, draw_text |
34 | 35 | from supervision.geometry.core import Point, Position, Rect |
35 | 36 | from supervision.utils.conversion import ( |
36 | | - ensure_cv2_image_for_annotation, |
37 | | - ensure_pil_image_for_annotation, |
| 37 | + ensure_cv2_image_for_class_method, |
| 38 | + ensure_pil_image_for_class_method, |
38 | 39 | ) |
39 | 40 | from supervision.utils.image import ( |
40 | 41 | crop_image, |
@@ -177,7 +178,7 @@ def __init__( |
177 | 178 | self.thickness: int = thickness |
178 | 179 | self.color_lookup: ColorLookup = color_lookup |
179 | 180 |
|
180 | | - @ensure_cv2_image_for_annotation |
| 181 | + @ensure_cv2_image_for_class_method |
181 | 182 | def annotate( |
182 | 183 | self, |
183 | 184 | scene: ImageType, |
@@ -260,7 +261,7 @@ def __init__( |
260 | 261 | self.thickness: int = thickness |
261 | 262 | self.color_lookup: ColorLookup = color_lookup |
262 | 263 |
|
263 | | - @ensure_cv2_image_for_annotation |
| 264 | + @ensure_cv2_image_for_class_method |
264 | 265 | def annotate( |
265 | 266 | self, |
266 | 267 | scene: ImageType, |
@@ -349,7 +350,7 @@ def __init__( |
349 | 350 | self.opacity = opacity |
350 | 351 | self.color_lookup: ColorLookup = color_lookup |
351 | 352 |
|
352 | | - @ensure_cv2_image_for_annotation |
| 353 | + @ensure_cv2_image_for_class_method |
353 | 354 | def annotate( |
354 | 355 | self, |
355 | 356 | scene: ImageType, |
@@ -439,7 +440,7 @@ def __init__( |
439 | 440 | self.thickness: int = thickness |
440 | 441 | self.color_lookup: ColorLookup = color_lookup |
441 | 442 |
|
442 | | - @ensure_cv2_image_for_annotation |
| 443 | + @ensure_cv2_image_for_class_method |
443 | 444 | def annotate( |
444 | 445 | self, |
445 | 446 | scene: ImageType, |
@@ -526,7 +527,7 @@ def __init__( |
526 | 527 | self.color_lookup: ColorLookup = color_lookup |
527 | 528 | self.opacity = opacity |
528 | 529 |
|
529 | | - @ensure_cv2_image_for_annotation |
| 530 | + @ensure_cv2_image_for_class_method |
530 | 531 | def annotate( |
531 | 532 | self, |
532 | 533 | scene: ImageType, |
@@ -622,7 +623,7 @@ def __init__( |
622 | 623 | self.color_lookup: ColorLookup = color_lookup |
623 | 624 | self.kernel_size: int = kernel_size |
624 | 625 |
|
625 | | - @ensure_cv2_image_for_annotation |
| 626 | + @ensure_cv2_image_for_class_method |
626 | 627 | def annotate( |
627 | 628 | self, |
628 | 629 | scene: ImageType, |
@@ -722,7 +723,7 @@ def __init__( |
722 | 723 | self.end_angle: int = end_angle |
723 | 724 | self.color_lookup: ColorLookup = color_lookup |
724 | 725 |
|
725 | | - @ensure_cv2_image_for_annotation |
| 726 | + @ensure_cv2_image_for_class_method |
726 | 727 | def annotate( |
727 | 728 | self, |
728 | 729 | scene: ImageType, |
@@ -814,7 +815,7 @@ def __init__( |
814 | 815 | self.corner_length: int = corner_length |
815 | 816 | self.color_lookup: ColorLookup = color_lookup |
816 | 817 |
|
817 | | - @ensure_cv2_image_for_annotation |
| 818 | + @ensure_cv2_image_for_class_method |
818 | 819 | def annotate( |
819 | 820 | self, |
820 | 821 | scene: ImageType, |
@@ -903,7 +904,7 @@ def __init__( |
903 | 904 | self.thickness: int = thickness |
904 | 905 | self.color_lookup: ColorLookup = color_lookup |
905 | 906 |
|
906 | | - @ensure_cv2_image_for_annotation |
| 907 | + @ensure_cv2_image_for_class_method |
907 | 908 | def annotate( |
908 | 909 | self, |
909 | 910 | scene: ImageType, |
@@ -1002,7 +1003,7 @@ def __init__( |
1002 | 1003 | self.outline_thickness = outline_thickness |
1003 | 1004 | self.outline_color: Color | ColorPalette = outline_color |
1004 | 1005 |
|
1005 | | - @ensure_cv2_image_for_annotation |
| 1006 | + @ensure_cv2_image_for_class_method |
1006 | 1007 | def annotate( |
1007 | 1008 | self, |
1008 | 1009 | scene: ImageType, |
@@ -1128,7 +1129,7 @@ def __init__( |
1128 | 1129 | max_line_length=max_line_length, |
1129 | 1130 | ) |
1130 | 1131 |
|
1131 | | - @ensure_cv2_image_for_annotation |
| 1132 | + @ensure_cv2_image_for_class_method |
1132 | 1133 | def annotate( |
1133 | 1134 | self, |
1134 | 1135 | scene: ImageType, |
@@ -1438,7 +1439,7 @@ def __init__( |
1438 | 1439 | max_line_length=max_line_length, |
1439 | 1440 | ) |
1440 | 1441 |
|
1441 | | - @ensure_pil_image_for_annotation |
| 1442 | + @ensure_pil_image_for_class_method |
1442 | 1443 | def annotate( |
1443 | 1444 | self, |
1444 | 1445 | scene: ImageType, |
@@ -1665,7 +1666,7 @@ def __init__( |
1665 | 1666 | self.position = icon_position |
1666 | 1667 | self.offset_xy = offset_xy |
1667 | 1668 |
|
1668 | | - @ensure_cv2_image_for_annotation |
| 1669 | + @ensure_cv2_image_for_class_method |
1669 | 1670 | def annotate( |
1670 | 1671 | self, scene: ImageType, detections: Detections, icon_path: str | list[str] |
1671 | 1672 | ) -> ImageType: |
@@ -1754,7 +1755,7 @@ def __init__(self, kernel_size: int = 15): |
1754 | 1755 | """ |
1755 | 1756 | self.kernel_size: int = kernel_size |
1756 | 1757 |
|
1757 | | - @ensure_cv2_image_for_annotation |
| 1758 | + @ensure_cv2_image_for_class_method |
1758 | 1759 | def annotate( |
1759 | 1760 | self, |
1760 | 1761 | scene: ImageType, |
@@ -1843,7 +1844,7 @@ def __init__( |
1843 | 1844 | self.smooth = smooth |
1844 | 1845 | self.color_lookup: ColorLookup = color_lookup |
1845 | 1846 |
|
1846 | | - @ensure_cv2_image_for_annotation |
| 1847 | + @ensure_cv2_image_for_class_method |
1847 | 1848 | def annotate( |
1848 | 1849 | self, |
1849 | 1850 | scene: ImageType, |
@@ -1965,7 +1966,7 @@ def __init__( |
1965 | 1966 | self.low_hue = low_hue |
1966 | 1967 | self.heat_mask: npt.NDArray[np.float32] | None = None |
1967 | 1968 |
|
1968 | | - @ensure_cv2_image_for_annotation |
| 1969 | + @ensure_cv2_image_for_class_method |
1969 | 1970 | def annotate(self, scene: ImageType, detections: Detections) -> ImageType: |
1970 | 1971 | """ |
1971 | 1972 | Annotates the scene with a heatmap based on the provided detections. |
@@ -2047,7 +2048,7 @@ def __init__(self, pixel_size: int = 20): |
2047 | 2048 | """ |
2048 | 2049 | self.pixel_size: int = pixel_size |
2049 | 2050 |
|
2050 | | - @ensure_cv2_image_for_annotation |
| 2051 | + @ensure_cv2_image_for_class_method |
2051 | 2052 | def annotate( |
2052 | 2053 | self, |
2053 | 2054 | scene: ImageType, |
@@ -2144,7 +2145,7 @@ def __init__( |
2144 | 2145 | self.outline_thickness: int = outline_thickness |
2145 | 2146 | self.outline_color: Color | ColorPalette = outline_color |
2146 | 2147 |
|
2147 | | - @ensure_cv2_image_for_annotation |
| 2148 | + @ensure_cv2_image_for_class_method |
2148 | 2149 | def annotate( |
2149 | 2150 | self, |
2150 | 2151 | scene: ImageType, |
@@ -2256,7 +2257,7 @@ def __init__( |
2256 | 2257 | raise ValueError("roundness attribute must be float between (0, 1.0]") |
2257 | 2258 | self.roundness: float = roundness |
2258 | 2259 |
|
2259 | | - @ensure_cv2_image_for_annotation |
| 2260 | + @ensure_cv2_image_for_class_method |
2260 | 2261 | def annotate( |
2261 | 2262 | self, |
2262 | 2263 | scene: ImageType, |
@@ -2396,7 +2397,7 @@ def __init__( |
2396 | 2397 | else int(0.15 * self.height) |
2397 | 2398 | ) |
2398 | 2399 |
|
2399 | | - @ensure_cv2_image_for_annotation |
| 2400 | + @ensure_cv2_image_for_class_method |
2400 | 2401 | def annotate( |
2401 | 2402 | self, |
2402 | 2403 | scene: ImageType, |
@@ -2577,7 +2578,7 @@ def __init__( |
2577 | 2578 | self.border_thickness: int = border_thickness |
2578 | 2579 | self.border_color_lookup: ColorLookup = border_color_lookup |
2579 | 2580 |
|
2580 | | - @ensure_cv2_image_for_annotation |
| 2581 | + @ensure_cv2_image_for_class_method |
2581 | 2582 | def annotate( |
2582 | 2583 | self, |
2583 | 2584 | scene: ImageType, |
@@ -2726,7 +2727,7 @@ def __init__( |
2726 | 2727 | self.opacity = opacity |
2727 | 2728 | self.force_box = force_box |
2728 | 2729 |
|
2729 | | - @ensure_cv2_image_for_annotation |
| 2730 | + @ensure_cv2_image_for_class_method |
2730 | 2731 | def annotate(self, scene: ImageType, detections: Detections) -> ImageType: |
2731 | 2732 | """ |
2732 | 2733 | Applies a colored overlay to the scene outside of the detected regions. |
@@ -2824,7 +2825,7 @@ def __init__( |
2824 | 2825 | self.label_scale = label_scale |
2825 | 2826 | self.text_thickness = int(self.label_scale + 1.2) |
2826 | 2827 |
|
2827 | | - @ensure_cv2_image_for_annotation |
| 2828 | + @ensure_cv2_image_for_class_method |
2828 | 2829 | def annotate( |
2829 | 2830 | self, scene: ImageType, detections_1: Detections, detections_2: Detections |
2830 | 2831 | ) -> ImageType: |
|
0 commit comments