Skip to content

Fix OBB IoU for non-square canvases#2282

Open
RitwijParmar wants to merge 1 commit into
roboflow:developfrom
RitwijParmar:codex/fix-obb-iou-metrics
Open

Fix OBB IoU for non-square canvases#2282
RitwijParmar wants to merge 1 commit into
roboflow:developfrom
RitwijParmar:codex/fix-obb-iou-metrics

Conversation

@RitwijParmar
Copy link
Copy Markdown

Summary

  • fix oriented_box_iou_batch canvas sizing so x coordinates determine width and y coordinates determine height
  • add a scale-invariance regression for non-square oriented boxes
  • add downstream metric coverage proving perfect non-square OBB predictions score correctly for Precision, Recall, F1, mAP, and mAR

Fixes #2278.

Why this matters

OBB evaluation currently rasterizes polygons onto a canvas with width/height swapped. For non-square extents this can clip the polygons away and return zero IoU, which then makes otherwise correct OBB detections look like complete failures across the metrics stack. This is especially painful for real-world CV datasets where rotated boxes are common for aerial imagery, floorplans, traffic scenes, and industrial inspection.

Tests

  • .venv/bin/python -m ruff check src/supervision/detection/utils/iou_and_nms.py tests/detection/utils/test_iou_and_nms.py tests/metrics/test_mean_average_precision.py tests/metrics/test_oriented_bounding_box_metrics.py
  • .venv/bin/python -m pytest tests/detection/utils/test_iou_and_nms.py::test_oriented_box_iou_batch_is_invariant_to_non_square_scaling tests/metrics/test_oriented_bounding_box_metrics.py
  • .venv/bin/python -m pytest tests/detection/utils/test_iou_and_nms.py tests/metrics/test_oriented_bounding_box_metrics.py tests/metrics/test_mean_average_precision.py tests/metrics/test_mean_average_recall.py tests/metrics/test_precision.py tests/metrics/test_recall.py tests/metrics/test_f1_score.py

@RitwijParmar RitwijParmar requested a review from SkalskiP as a code owner May 29, 2026 17:47
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 29, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: oriented_box_iou_batch returns 0 for non-square inputs, breaking all OBB metrics

2 participants