{"record":{"id":"2a49a7c6b1ddfe59","repo":"roboflow/supervision","slug":"name-has-shape-arr-shape-expected-n-8-fo","errorCode":null,"errorMessage":"`{name}` has shape {arr.shape}; expected (N, 8) for flat YOLO format or (N, 4, 2) for corner format.","messagePattern":"`(.+?)` has shape (.+?); expected \\(N, 8\\) for flat YOLO format or \\(N, 4, 2\\) for corner format\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/utils/iou_and_nms.py","lineNumber":541,"sourceCode":"        ```pycon\n        >>> import numpy as np\n        >>> import supervision as sv\n        >>> a = np.array([[[0, 0], [2, 0], [2, 2], [0, 2]]], dtype=np.float32)\n        >>> b = np.array([[[1, 0], [3, 0], [3, 2], [1, 2]]], dtype=np.float32)\n        >>> sv.oriented_box_iou_batch(a, b)  # doctest: +ELLIPSIS\n        array([[0.333...]])\n\n        ```\n    \"\"\"\n\n    for name, arr in ((\"boxes_true\", boxes_true), (\"boxes_detection\", boxes_detection)):\n        if arr.ndim == 3 and arr.shape[1:] != (4, 2):\n            raise ValueError(\n                f\"`{name}` has shape {arr.shape}; expected (N, 4, 2) \"\n                f\"— each box must have exactly 4 corners with (x, y) coordinates.\"\n            )\n        elif arr.ndim == 2 and arr.shape[1] != 8:\n            raise ValueError(\n                f\"`{name}` has shape {arr.shape}; expected (N, 8) for flat \"\n                f\"YOLO format or (N, 4, 2) for corner format.\"\n            )\n        elif arr.ndim not in (2, 3):\n            raise ValueError(\n                f\"`{name}` must be 2-D (N, 8) or 3-D (N, 4, 2), got shape {arr.shape}.\"\n            )\n\n    if overlap_metric == OverlapMetric.IOU:\n        normalize_by_union = True\n    elif overlap_metric == OverlapMetric.IOS:\n        normalize_by_union = False\n    else:\n        raise ValueError(\n            f\"overlap_metric {overlap_metric} is not supported, \"\n            \"only 'IOU' and 'IOS' are supported\"\n        )\n","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/utils/iou_and_nms.py#L523-L559","documentation":"`oriented_box_iou_batch` accepts 2-D input only in the flat YOLO-OBB format (N, 8) — eight numbers per box describing the 4 corners. This error fires when a 2-D array has any other column count (e.g. (N, 4) axis-aligned xyxy, (N, 5) xywha, (N, 6)). The function cannot guess which of the 8 corner coordinates are missing, so it rejects the layout.","triggerScenarios":"Passing `detections.xyxy` (N, 4) directly; passing rotated boxes in (x, y, w, h, angle) format (N, 5); slicing an (N, 8) array down to fewer columns before the call.","commonSituations":"Mixing axis-aligned supervision workflows with oriented-box ones; converting from a model that uses cv2 RotatedRect (5 floats) and assuming supervision takes it verbatim.","solutions":["Convert (x, y, w, h, angle) to 8-float corners with `cv2.boxPoints(cv2.RotatedRect(...))` and stack into (N, 8) or (N, 4, 2).","For axis-aligned boxes use `box_iou_batch`, not `oriented_box_iou_batch`.","Double-check `arr.shape == (N, 8)` or `arr.shape == (N, 4, 2)` immediately before calling."],"exampleFix":"# before\nious = sv.oriented_box_iou_batch(dets.xyxy, dets.xyxy)  # (N, 4) -> ValueError\n\n# after\nious = sv.box_iou_batch(dets.xyxy, dets.xyxy)","handlingStrategy":"validation","validationCode":"arr = np.asarray(arr, dtype=float)\nif arr.ndim == 2 and arr.shape[1] != 8:\n    if arr.shape[1] == 4:\n        raise TypeError('axis-aligned xyxy: use box_iou_batch instead')\n    raise ValueError('need (N, 8) or (N, 4, 2)')","typeGuard":"def is_obb_flat(arr) -> bool:\n    return np.asarray(arr).ndim == 2 and np.asarray(arr).shape[1] == 8","tryCatchPattern":null,"preventionTips":["Convert (x,y,w,h,angle) with cv2.boxPoints before calling oriented APIs.","Use box_iou_batch for axis-aligned boxes."],"tags":["shape-validation","oriented-boxes","iou","numpy","detection"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}