Skip to content

[utils] Return the corners of bbox_to_polygon in order around the box - #2188

Merged
felixdittrich92 merged 2 commits into
mindee:mainfrom
RavSinghChandan:bbox-to-polygon-corner-order
Oct 30, 2026
Merged

felixdittrich92 merged 2 commits into
mindee:mainfrom
RavSinghChandan:bbox-to-polygon-corner-order

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

bbox_to_polygon(((0, 0), (1, 1))) returned ((0, 0), (1, 0), (0, 1), (1, 1)): top left, top right, bottom left, bottom right. Read as a polygon, those corners cross over each other, so cv2.contourArea of the converted 10x10 box is 0 instead of 100, and drawing it gives a bow tie.

It now returns top left, top right, bottom right, bottom left, the order the dataset loaders use for their polygons. Nothing inside doctr calls it, and polygon_to_bbox takes the min/max, so a round trip gives the same box as before

@felixdittrich92 felixdittrich92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @RavSinghChandan thanks for the PR 👍

One small update afterwards can be merged

Comment thread tests/common/test_utils_geometry.py Outdated
@felixdittrich92 felixdittrich92 self-assigned this Oct 29, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 29, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement module: utils Related to doctr.utils ext: tests Related to tests folder labels Oct 29, 2026
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Thanks! Updated the input polygon to the same corner order (top left, top right, bottom right, bottom left).

@felixdittrich92
felixdittrich92 merged commit 5f3ba75 into mindee:main Oct 30, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext: tests Related to tests folder module: utils Related to doctr.utils type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants