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

Function xyxy2xywh

detrsmpl/utils/demo_utils.py:21–39  ·  view source on GitHub ↗

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

(bbox_xyxy)

Source from the content-addressed store, hash-verified

19
20
21def xyxy2xywh(bbox_xyxy):
22 """Transform the bbox format from x1y1x2y2 to xywh.
23
24 Args:
25 bbox_xyxy (np.ndarray): Bounding boxes (with scores), shaped (n, 4) or
26 (n, 5). (left, top, right, bottom, [score])
27
28 Returns:
29 np.ndarray: Bounding boxes (with scores),
30 shaped (n, 4) or (n, 5). (left, top, width, height, [score])
31 """
32 if not isinstance(bbox_xyxy, np.ndarray):
33 raise TypeError(
34 f'Input type is {type(bbox_xyxy)}, which should be numpy.ndarray.')
35 bbox_xywh = bbox_xyxy.copy()
36 bbox_xywh[..., 2] = bbox_xywh[..., 2] - bbox_xywh[..., 0]
37 bbox_xywh[..., 3] = bbox_xywh[..., 3] - bbox_xywh[..., 1]
38
39 return bbox_xywh
40
41
42def xywh2xyxy(bbox_xywh):

Callers 10

load_annotationsMethod · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
feature_extractFunction · 0.90
inferenceMethod · 0.90
convert_kp2d_to_bboxFunction · 0.85

Calls 1

copyMethod · 0.80

Tested by

no test coverage detected