Repository navigation
[io] Resolve rotated block geometries from lines read back from an export - #2181
Merged
felixdittrich92 merged 1 commit intoOct 26, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2181 +/- ##
=======================================
Coverage 97.68% 97.69%
=======================================
Files 170 170
Lines 10744 10744
=======================================
+ Hits 10495 10496 +1
+ Misses 249 248 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
felixdittrich92
approved these changes
Oct 26, 2026
felixdittrich92
left a comment
Collaborator
There was a problem hiding this comment.
LGTM @RaphaelFakhri Thanks 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Block.__init__picks the box resolution from the type of the first line geometry:resolve_enclosing_rbboxwhen it is anp.ndarray,resolve_enclosing_bboxotherwise. A rotated line geometry read back withfrom_dict(fromexport()or a JSON file) is a nested list, so the 4 points go toresolve_enclosing_bbox, which returns a straight((xmin, ymin), (xmax, ymax))box.Page.export()rebuilds the blocks in reading order without passing a geometry. As a result, the rotated block polygons of a page loaded from a dict (e.g. from anocr_predictor(assume_straight_pages=False)result saved as JSON) become straight boxes in the next export.Repro:
Before: the first line prints the rotated polygon
[[0.1, 0.1], [0.415, 0.205], [0.35, 0.4], [0.035, 0.295]], the second prints the straight box[[0.05, 0.1], [0.4, 0.4]].After: both lines print the rotated polygon.
Changes:
len(geometry) == 4), likeLine.__init__already does for wordstest_block_rotated_lines_from_dict(block built from a line loaded withfrom_dict, then a page export, JSON round trip and re-export); it fails without the fixChecks:
pytest tests/common(708 passed),ruff check,ruff format --check,mypy doctr/io/elements.py(no new errors).Fixes #2180