roboflow/supervision · error · ValueError

Expected {ORIENTED_BOX_COORDINATES} to contain {len(detectio

Error message

Expected {ORIENTED_BOX_COORDINATES} to contain {len(detections) * 8} elements (N={len(detections)} detections x 8 coordinates), but got {obb_arr.size}. Each OBB must be stored as [x1, y1, x2, y2, x3, y3, x4, y4].

What it means

Error "Expected {ORIENTED_BOX_COORDINATES} to contain {len(detections) * 8} elements (N={len(detections)} detections x 8 coordinates), but got {obb_arr.size}. Each OBB must be stored as [x1, y1, x2, y2, x3, y3, x4, y4]." thrown in roboflow/supervision.

Source

Thrown at src/supervision/metrics/detection.py:154

        )

    box_data: npt.NDArray[np.float32]
    if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:
        obb = detections.data.get(ORIENTED_BOX_COORDINATES)
        if obb is None:
            if len(detections) > 0:
                raise ValueError(
                    "ORIENTED_BOUNDING_BOXES requested, but "
                    f"{ORIENTED_BOX_COORDINATES} is missing from detections.data"
                )
            box_data = np.empty((0, 8), dtype=np.float32)
        else:
            obb_arr = np.asarray(obb, dtype=np.float32)
            # Normalize (N, 4, 2) → (N, 8) as produced by from_ultralytics.
            if obb_arr.ndim == 3 and obb_arr.shape[1:] == (4, 2):
                obb_arr = obb_arr.reshape(-1, 8)
            if obb_arr.size != len(detections) * 8:
                raise ValueError(
                    f"Expected {ORIENTED_BOX_COORDINATES} to contain "
                    f"{len(detections) * 8} elements "
                    f"(N={len(detections)} detections x 8 coordinates), "
                    f"but got {obb_arr.size}. "
                    "Each OBB must be stored as [x1, y1, x2, y2, x3, y3, x4, y4]."
                )
            box_data = obb_arr.reshape(-1, 8)
    else:
        box_data = np.asarray(detections.xyxy, dtype=np.float32)

    arrays_to_concat = [
        box_data,
        np.expand_dims(detections.class_id.astype(np.float32), 1),
    ]

    if with_confidence:
        if detections.confidence is None:
            raise ValueError(

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Store each OBB as [x1, y1, x2, y2, x3, y3, x4, y4] so the data has exactly N * 8 elements.
  2. Reshape the OBB array to (N, 8) or (N, 4, 2) consistently before assigning it to detections.data.

When it happens

Trigger: Thrown at src/supervision/metrics/detection.py:154 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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