fix(ocr): make UVDoc output C-contiguous - #5179
Open
1443858742 wants to merge 1 commit into
Open
Conversation
|
Thanks for your contribution! |
1443858742
force-pushed
the
agent/uvdoc-contiguous-output
branch
from
July 26, 2026 10:50
2a6b3f6 to
25509fb
Compare
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.
What
Why
The current channel reversal returns a NumPy view with a negative channel
stride. The OCR pipeline then passes the full page to
cv2.warpPerspectiveonce per detected text region. OpenCV has to handle the incompatible layout
for every crop, which makes region cropping dominate OCR latency on
text-dense pages.
Converting the page once with
np.ascontiguousarraypreserves the currentBGR pixels while avoiding repeated downstream layout conversion.
Fixes #5178.
Validation
pytest -q tests/test_doc_preprocessor_pipeline.py: 4 passedC_CONTIGUOUS=True, and has no negative stridesA deterministic synthetic
1600x1132image with 200 perspective cropsmeasured:
In a separate 20-run warm OCR check on two text-dense pages, normalized OCR
output remained identical and end-to-end p50 changed from
1.330sto0.537sand from3.209sto1.172s.No private images or OCR text are included in this pull request.
Compatibility
There is no public API or model-behavior change. The no-unwarping path is
unchanged. If appropriate, this fix can also be backported to
release/3.7.