-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(pypdfium2): Fix OCR bounding box misalignment caused by mismatched rotation metadata #2039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ DCO Check Passed Thanks @AndrewTsai0406, all your commits are properly signed off. 🎉 |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 Require two reviewer for test updatesThis rule is failing.When test data is updated, we require two reviewers
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: AndrewTsai0406 <tsai247365@gmail.com>
Signed-off-by: AndrewTsai0406 <tsai247365@gmail.com>
Signed-off-by: AndrewTsai0406 <tsai247365@gmail.com>
2a95dbd
to
ff094b1
Compare
Signed-off-by: AndrewTsai0406 <tsai247365@gmail.com>
The result of ocr is usually not deterministic, can anyone help me with testing please.😢 doc_pred = DoclingDocument(schema_name='DoclingDocument', version='1.5.0', name='ocr_test_rotation_mismatch', origin=DocumentOrig...], key_value_items=[], form_items=[], pages={1: PageItem(size=Size(width=595.0, height=842.0), image=None, page_no=1)})
doc_true = DoclingDocument(schema_name='DoclingDocument', version='1.5.0', name='ocr_test_rotation_mismatch', origin=DocumentOrig...], key_value_items=[], form_items=[], pages={1: PageItem(size=Size(width=595.0, height=842.0), image=None, page_no=1)})
fuzzy = True
def verify_docitems(doc_pred: DoclingDocument, doc_true: DoclingDocument, fuzzy: bool):
> assert len(doc_pred.texts) == len(doc_true.texts), "Text lengths do not match."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E AssertionError: Text lengths do not match.
tests/verify_utils.py:231: AssertionError |
I fixed the OCR bounding box misalignment issue by reading the rotation metadata from scanned PDF pages and applying the necessary adjustments in the pypdfium2 backend. This ensures that bounding boxes align correctly with the visually rotated pages during OCR detection.
Issue resolved by this Pull Request:
Resolves #2038
Checklist: