Skip to content

Conversation

AshAnand34
Copy link

Description

This pull request introduces support for evaluating oriented bounding boxes (OBBs) in the confusion matrix calculations within the supervision library. The changes include adding a new parameter to enable OBB support, modifying the IoU calculation logic, and adding comprehensive tests to validate the functionality.

Enhancements to IoU and Confusion Matrix Calculations:

  • Added the use_oriented_boxes parameter to the from_detections, from_tensors, and evaluate_detection_batch methods, allowing users to toggle between axis-aligned and oriented bounding box IoU calculations.
  • Updated the IoU computation logic to use oriented_box_iou_batch when use_oriented_boxes is set to True. This ensures accurate IoU calculations for OBBs.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

Added a new test file, test/metrics/test_confusion_matrix_obb.py, to validate the confusion matrix functionality with and without OBB support. These tests include scenarios for perfect matches and slight offsets between predictions and ground truth.

Docs

  • Docs updated? What were the changes:
  • Enhanced the example in the from_detections method's docstring to demonstrate how to use the use_oriented_boxes parameter with both axis-aligned and oriented bounding boxes.

Copy link
Contributor

@soumik12345 soumik12345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AshAnand34, thanks for the PR!
Please make sure the tests are passing and not broken.

from supervision.metrics.detection import ConfusionMatrix


def test_confusion_matrix_with_obb():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case is not passing with the current code.

classes: List[str],
conf_threshold: float = 0.3,
iou_threshold: float = 0.5,
use_oriented_boxes: bool = False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option should also be supported for ConfusionMatrix.benchmark.

@galafis
Copy link

galafis commented Sep 27, 2025

Excellent initiative on adding OBB support to confusion matrix evaluation! This enhancement addresses a critical gap for oriented object detection benchmarking. The implementation approach is solid and follows good software engineering practices.

Technical Assessment:

  1. Architecture: The use_oriented_boxes parameter design is clean and maintains backward compatibility. The conditional IoU logic between box_iou_batch and oriented_box_iou_batch is well-structured.

  2. Implementation Strengths:

    • Comprehensive parameter propagation through from_detections, from_tensors, and evaluate_detection_batch
    • Dedicated test suite for OBB scenarios
    • Clear documentation updates with practical examples
    • Non-breaking change design
  3. Addressing Review Feedback:

    • @soumik12345's suggestion to add OBB support to ConfusionMatrix.benchmark is valid and should be implemented
    • The failing test case indicates potential issues with the current oriented IoU implementation

Technical Recommendations:

  1. Test Debugging: Investigate the failing test case by:

    • Verifying oriented_box_iou_batch output for your test geometries
    • Adding debug prints to compare expected vs actual IoU values
    • Ensuring OBB format consistency (center, width, height, angle representation)
  2. Benchmark Method: Add the use_oriented_boxes parameter to the benchmark classmethod for complete API consistency

  3. Edge Cases: Consider testing scenarios with:

    • Various rotation angles (0°, 45°, 90°, etc.)
    • Degenerate cases (zero area boxes)
    • High-overlap oriented boxes at different angles

This enhancement will significantly benefit the computer vision community working with oriented detection tasks. The approach aligns well with modern evaluation practices.

Best regards,
Gabriel

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.

3 participants