IoB¶
Module for calculating Intersection over Box (IoB) metrics.
This module provides functions to compute IoB values between single and multiple bounding boxes, useful for evaluating object detection and tracking results.
iob ¶
iob(box_a: ndarray, box_b: ndarray) -> tuple[float, float]
Calculate the Intersection over Box (IoB) between two bounding boxes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box_a
|
ndarray
|
Bounding box of shape (4,) with format [left, top, width, height]. |
required |
box_b
|
ndarray
|
Bounding box of shape (4,) with format [left, top, width, height]. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
A tuple (iob_a, iob_b) where: - iob_a: ratio of intersection area to box_a area - iob_b: ratio of intersection area to box_b area |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either box does not have shape (4,) or contains negative width/height. |
Notes
Bounding box format is [left, top, width, height] where: - left: x-coordinate of top-left corner - top: y-coordinate of top-left corner - width: box width (must be non-negative) - height: box height (must be non-negative)
Examples:
>>> box1 = np.array([0, 0, 10, 10])
>>> box2 = np.array([5, 5, 10, 10])
>>> iob(box1, box2)
(0.25, 0.25)
Source code in src/dnt/engine/iob.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
iobs ¶
iobs(
alrbs: ndarray, blrbs: ndarray
) -> tuple[np.ndarray, np.ndarray]
Calculate the IoB matrix for multiple bounding boxes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alrbs
|
ndarray
|
Array of shape (N, 4) containing N bounding boxes with format [left, top, width, height]. |
required |
blrbs
|
ndarray
|
Array of shape (M, 4) containing M bounding boxes with format [left, top, width, height]. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
A tuple (iobs_a, iobs_b) where: - iobs_a: array of shape (N, M) with IoB values relative to alrbs - iobs_b: array of shape (N, M) with IoB values relative to blrbs |
Raises:
| Type | Description |
|---|---|
ValueError
|
If arrays do not have shape (N, 4) and (M, 4) respectively, or contain negative width/height values. |
Notes
Bounding box format is [left, top, width, height] where: - left: x-coordinate of top-left corner - top: y-coordinate of top-left corner - width: box width (must be non-negative) - height: box height (must be non-negative)
Examples:
>>> boxes1 = np.array([[0, 0, 10, 10], [5, 5, 10, 10]])
>>> boxes2 = np.array([[0, 0, 5, 5], [10, 10, 5, 5]])
>>> iobs_a, iobs_b = iobs(boxes1, boxes2)
>>> iobs_a.shape
(2, 2)
Source code in src/dnt/engine/iob.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |