supervision/tests/detection
Agis Kounelis ace3ebd03e
fix(detection): make `Detections.area` OBB-aware (#2306)
* fix(detection): make Detections.area OBB-aware

When detections carry ORIENTED_BOX_COORDINATES (the four xyxyxyxy corners),
the area property returned the area of the derived axis-aligned bounding
box instead of the rotated body. The AABB overestimates by up to ~2x for a
45-degree rotation, which silently miscomputes downstream values — most
visibly the area-sorted z-ordering inside MaskAnnotator / HaloAnnotator,
and any user code that filters detections by area.

* docs(detection): use string literal in Detections.area doctest
* test(detection): single-line docstring on test_uses_oriented_box_corners_when_present
* fix(detection): validate (N,4,2) shape of OBB data field in Detections.area
* perf(detection): replace np.roll pair with cross-diagonal shoelace in Detections.area
* perf(detection): cast x/y slices to float64 instead of full corners array
* refactor(detection): extract obb_polygon_area to detection/utils/boxes.py
* test(detection): add test_raises_on_malformed_obb_coordinates_shape
* test(detection): assert per-branch dtype contract for Detections.area
* docs(detection): document OBB dispatch contract and dtype in Detections.area docstring

---------

Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-06-09 22:20:34 +02:00
..
tools refine(detection): make `with_nms` and `with_nmm` OBB-aware (#2303) 2026-06-09 13:11:09 +02:00
utils refine(detection): make `with_nms` and `with_nmm` OBB-aware (#2303) 2026-06-09 13:11:09 +02:00
__init__.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_compact_mask.py feat(compact_mask): add `resize()` method and benchmark stage (#2227) 2026-04-22 15:34:12 +02:00
test_compact_mask_integration.py feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159) 2026-04-13 11:10:12 +02:00
test_compact_mask_iou.py feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159) 2026-04-13 11:10:12 +02:00
test_core.py fix(detection): make `Detections.area` OBB-aware (#2306) 2026-06-09 22:20:34 +02:00
test_csv.py fix(sinks): slice list and tuple custom_data values per row (#2216) 2026-04-18 00:24:36 +02:00
test_from_adapters.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_from_sam.py Add support for SAM3 PVS output (#2152) 2026-02-19 17:09:31 +01:00
test_inference_slicer_compact.py feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159) 2026-04-13 11:10:12 +02:00
test_json.py fix(sinks): slice list and tuple custom_data values per row (#2216) 2026-04-18 00:24:36 +02:00
test_line_counter.py refactor docstrings in `scr/supervision/detection` (#2162) 2026-03-10 18:40:05 +01:00
test_polygon_zone_annotator.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_polygonzone.py fix: prevent single object from appearing in multiple polygon zones (#1991) 2026-03-10 21:19:09 +01:00
test_vlm.py fix: return empty int ndarray instead of None for class_id on empty VLM parse (#2239) 2026-05-19 14:31:44 +02:00