From 2544d7293d0a809e85672979dca27ad55728500d Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Tue, 16 Jul 2024 08:54:55 -0500 Subject: [PATCH] update entire methods: move_obb_boxes and move detections --- supervision/detection/tools/inference_slicer.py | 7 ++++--- supervision/detection/utils.py | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 277854f9..001838a9 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -9,6 +9,7 @@ from supervision.detection.overlap_filter import OverlapFilter, validate_overlap from supervision.detection.utils import move_boxes, move_masks, move_obb_boxes from supervision.utils.image import crop_image from supervision.utils.internal import SupervisionWarnings +from supervision import config def move_detections( @@ -28,9 +29,9 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset) - if "ORIENTED_BOX_COORDINATES" in detections.data: - detections.data["ORIENTED_BOX_COORDINATES"] = move_obb_boxes( - xyss=detections.data["ORIENTED_BOX_COORDINATES"], offset=offset + if config.ORIENTED_BOX_COORDINATES in detections.data: + detections.data[config.ORIENTED_BOX_COORDINATES] = move_obb_boxes( + xyxyxyxy=detections.data[config.ORIENTED_BOX_COORDINATES], offset=offset ) if detections.mask is not None: if resolution_wh is None: diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index dc66023a..756d6a2d 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -596,9 +596,8 @@ def move_boxes( return xyxy + np.hstack([offset, offset]) -def move_obb_boxes( - xyss: npt.NDArray[np.float64], offset: npt.NDArray[np.int32] -) -> npt.NDArray[np.float64]: +def move_obb_boxes(xyxyxyxy: npt.NDArray[np.float64], offset: npt.NDArray[np.int32] + ) -> npt.NDArray[np.float64]: """ Parameters: xyxyxyxy (npt.NDArray[np.float64]): An array of shape `(n, 4, 2)` containing the @@ -630,7 +629,7 @@ def move_obb_boxes( """ return [ xys + np.hstack([offset, offset, offset, offset]).reshape(xys.shape) - for xys in xyss + for xys in xyxyxyxy ]