# bbox_format_converters

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

## Functions

| Name | Description |
| --- | --- |
| [`corners_to_rotated_bbox`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/bbox_format_converters.md#bbox_format_converters-Functions-corners_to_rotated_bbox) | Converts the corners of a bounding box to a rotated bounding box. |
| [`normalize_bboxes`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/bbox_format_converters.md#bbox_format_converters-Functions-normalize_bboxes) | Normalize bounding box coordinates to (0, 1). |
| [`rotated_bbox_to_corners`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/bbox_format_converters.md#bbox_format_converters-Functions-rotated_bbox_to_corners) | Converts a rotated bounding box to the corners of the bounding box. |
| [`top_left_wh_to_xywh`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/bbox_format_converters.md#bbox_format_converters-Functions-top_left_wh_to_xywh) | Converts bounding boxes from [top_left_x, top_left_y, width, height] to [x_center, y_center, width, height]. |
| [`xywh_to_xyxy`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/bbox_format_converters.md#bbox_format_converters-Functions-xywh_to_xyxy) | Convert bounding box coordinates from (x_center, y_center, width, height) to (x_min, y_min, x_max, y_max). |
| [`xyxy_to_xywh`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/bbox_format_converters.md#bbox_format_converters-Functions-xyxy_to_xywh) | Converts bounding boxes from [x_min, y_min, x_max, y_max] to [x_center, y_center, width, height]. |

### function `corners_to_rotated_bbox`

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

Converts the corners of a bounding box to a rotated bounding box.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `corners` | `np.ndarray` | The corners of the bounding box. The corners are expected to be ordered by top-left, top-right, bottom-right, bottom-left. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | The rotated bounding box defined as [x_center, y_center, width, height, angle]. |

### function `normalize_bboxes`

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

Normalize bounding box coordinates to (0, 1).

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `bboxes` | `np.ndarray` | A numpy array of shape (N, 4) containing the bounding boxes. | required |
| `height` | `int` | The height of the image. | required |
| `width` | `int` | The width of the image. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | A numpy array of shape (N, 4) containing the normalized bounding boxes. |

### function `rotated_bbox_to_corners`

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

Converts a rotated bounding box to the corners of the bounding box.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `cx` | `float` | The x-coordinate of the center of the bounding box. | required |
| `cy` | `float` | The y-coordinate of the center of the bounding box. | required |
| `w` | `float` | The width of the bounding box. | required |
| `h` | `float` | The height of the bounding box. | required |
| `rotation` | `float` | The angle of the bounding box given in degrees. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | The corners of the bounding box. |

### function `top_left_wh_to_xywh`

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

Converts bounding boxes from [top_left_x, top_left_y, width, height] to [x_center, y_center, width, height].

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `bboxes` | `np.ndarray` | The bounding boxes to convert. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | The converted bounding boxes. |

### function `xywh_to_xyxy`

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

Convert bounding box coordinates from (x_center, y_center, width, height) to (x_min, y_min, x_max, y_max).

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `bboxes` | `np.ndarray` | A numpy array of shape (N, 4) containing the bounding boxes in (x, y, width, height) format. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | A numpy array of shape (N, 4) containing the bounding boxes in (x_min, y_min, x_max, y_max) format. |

### function `xyxy_to_xywh`

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

Converts bounding boxes from [x_min, y_min, x_max, y_max] to [x_center, y_center, width, height].

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `bboxes` | `np.ndarray` | The bounding boxes to convert. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | The converted bounding boxes. |
