diff --git a/supervision/detection/tools/polygon_zone.py b/supervision/detection/tools/polygon_zone.py index 683ae3b5..2ca4d080 100644 --- a/supervision/detection/tools/polygon_zone.py +++ b/supervision/detection/tools/polygon_zone.py @@ -9,7 +9,7 @@ import numpy.typing as npt from supervision import Detections from supervision.detection.utils import clip_boxes, polygon_to_mask from supervision.draw.color import Color -from supervision.draw.utils import draw_polygon, draw_filled_polygon, draw_text +from supervision.draw.utils import draw_filled_polygon, draw_polygon, draw_text from supervision.geometry.core import Position from supervision.geometry.utils import get_polygon_center from supervision.utils.internal import SupervisionWarnings diff --git a/supervision/draw/utils.py b/supervision/draw/utils.py index 4c5e30d6..678f3f66 100644 --- a/supervision/draw/utils.py +++ b/supervision/draw/utils.py @@ -59,7 +59,9 @@ def draw_rectangle( return scene -def draw_filled_rectangle(scene: np.ndarray, rect: Rect, color: Color, opacity: float = 1) -> np.ndarray: +def draw_filled_rectangle( + scene: np.ndarray, rect: Rect, color: Color, opacity: float = 1 +) -> np.ndarray: """ Draws a filled rectangle on an image. @@ -183,14 +185,10 @@ def draw_filled_polygon( np.ndarray: The scene with the polygon drawn on it. """ if opacity == 1: - cv2.fillPoly( - scene, [polygon], color=color.as_bgr() - ) + cv2.fillPoly(scene, [polygon], color=color.as_bgr()) else: scene_with_annotations = scene.copy() - cv2.fillPoly( - scene_with_annotations, [polygon], color=color.as_bgr() - ) + cv2.fillPoly(scene_with_annotations, [polygon], color=color.as_bgr()) cv2.addWeighted( scene_with_annotations, opacity, scene, 1 - opacity, gamma=0, dst=scene ) diff --git a/test/detection/test_polygon_zone_annotator.py b/test/detection/test_polygon_zone_annotator.py index 0408499e..d28a4eec 100644 --- a/test/detection/test_polygon_zone_annotator.py +++ b/test/detection/test_polygon_zone_annotator.py @@ -1,12 +1,8 @@ -from contextlib import ExitStack as DoesNotRaise - -import cv2 import numpy as np import pytest import supervision as sv - COLOR = sv.Color(r=255, g=0, b=0) THICKNESS = 2 POLYGON = np.array([[100, 100], [200, 100], [200, 200], [100, 200]])