diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index f7af7797..e8db4627 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -415,16 +415,17 @@ def move_boxes(xyxy: np.ndarray, offset: np.ndarray) -> np.ndarray: Example: ```python - >>> import numpy as np - >>> import supervision as sv + import numpy as np + import supervision as sv - >>> boxes = np.array([[10, 10, 20, 20], [30, 30, 40, 40]]) - >>> offset = np.array([5, 5]) - >>> sv.move_boxes(boxes, offset) - ... array([ - ... [15, 15, 25, 25], - ... [35, 35, 45, 45] - ... ]) + boxes = np.array([[10, 10, 20, 20], [30, 30, 40, 40]]) + offset = np.array([5, 5]) + moved_box = sv.move_boxes(boxes, offset) + print(moved_box) + # np.array([ + # [15, 15, 25, 25], + # [35, 35, 45, 45] + # ]) ``` """ return xyxy + np.hstack([offset, offset]) @@ -446,16 +447,17 @@ def scale_boxes(xyxy: np.ndarray, factor: float) -> np.ndarray: Example: ```python - >>> import numpy as np - >>> import supervision as sv + import numpy as np + import supervision as sv - >>> boxes = np.array([[10, 10, 20, 20], [30, 30, 40, 40]]) - >>> factor = 1.5 - >>> sv.scale_boxes(boxes, factor) - ... array([ - ... [ 7.5, 7.5, 22.5, 22.5], - ... [27.5, 27.5, 42.5, 42.5] - ... ]) + boxes = np.array([[10, 10, 20, 20], [30, 30, 40, 40]]) + factor = 1.5 + scaled_bb = sv.scale_boxes(boxes, factor) + print(scaled_bb) + # np.array([ + # [ 7.5, 7.5, 22.5, 22.5], + # [27.5, 27.5, 42.5, 42.5] + # ]) ``` """ centers = (xyxy[:, :2] + xyxy[:, 2:]) / 2