Skip to content

[utils] Scale a copy of the geometry in polygon_patch - #2198

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:polygon-patch-copy-geometry
Oct 30, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:polygon-patch-copy-geometry

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

polygon_patch scaled the polygon to absolute coordinates in place. A caller passing an array it keeps, e.g. create_obj_patch(word.geometry, page.dimensions) for a rotated word, got its relative geometry overwritten with pixel coordinates, and a second call scaled it again:

>>> geometry = np.array([[0.1, 0.1], [0.4, 0.1], [0.4, 0.2], [0.1, 0.2]])
>>> create_obj_patch(geometry, (100, 200))
>>> geometry
array([[20., 10.], [80., 10.], [80., 20.], [20., 20.]])

The patch is now built from a scaled copy, so the geometry passed in stays relative. Page exports store geometries as tuples, so visualize_page was not affected, and the patches are the same as before

@felixdittrich92 felixdittrich92 self-assigned this Oct 30, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 30, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement module: utils Related to doctr.utils ext: tests Related to tests folder labels Oct 30, 2026

@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.

Thanks 👍

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.75%. Comparing base (74e5759) to head (0e994df).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2198   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files         170      170           
  Lines       10969    10975    +6     
=======================================
+ Hits        10723    10729    +6     
  Misses        246      246           
Flag Coverage Δ
unittests 97.75% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@felixdittrich92
felixdittrich92 merged commit 2b683ac into mindee:main Oct 30, 2026
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