# bbox_format_converters

Python API: `depthai_nodes.node.parsers.utils.bbox_format_converters`

## 函数

### corners_to_rotated_bbox

```python
def corners_to_rotated_bbox(corners: np.ndarray) -> np.ndarray:
```

将边界框的角点转换为旋转边界框。

参数

 * `corners` (`np.ndarray`): 边界框的角点。角点应按左上、右上、右下、左下的顺序排列。

返回

 * `np.ndarray`: 定义为 [x_center, y_center, width, height, angle] 的旋转边界框。

### normalize_bboxes

```python
def normalize_bboxes(bboxes: np.ndarray, height: int, width: int) -> np.ndarray:
```

将边界框坐标归一化到 (0, 1)。

参数

 * `bboxes` (`np.ndarray`): 包含边界框的形状为 (N, 4) 的 numpy 数组。
 * `height` (`int`): 图像的高度。
 * `width` (`int`): 图像的宽度。

返回

 * `np.ndarray`: 包含归一化边界框的形状为 (N, 4) 的 numpy 数组。

### rotated_bbox_to_corners

```python
def rotated_bbox_to_corners(cx: float, cy: float, w: float, h: float, rotation: float) -> np.ndarray:
```

将旋转边界框转换为边界框的角点。

参数

 * `cx` (`float`): 边界框中心的 x 坐标。
 * `cy` (`float`): 边界框中心的 y 坐标。
 * `w` (`float`): 边界框的宽度。
 * `h` (`float`): 边界框的高度。
 * `rotation` (`float`): 边界框的角度，以度为单位。

返回

 * `np.ndarray`: 边界框的角点。

### top_left_wh_to_xywh

```python
def top_left_wh_to_xywh(bboxes: np.ndarray) -> np.ndarray:
```

将边界框从 [top_left_x, top_left_y, width, height] 转换为 [x_center, y_center, width, height]。

参数

 * `bboxes` (`np.ndarray`): 要转换的边界框。

返回

 * `np.ndarray`: 转换后的边界框。

### xywh_to_xyxy

```python
def xywh_to_xyxy(bboxes: np.ndarray) -> np.ndarray:
```

将边界框坐标从 (x_center, y_center, width, height) 转换为 (x_min, y_min, x_max, y_max)。

参数

 * `bboxes` (`np.ndarray`): 包含 (x, y, width, height) 格式边界框的形状为 (N, 4) 的 numpy 数组。

返回

 * `np.ndarray`: 包含 (x_min, y_min, x_max, y_max) 格式边界框的形状为 (N, 4) 的 numpy 数组。

### xyxy_to_xywh

```python
def xyxy_to_xywh(bboxes: np.ndarray) -> np.ndarray:
```

将边界框从 [x_min, y_min, x_max, y_max] 转换为 [x_center, y_center, width, height]。

参数

 * `bboxes` (`np.ndarray`): 要转换的边界框。

返回

 * `np.ndarray`: 转换后的边界框。
