Skip to content

fix: enhance bounding box processing with rotation support#231

Merged
przemyslaw-aszkowski merged 1 commit intoPUTvision:develfrom
oguz-hanoglu:fix/rotated-bbox-postprocessing
Feb 2, 2026
Merged

fix: enhance bounding box processing with rotation support#231
przemyslaw-aszkowski merged 1 commit intoPUTvision:develfrom
oguz-hanoglu:fix/rotated-bbox-postprocessing

Conversation

@oguz-hanoglu
Copy link

Fixes #228

Summary

This PR adds rotation-aware intersection calculation to the non_max_kdtree method, fixing duplicate detection removal for Oriented Bounding Box (OBB) detections.

Problem

When using YOLO_ULTRALYTICS_OBB detector type, the non_max_kdtree post-processing step was not considering bounding box rotation. This could lead to incorrect removal of overlapping detections for rotated bounding boxes.

Changes

  • Added with_rot parameter to non_max_kdtree() method
  • Added _calculate_rotated_intersection_over_smaller_area() static method that uses QGIS geometry operations to compute intersection area for rotated rectangles
  • Updated the call site in remove_overlaping_detections() to pass with_rot flag

Testing

  • All existing unit tests pass (46 tests)
  • Tested manually with manual_test_map_processor_obb_yolo_ultralytics.py - correctly detects 2 planes

Known Limitations

  • I have not checked if the IoU calculation is correct with two specific polygons.

Related

Related to OBB detection support added in earlier PRs.
Note that as explained in #228, Detector.non_max_suppression_fast was already addressing the obb case with with_rot=True, but non_max_kdtree was missing with_rot=True implementation as also verified by @przemyslaw-aszkowski in #228 .

@oguz-hanoglu
Copy link
Author

The PR process has stopped for some reason that I do not know. Anything I can do @przemyslaw-aszkowski ?

@przemyslaw-aszkowski przemyslaw-aszkowski merged commit 71d0143 into PUTvision:devel Feb 2, 2026
1 of 2 checks passed
@przemyslaw-aszkowski
Copy link
Contributor

There is some issue with Ubunto20 pipeline, I merged the PR, thanks!

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.

Rotated BBox Postprocessing has missing implementation

2 participants