MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / xywh2xyxy

Function xywh2xyxy

detrsmpl/utils/demo_utils.py:42–60  ·  view source on GitHub ↗

Transform the bbox format from xywh to x1y1x2y2. Args: bbox_xywh (np.ndarray): Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, width, height, [score]) Returns: np.ndarray: Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top

(bbox_xywh)

Source from the content-addressed store, hash-verified

40
41
42def xywh2xyxy(bbox_xywh):
43 """Transform the bbox format from xywh to x1y1x2y2.
44
45 Args:
46 bbox_xywh (np.ndarray): Bounding boxes (with scores), shaped
47 (n, 4) or (n, 5). (left, top, width, height, [score])
48
49 Returns:
50 np.ndarray: Bounding boxes (with scores),
51 shaped (n, 4) or (n, 5). (left, top, right, bottom, [score])
52 """
53 if not isinstance(bbox_xywh, np.ndarray):
54 raise TypeError(
55 f'Input type is {type(bbox_xywh)}, which should be numpy.ndarray.')
56 bbox_xyxy = bbox_xywh.copy()
57 bbox_xyxy[..., 2] = bbox_xyxy[..., 2] + bbox_xyxy[..., 0] - 1
58 bbox_xyxy[..., 3] = bbox_xyxy[..., 3] + bbox_xyxy[..., 1] - 1
59
60 return bbox_xyxy
61
62
63def box2cs(bbox_xywh, aspect_ratio=1.0, bbox_scale_factor=1.25):

Callers 4

__call__Method · 0.90
__call__Method · 0.90
feature_extractFunction · 0.90

Calls 1

copyMethod · 0.80

Tested by

no test coverage detected