🖤 make black happy

This commit is contained in:
SkalskiP 2023-03-14 12:41:12 +01:00
parent e04c531c05
commit b91bc91897
2 changed files with 11 additions and 5 deletions

View File

@ -1,11 +1,11 @@
from typing import Optional, Tuple
from dataclasses import replace
from typing import Optional, Tuple
import cv2
import numpy as np
from supervision import Detections
from supervision.detection.utils import generate_2d_mask, clip_boxes
from supervision.detection.utils import clip_boxes, generate_2d_mask
from supervision.draw.color import Color
from supervision.draw.utils import draw_polygon, draw_text
from supervision.geometry.core import Position
@ -25,10 +25,14 @@ class PolygonZone:
self.current_count = 0
width, height = frame_resolution_wh
self.mask = generate_2d_mask(polygon=polygon, resolution_wh=(width + 1, height + 1))
self.mask = generate_2d_mask(
polygon=polygon, resolution_wh=(width + 1, height + 1)
)
def trigger(self, detections: Detections) -> np.ndarray:
clipped_xyxy = clip_boxes(boxes_xyxy=detections.xyxy, frame_resolution_wh=self.frame_resolution_wh)
clipped_xyxy = clip_boxes(
boxes_xyxy=detections.xyxy, frame_resolution_wh=self.frame_resolution_wh
)
clipped_detections = replace(detections, xyxy=clipped_xyxy)
clipped_anchors = np.ceil(
clipped_detections.get_anchor_coordinates(anchor=self.triggering_position)

View File

@ -94,7 +94,9 @@ def non_max_suppression(
return keep[sort_index.argsort()]
def clip_boxes(boxes_xyxy: np.ndarray, frame_resolution_wh: Tuple[int, int]) -> np.ndarray:
def clip_boxes(
boxes_xyxy: np.ndarray, frame_resolution_wh: Tuple[int, int]
) -> np.ndarray:
"""
Clips bounding boxes coordinates to fit within the frame resolution.