bbox-utils

bbox-utils allows you to easily convert between different bounding box formats (YOLO, XYWH, XYXY, etc.).

It’s as simple to use as:

from bbox_utils import BoundingBox

xy1 = np.array([100, 50])
xy2 = np.array([200, 75])
bbox = BoundingBox.from_xyxy(xy1, xy2)

# Get XYWH
xy, w, h = bbox.to_xywh()

# Get XYXY
xy1, xy2 = bbox.to_xyxy()

# Get YOLO
image_dim = 640, 420
yolo_bbox = bbox.to_yolo(image_dim)

You can install bbox-utils with PyPI: pip install bbox-utils

Conversions

2D Bounding Box Conversions:

Colab Image Demo

  • List of points [top left, top right, bottom right, bottom left]

  • XYWH: top left, width, height

  • XYXY: top left, bottom right

  • YOLO

  • 3D Bounding Box Conversions You can create a 3D bounding box with either:

3D Bounding Box Conversions:

Colab PCD Demo

You can create a 3D bounding box with either:

  • A center point, width, height, depth, and rotation

  • The back-bottom-left point, width, height, depth, and rotation

You can convert between the two forms and also get a triangular polygon to use for plotting triangular meshes.

The majority of the 3D Bounding Box implementation comes from the bbox PyPI package.

Indices and tables