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)
| 40 | |
| 41 | |
| 42 | def 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 | |
| 63 | def box2cs(bbox_xywh, aspect_ratio=1.0, bbox_scale_factor=1.25): |
no test coverage detected