Skip to content

Box operations

powerboxes.boxes_areas(boxes)

Compute areas of boxes.

Parameters:

Name Type Description Default
boxes NDArray[T]

2d array of boxes in xyxy format

required

Returns:

Type Description
NDArray[float64]

np.ndarray: 1d array of areas

powerboxes.box_convert(boxes, in_fmt, out_fmt)

Convert boxes from one format to another.

Available formats are
  • 'xyxy': (xmin, ymin, xmax, ymax)
  • 'xywh': (xmin, ymin, width, height)
  • 'cxcywh': (center_x, center_y, width, height)

Parameters:

Name Type Description Default
boxes NDArray[T]

2d array of boxes in in_fmt

required
in_fmt str

format of input boxes

required
out_fmt str

format of output boxes

required

Returns:

Type Description
NDArray[T]

np.ndarray: boxes in out_fmt

powerboxes.masks_to_boxes(masks)

Convert masks to boxes in xyxy format.

Parameters:

Name Type Description Default
masks NDArray[bool_]

3d array of masks in (N, H, W) format

required

Raises:

Type Description
TypeError

if masks is not numpy array

Returns:

Type Description
NDArray[uint64]

npt.NDArray[np.uint64]: 2d array of boxes in xyxy format