From 60d56602865cef878ce10ece5be6806e992651ba Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Thu, 11 Jul 2024 13:38:58 -0500 Subject: [PATCH 01/14] added functionality for oriented bounding boxes --- .../detection/tools/inference_slicer.py | 4 ++- supervision/detection/utils.py | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 134361bd..00023ec3 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -6,7 +6,7 @@ import numpy as np from supervision.detection.core import Detections from supervision.detection.overlap_filter import OverlapFilter, validate_overlap_filter -from supervision.detection.utils import move_boxes, move_masks +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 @@ -28,6 +28,8 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset) + if 'xyxyxyxy' in detections: + detections.xyxyxyxy = move_obb_boxes(xyxyxyxy = detections.xyxyxyxy, offset = offset) if detections.mask is not None: if resolution_wh is None: raise ValueError( diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index e7090be3..5082afb3 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -595,6 +595,33 @@ def move_boxes( """ return xyxy + np.hstack([offset, offset]) +def move_obb_boxes(xyxyxyxy, offset): + """ + Parameters: + xyxyxyxy (npt.NDArray[np.float64]): An array of shape `(n, 8)` containing the + bounding boxes coordinates in format `[x1, y1, x2, y2,x3, y3, x4, y4]` + offset (np.array): An array of shape `(2,)` containing offset values in format + is `[dx, dy]`. + + Returns: + npt.NDArray[np.float64]: Repositioned oriented bounding boxes. + + Examples: + ```python + import numpy as np + import supervision as sv + + xyxyxyxy: np.array([[10, 10, 20, 20, 30, 30, 40, 40], + [20, 20, 30, 30, 40, 40, 50, 50]]) + offset = np.array([5, 10]) + + sv.move_obb_boxes(xyxyxyxy=xyxyxyxy, offset=offset) + #[[15 20 25 30 35 40 45 50] + #[25 30 35 40 45 50 55 60]] + ``` + """ + + return xyxyxyxy + np.hstack([offset, offset, offset, offset]) def move_masks( masks: npt.NDArray[np.bool_], From 7fa7907219a683b98167f85758dbde6f8faf6f8b Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Thu, 11 Jul 2024 14:42:13 -0500 Subject: [PATCH 02/14] Run pre-commit and fix issues --- supervision/detection/tools/inference_slicer.py | 6 ++++-- supervision/detection/utils.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 00023ec3..7208d3ce 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -28,8 +28,10 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset) - if 'xyxyxyxy' in detections: - detections.xyxyxyxy = move_obb_boxes(xyxyxyxy = detections.xyxyxyxy, offset = offset) + if "xyxyxyxy" in detections: + detections.xyxyxyxy = move_obb_boxes( + xyxyxyxy=detections.xyxyxyxy, offset=offset + ) if detections.mask is not None: if resolution_wh is None: raise ValueError( diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 5082afb3..5f38905a 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -595,6 +595,7 @@ def move_boxes( """ return xyxy + np.hstack([offset, offset]) + def move_obb_boxes(xyxyxyxy, offset): """ Parameters: @@ -604,7 +605,7 @@ def move_obb_boxes(xyxyxyxy, offset): is `[dx, dy]`. Returns: - npt.NDArray[np.float64]: Repositioned oriented bounding boxes. + npt.NDArray[np.float64]: Repositioned oriented bounding boxes. Examples: ```python @@ -623,6 +624,7 @@ def move_obb_boxes(xyxyxyxy, offset): return xyxyxyxy + np.hstack([offset, offset, offset, offset]) + def move_masks( masks: npt.NDArray[np.bool_], offset: npt.NDArray[np.int32], From 9d5a477064665c22723be7b2e9a3e3d49582c554 Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Thu, 11 Jul 2024 16:44:23 -0500 Subject: [PATCH 03/14] correct check to detections.data --- supervision/detection/tools/inference_slicer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 7208d3ce..2372dc51 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -28,9 +28,9 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset) - if "xyxyxyxy" in detections: - detections.xyxyxyxy = move_obb_boxes( - xyxyxyxy=detections.xyxyxyxy, offset=offset + if "xyxyxyxy" in detections.data: + detections.data["xyxyxyxy"] = move_obb_boxes( + xyxyxyxy=detections.data["xyxyxyxy"], offset=offset ) if detections.mask is not None: if resolution_wh is None: From 377ca27cc98eb022c2067fa4c41dcec09b12666c Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Thu, 11 Jul 2024 18:00:46 -0500 Subject: [PATCH 04/14] change move_obb_boxesto accept array of arrays --- supervision/detection/utils.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 5f38905a..3d4fe8d5 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -612,17 +612,23 @@ def move_obb_boxes(xyxyxyxy, offset): import numpy as np import supervision as sv - xyxyxyxy: np.array([[10, 10, 20, 20, 30, 30, 40, 40], - [20, 20, 30, 30, 40, 40, 50, 50]]) + xyxyxyxy: np.array([[[10., 10.], + [20., 20.], + [30., 30.], + [40., 40.]]]) offset = np.array([5, 10]) sv.move_obb_boxes(xyxyxyxy=xyxyxyxy, offset=offset) - #[[15 20 25 30 35 40 45 50] - #[25 30 35 40 45 50 55 60]] + #[[[15., 20.], + #[25., 30.], + #[35., 40.], + #[45., 50.]]] ``` """ - return xyxyxyxy + np.hstack([offset, offset, offset, offset]) + return xyxyxyxy + np.hstack([offset, offset, offset, offset]).reshape( + xyxyxyxy.shape + ) def move_masks( From 113d4b697a77023164286047be9a037278acd584 Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Fri, 12 Jul 2024 08:51:46 -0500 Subject: [PATCH 05/14] change move_obb_boxes to accept multiple detections --- supervision/detection/utils.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 3d4fe8d5..bd12a88b 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -599,10 +599,11 @@ def move_boxes( def move_obb_boxes(xyxyxyxy, offset): """ Parameters: - xyxyxyxy (npt.NDArray[np.float64]): An array of shape `(n, 8)` containing the - bounding boxes coordinates in format `[x1, y1, x2, y2,x3, y3, x4, y4]` - offset (np.array): An array of shape `(2,)` containing offset values in format - is `[dx, dy]`. + xyxyxyxy (npt.NDArray[np.float64]): An array of shape `(n, 4, 2)` containing the + bounding boxes coordinates in format + `n * [[x1, y1], [x2, y2],[x3, y3], [x4, y4]]` + offset (np.array): An array of shape `(2,)` containing offset values + in format is `[dx, dy]`. Returns: npt.NDArray[np.float64]: Repositioned oriented bounding boxes. @@ -625,10 +626,10 @@ def move_obb_boxes(xyxyxyxy, offset): #[45., 50.]]] ``` """ - - return xyxyxyxy + np.hstack([offset, offset, offset, offset]).reshape( - xyxyxyxy.shape - ) + return [ + xys + np.hstack([offset, offset, offset, offset]).reshape(xys.shape) + for xys in xyxyxyxy + ] def move_masks( From 9a61b3c41b0c0aa044c952031f57caf093306c58 Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Fri, 12 Jul 2024 09:26:27 -0500 Subject: [PATCH 06/14] added email to the push From cea854edf51336688571a40e7607c527fb4bf2f8 Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Fri, 12 Jul 2024 09:34:26 -0500 Subject: [PATCH 07/14] small change to comments, added email to submission --- supervision/detection/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index bd12a88b..0349c4b6 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -601,7 +601,7 @@ def move_obb_boxes(xyxyxyxy, offset): Parameters: xyxyxyxy (npt.NDArray[np.float64]): An array of shape `(n, 4, 2)` containing the bounding boxes coordinates in format - `n * [[x1, y1], [x2, y2],[x3, y3], [x4, y4]]` + `n[[x1, y1], [x2, y2],[x3, y3], [x4, y4]]` offset (np.array): An array of shape `(2,)` containing offset values in format is `[dx, dy]`. From c9d4f2b82e9a65ee6b9717d9cec04548c7701c5d Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Sat, 13 Jul 2024 08:18:47 -0500 Subject: [PATCH 08/14] commit under new branch --- supervision/detection/tools/inference_slicer.py | 6 +++--- supervision/detection/utils.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 2372dc51..277854f9 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -28,9 +28,9 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset) - if "xyxyxyxy" in detections.data: - detections.data["xyxyxyxy"] = move_obb_boxes( - xyxyxyxy=detections.data["xyxyxyxy"], 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 detections.mask is not None: if resolution_wh is None: diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 0349c4b6..1d984ceb 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -596,7 +596,8 @@ def move_boxes( return xyxy + np.hstack([offset, offset]) -def move_obb_boxes(xyxyxyxy, offset): +def move_obb_boxes(xyss: 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 @@ -619,7 +620,7 @@ def move_obb_boxes(xyxyxyxy, offset): [40., 40.]]]) offset = np.array([5, 10]) - sv.move_obb_boxes(xyxyxyxy=xyxyxyxy, offset=offset) + sv.move_obb_boxes(xyss, offset=offset) #[[[15., 20.], #[25., 30.], #[35., 40.], @@ -628,7 +629,7 @@ def move_obb_boxes(xyxyxyxy, offset): """ return [ xys + np.hstack([offset, offset, offset, offset]).reshape(xys.shape) - for xys in xyxyxyxy + for xys in xyss ] From 5ee8fcfea287b234310a90bc955eeab0fce7ff6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:19:21 +0000 Subject: [PATCH 09/14] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 1d984ceb..dc66023a 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -596,8 +596,9 @@ 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( + xyss: 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 From c71d9458c8fb2403455405cea03af1e68f1d1838 Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Fri, 12 Jul 2024 09:26:27 -0500 Subject: [PATCH 10/14] added email to the push From 2544d7293d0a809e85672979dca27ad55728500d Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Tue, 16 Jul 2024 08:54:55 -0500 Subject: [PATCH 11/14] 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 ] From 48f6c8d3c1ac0cdd04df650924c74486bdd0053c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:55:23 +0000 Subject: [PATCH 12/14] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/tools/inference_slicer.py | 2 +- supervision/detection/utils.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 001838a9..d6954fcb 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -4,12 +4,12 @@ from typing import Callable, Optional, Tuple, Union import numpy as np +from supervision import config from supervision.detection.core import Detections from supervision.detection.overlap_filter import OverlapFilter, validate_overlap_filter 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( diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 756d6a2d..d704997a 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -596,8 +596,9 @@ def move_boxes( return xyxy + np.hstack([offset, offset]) -def move_obb_boxes(xyxyxyxy: 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 From 9b0568c5e7df5ee03f0fb77e0962cfe81c6d1643 Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Tue, 16 Jul 2024 10:00:00 -0500 Subject: [PATCH 13/14] change import config to import config.OREIENTED_BOX_COORDINATES --- supervision/detection/tools/inference_slicer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index d6954fcb..d8a62e4f 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -4,7 +4,7 @@ from typing import Callable, Optional, Tuple, Union import numpy as np -from supervision import config +from supervision.config import ORIENTED_BOX_COORDINATES as o_b_c from supervision.detection.core import Detections from supervision.detection.overlap_filter import OverlapFilter, validate_overlap_filter from supervision.detection.utils import move_boxes, move_masks, move_obb_boxes @@ -29,9 +29,9 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, 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 o_b_c in detections.data: + detections.data[o_b_c] = move_obb_boxes( + xyxyxyxy=detections.data[o_b_c], offset=offset ) if detections.mask is not None: if resolution_wh is None: From b21a478528cd85d59fe53fe730098c11506592cc Mon Sep 17 00:00:00 2001 From: Eric Criteser Date: Wed, 17 Jul 2024 08:25:44 -0500 Subject: [PATCH 14/14] eliminate alias obc, rename function to move_oriented_boxes, return using broadcasting, change docstring --- .../detection/tools/inference_slicer.py | 10 +-- supervision/detection/utils.py | 67 ++++++++++++------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index d8a62e4f..38d85faa 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -4,10 +4,10 @@ from typing import Callable, Optional, Tuple, Union import numpy as np -from supervision.config import ORIENTED_BOX_COORDINATES as o_b_c +from supervision.config import ORIENTED_BOX_COORDINATES from supervision.detection.core import Detections from supervision.detection.overlap_filter import OverlapFilter, validate_overlap_filter -from supervision.detection.utils import move_boxes, move_masks, move_obb_boxes +from supervision.detection.utils import move_boxes, move_masks, move_oriented_boxes from supervision.utils.image import crop_image from supervision.utils.internal import SupervisionWarnings @@ -29,9 +29,9 @@ def move_detections( (sv.Detections) repositioned Detections object. """ detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset) - if o_b_c in detections.data: - detections.data[o_b_c] = move_obb_boxes( - xyxyxyxy=detections.data[o_b_c], offset=offset + if ORIENTED_BOX_COORDINATES in detections.data: + detections.data[ORIENTED_BOX_COORDINATES] = move_oriented_boxes( + xyxyxyxy=detections.data[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 d704997a..a02a6a1f 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -596,42 +596,59 @@ def move_boxes( return xyxy + np.hstack([offset, offset]) -def move_obb_boxes( +def move_oriented_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 - bounding boxes coordinates in format - `n[[x1, y1], [x2, y2],[x3, y3], [x4, y4]]` - offset (np.array): An array of shape `(2,)` containing offset values - in format is `[dx, dy]`. + xyxyxyxy (npt.NDArray[np.float64]): An array of shape `(n, 4, 2)` containing the + oriented bounding boxes coordinates in format + `[[x1, y1], [x2, y2], [x3, y3], [x3, y3]]` + offset (np.array): An array of shape `(2,)` containing offset values in format + is `[dx, dy]`. Returns: - npt.NDArray[np.float64]: Repositioned oriented bounding boxes. + npt.NDArray[np.float64]: Repositioned bounding boxes. Examples: - ```python - import numpy as np - import supervision as sv + ```python + import numpy as np + import supervision as sv - xyxyxyxy: np.array([[[10., 10.], - [20., 20.], - [30., 30.], - [40., 40.]]]) - offset = np.array([5, 10]) + xyxyxyxy = np.array([ + [ + [20, 10], + [10, 20], + [20, 30], + [30, 20] + ], + [ + [30 ,30], + [20, 40], + [30, 50], + [40, 40] + ] + ]) + offset = np.array([5, 5]) - sv.move_obb_boxes(xyss, offset=offset) - #[[[15., 20.], - #[25., 30.], - #[35., 40.], - #[45., 50.]]] - ``` + sv.move_oriented_boxes(xyxy=xyxy, offset=offset) + # array([ + # [ + # [25, 15], + # [15, 25], + # [25, 35], + # [35, 25] + # ], + # [ + # [35, 35], + # [25, 45], + # [35, 55], + # [45, 45] + # ] + # ]) + ``` """ - return [ - xys + np.hstack([offset, offset, offset, offset]).reshape(xys.shape) - for xys in xyxyxyxy - ] + return xyxyxyxy + offset def move_masks(