{"record":{"id":"95ffcbdb5b77009c","repo":"roboflow/supervision","slug":"detections-oriented-bounding-boxes-are-not-availab","errorCode":null,"errorMessage":"Detections oriented bounding boxes are not available","messagePattern":"Detections oriented bounding boxes are not available","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/utils/object_size.py","lineNumber":315,"sourceCode":"        areas = np.asarray(area_data, dtype=np.float64)\n        if len(areas.shape) != 1 or len(areas) != len(detections):\n            raise ValueError(\n                \"Detection area metadata must be shaped (N,) and aligned \"\n                \"with detections\"\n            )\n        return get_area_size_category(areas)\n\n    if metric_target == MetricTarget.BOXES:\n        return get_bbox_size_category(detections.xyxy)\n    if metric_target == MetricTarget.MASKS:\n        mask = detections.mask\n        if mask is None:\n            raise ValueError(\"Detections mask is not available\")\n        return get_mask_size_category(mask)\n    if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:\n        oriented_box_coordinates = detections.data.get(ORIENTED_BOX_COORDINATES)\n        if oriented_box_coordinates is None:\n            raise ValueError(\"Detections oriented bounding boxes are not available\")\n        return get_obb_size_category(\n            cast(\n                npt.NDArray[np.number],\n                np.asarray(oriented_box_coordinates, dtype=np.float32),\n            )\n        )\n    raise ValueError(\"Invalid metric type\")\n","sourceCodeStart":297,"sourceCodeEnd":323,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/utils/object_size.py#L297-L323","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Attach the corners: sv.Detections(..., data={ORIENTED_BOX_COORDINATES: corners}) with corners shaped (N, 4, 2)","Use an OBB-aware model connector that populates the field automatically","Or switch the metric target to MetricTarget.BOXES if rotation is not needed"],"exampleFix":"# before\ndets = sv.Detections(xyxy=boxes)\nget_detection_size_category(dets, MetricTarget.ORIENTED_BOUNDING_BOXES)\n\n# after\nfrom supervision.config import ORIENTED_BOX_COORDINATES\n\ndets = sv.Detections(\n    xyxy=boxes,\n    data={ORIENTED_BOX_COORDINATES: obb_corners},  # (N, 4, 2)\n)\nget_detection_size_category(dets, MetricTarget.ORIENTED_BOUNDING_BOXES)","handlingStrategy":"type-guard","validationCode":"from supervision.config import ORIENTED_BOX_COORDINATES\n\nhas_obb = (\n    ORIENTED_BOX_COORDINATES in detections.data\n    and np.asarray(detections.data[ORIENTED_BOX_COORDINATES]).shape[1:] == (4, 2)\n)\nif not has_obb:\n    raise ValueError('OBB metric needs ORIENTED_BOX_COORDINATES data')","typeGuard":"import numpy as np\nfrom supervision.config import ORIENTED_BOX_COORDINATES\n\ndef has_obb_coordinates(dets: sv.Detections) -> bool:\n    \"\"\"True when detections carry (N, 4, 2) oriented box corners.\"\"\"\n    corners = dets.data.get(ORIENTED_BOX_COORDINATES)\n    return corners is not None and np.asarray(corners).ndim == 3","tryCatchPattern":"try:\n    cats = get_detection_size_category(detections, MetricTarget.ORIENTED_BOUNDING_BOXES)\nexcept ValueError as e:\n    if 'oriented bounding boxes are not available' in str(e):\n        cats = get_detection_size_category(detections, MetricTarget.BOXES)\n    else:\n        raise","preventionTips":["Use OBB-aware connectors that populate ORIENTED_BOX_COORDINATES automatically","Verify the data key survives any Detections filtering/serialization step"],"tags":["metrics","object-size","obb","missing-data"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}