roboflow/supervision · error · ValueError

Detections oriented bounding boxes are not available

Error message

Detections oriented bounding boxes are not available

What it means

Raised by get_detection_size_category() when metric_target is ORIENTED_BOUNDING_BOXES but detections.data[ORIENTED_BOX_COORDINATES] is absent. Oriented-box size categorization needs the (N, 4, 2) corner coordinates stored under that data key; axis-aligned xyxy alone is not enough because OBB area depends on rotation. The error tells you the required metadata field is missing.

Source

Thrown at src/supervision/metrics/utils/object_size.py:315

        areas = np.asarray(area_data, dtype=np.float64)
        if len(areas.shape) != 1 or len(areas) != len(detections):
            raise ValueError(
                "Detection area metadata must be shaped (N,) and aligned "
                "with detections"
            )
        return get_area_size_category(areas)

    if metric_target == MetricTarget.BOXES:
        return get_bbox_size_category(detections.xyxy)
    if metric_target == MetricTarget.MASKS:
        mask = detections.mask
        if mask is None:
            raise ValueError("Detections mask is not available")
        return get_mask_size_category(mask)
    if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:
        oriented_box_coordinates = detections.data.get(ORIENTED_BOX_COORDINATES)
        if oriented_box_coordinates is None:
            raise ValueError("Detections oriented bounding boxes are not available")
        return get_obb_size_category(
            cast(
                npt.NDArray[np.number],
                np.asarray(oriented_box_coordinates, dtype=np.float32),
            )
        )
    raise ValueError("Invalid metric type")

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Attach the corners: sv.Detections(..., data={ORIENTED_BOX_COORDINATES: corners}) with corners shaped (N, 4, 2)
  2. Use an OBB-aware model connector that populates the field automatically
  3. Or switch the metric target to MetricTarget.BOXES if rotation is not needed

Example fix

# before
dets = sv.Detections(xyxy=boxes)
get_detection_size_category(dets, MetricTarget.ORIENTED_BOUNDING_BOXES)

# after
from supervision.config import ORIENTED_BOX_COORDINATES

dets = sv.Detections(
    xyxy=boxes,
    data={ORIENTED_BOX_COORDINATES: obb_corners},  # (N, 4, 2)
)
get_detection_size_category(dets, MetricTarget.ORIENTED_BOUNDING_BOXES)
Defensive patterns

Strategy: type-guard

Validate before calling

from supervision.config import ORIENTED_BOX_COORDINATES

has_obb = (
    ORIENTED_BOX_COORDINATES in detections.data
    and np.asarray(detections.data[ORIENTED_BOX_COORDINATES]).shape[1:] == (4, 2)
)
if not has_obb:
    raise ValueError('OBB metric needs ORIENTED_BOX_COORDINATES data')

Type guard

import numpy as np
from supervision.config import ORIENTED_BOX_COORDINATES

def has_obb_coordinates(dets: sv.Detections) -> bool:
    """True when detections carry (N, 4, 2) oriented box corners."""
    corners = dets.data.get(ORIENTED_BOX_COORDINATES)
    return corners is not None and np.asarray(corners).ndim == 3

Try / catch

try:
    cats = get_detection_size_category(detections, MetricTarget.ORIENTED_BOUNDING_BOXES)
except ValueError as e:
    if 'oriented bounding boxes are not available' in str(e):
        cats = get_detection_size_category(detections, MetricTarget.BOXES)
    else:
        raise

Prevention

When it happens

Trigger: Calling get_detection_size_category(dets, MetricTarget.ORIENTED_BOUNDING_BOXES) on Detections built without the ORIENTED_BOX_COORDINATES data entry; using a non-OBB connector (plain detector) with an OBB metric target.

Common situations: Evaluating OBB predictions from a detector that does not produce rotated boxes; forgetting to pass data={ORIENTED_BOX_COORDINATES: corners} when hand-building Detections; dropping the data dict during filtering/serialization.

Related errors


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/95ffcbdb5b77009c. Report an issue: GitHub.