NpBoxList#
- class NpBoxList[source]#
Bases:
object
A list of bounding boxes as a [y_min, x_min, y_max, x_max] numpy array.
It is assumed that all bounding boxes within a given list correspond to a single image. Optionally, users can add additional related fields (such as objectness/classification scores).
- __init__(data: ndarray)[source]#
Constructor.
- Parameters:
data (np.ndarray) – Box coords as a [N, 4] numpy array.
- Raises:
ValueError – If bbox data is not a numpy array.
ValueError – If invalid dimensions for bbox data.
Methods
__init__
(data)Constructor.
add_field
(name, data)Add data to a specified field.
get
()Shorthand for get_field('boxes').
Get corner coordinates of boxes.
Return all non-box fields.
get_field
(name)Get data for field.
has_field
(field)Return number of boxes held in collections.
- __init__(data: ndarray)[source]#
Constructor.
- Parameters:
data (np.ndarray) – Box coords as a [N, 4] numpy array.
- Raises:
ValueError – If bbox data is not a numpy array.
ValueError – If invalid dimensions for bbox data.
- add_field(name: str, data: ndarray) None [source]#
Add data to a specified field.
- Parameters:
name (str) – Field name.
data (np.ndarray) – Field data: box coords as a [N, 4] numpy array.
- Raises:
ValueError – If name already exists.
ValueError – If the dimension of the field data does not matche the number of boxes.
- Return type:
None
- get_coordinates() tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]#
Get corner coordinates of boxes.
- Returns:
a 4-tuple of 1-d numpy arrays [y_min, x_min, y_max, x_max].
- Return type:
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]