Skip to content

Bounding Box IoU

Compute IoU (Intersection over Union) between bounding boxes.

This module provides functions to calculate the IoU metric for bounding boxes.

ious

ious(atlbrs, btlbrs)

Compute cost based on IoU.

:type atlbrs: list[tlbr] | np.ndarray :type atlbrs: list[tlbr] | np.ndarray

:rtype ious np.ndarray

Source code in src/dnt/engine/bbox_iou.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def ious(atlbrs, btlbrs):
    """Compute cost based on IoU.

    :type atlbrs: list[tlbr] | np.ndarray
    :type atlbrs: list[tlbr] | np.ndarray

    :rtype ious np.ndarray
    """
    ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float64)
    if ious.size == 0:
        return ious

    ious = bbox_overlaps(np.ascontiguousarray(atlbrs, dtype=np.float64), np.ascontiguousarray(btlbrs, dtype=np.float64))

    return ious