update entire methods: move_obb_boxes and move detections
This commit is contained in:
1 parent
c71d9458c8
commit
2544d7293d
2 files changed
+7
-7
No files matched your search
@@ -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:
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user