Skip to content

Conversation

@arda92a
Copy link

@arda92a arda92a commented Nov 28, 2025

Fix OBB Corner Detection in convert_yolo_obb_to_annotation

Problem

The previous implementation calculated the top-left corner of oriented bounding boxes (OBBs) using geometric transformations from the center point. This approach could produce incorrect corner positions, especially for rotated boxes, as it relied on assumptions about coordinate ordering that may not hold for all YOLO OBB outputs.

Solution

This PR refactors the corner detection logic to explicitly identify the actual top-left corner from the provided coordinates:

  1. Sort by X-coordinate to separate left-side points from right-side points
  2. Identify top-left corner as the left-most point with the smallest Y-coordinate
  3. Identify bottom-left corner as the left-most point with the largest Y-coordinate
  4. Identify top-right corner as the right-most point with the smallest Y-coordinate
  5. Calculate dimensions directly from corner-to-corner distances (TL→TR for width, TL→BL for height)

Changes

  • Replaced center-based calculation with explicit corner detection
  • Width is now calculated as the distance between top-left and top-right corners
  • Height is now calculated as the distance between top-left and bottom-left corners
  • Rotation angle calculation remains unchanged (angle between top-left and top-right)

@arda92a arda92a changed the title Fix OBB → Label Studio polygon conversion fix: OBB corner detection in convert_yolo_obb_to_annotation Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant