# bbox_format_converters

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

## Functions

### 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.

Parameters

 * `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.

Returns

 * `np.ndarray`: The rotated bounding box defined as [x_center, y_center, width, height, angle].

### normalize_bboxes

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

Normalize bounding box coordinates to (0, 1).

Parameters

 * `bboxes` (`np.ndarray`): A numpy array of shape (N, 4) containing the bounding boxes.
 * `height` (`int`): The height of the image.
 * `width` (`int`): The width of the image.

Returns

 * `np.ndarray`: A numpy array of shape (N, 4) containing the normalized bounding boxes.

### 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.

Parameters

 * `cx` (`float`): The x-coordinate of the center of the bounding box.
 * `cy` (`float`): The y-coordinate of the center of the bounding box.
 * `w` (`float`): The width of the bounding box.
 * `h` (`float`): The height of the bounding box.
 * `rotation` (`float`): The angle of the bounding box given in degrees.

Returns

 * `np.ndarray`: The corners of the bounding box.

### 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].

Parameters

 * `bboxes` (`np.ndarray`): The bounding boxes to convert.

Returns

 * `np.ndarray`: The converted bounding boxes.

### 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).

Parameters

 * `bboxes` (`np.ndarray`): A numpy array of shape (N, 4) containing the bounding boxes in (x, y, width, height) format.

Returns

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

### 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].

Parameters

 * `bboxes` (`np.ndarray`): The bounding boxes to convert.

Returns

 * `np.ndarray`: The converted bounding boxes.
