# segmentation_matching

Python API: `depthai_nodes.node.box_detector.segmentation_matching`

Pair tracked boxes with the detections whose instance masks they own.

## Functions

### intersection_over_union

```python
def intersection_over_union(a: Corners, b: Corners) -> float:
```

Return the IoU of two `(xmin, ymin, xmax, ymax)` boxes.

Parameters

 * `a` (`Corners`): First box.
 * `b` (`Corners`): Second box.

Returns

 * `float`: IoU in `[0, 1]`; zero when the boxes do not overlap.

### match_tracklets_to_detections

```python
def match_tracklets_to_detections(tracklets: list[dai.Tracklet], detections: list[dai.ImgDetection]) -> dict[int, int]:
```

Greedily pair tracklets and detections by descending IoU.

Parameters

 * `tracklets` (`list[dai.Tracklet]`): Tracklets with normalized ROIs.
 * `detections` (`list[dai.ImgDetection]`): Detections with normalized corners.

Returns

 * `dict[int, int]`: Mapping of tracklet index to detection index. Pairs need a positive IoU, and each tracklet and detection
   appears at most once.

## Attributes

### Corners
