Repository navigation
feat(core,ocr-tesseract): read scanned PDFs by OCR (extension 0.8.0) - #311
Merged
Merged
Conversation
…request
A request for a PDF takes "ocr": true or { languages, always, dpi }.
Pages with no text layer are rendered at the scan's own resolution
(150 to 300 dpi), cleaned (background flattened, straightened, and
binarized when the first read is poor), read by Tesseract and handed on
as positioned text runs, so table, region and section work on a scan.
The engine is the new @opencraw/ocr-tesseract package, loaded when a
recipe asks for it and bundled in the extension.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TjR6eM2tUwU3NGnKXsmEap
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TjR6eM2tUwU3NGnKXsmEap
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TjR6eM2tUwU3NGnKXsmEap
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TjR6eM2tUwU3NGnKXsmEap
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
A
requestfor a PDF takes"ocr": trueor{ languages?, always?, dpi? }. Pages with no text layer are read by OCR and their words become the same positioned cells a text layer gives, sotable,regionandsectionwork on scans.@opencraw/core:pdf-ocrslice (OCR contract, page rendering with pdf.js +@napi-rs/canvas, words to runs),ocron the request step, schema, docs. A scan read withoutocrnow says how to ask for it.@opencraw/ocr-tesseract: Tesseract (WebAssembly, bundled English model; other languages from@tesseract.js-data/<code>). Each page is cleaned first (background flattening, deskew, and a second adaptive-binarize + median pass when the first read is poor); word boxes map back to the original page.Measured
Rendering at the scan's native dpi (150 to 300) matters: upsampling a soft 144 dpi scan to 300 read nothing. The tilted, shaded fixture read nothing with the plain cleaning and reads with the second pass (one character off:
8,0%as8,09). The per-pixel loops avoidMath.*calls, which cost ~100x more inside Jest (cleanup 14 s to 0.3 s).Test plan
ocr-tesseractsuite (17 tests, real Tesseract against generated fixtures) and afile:request withocr: trueend to endnx affectedlint/test/typecheck🤖 Generated with Claude Code
https://claude.ai/code/session_01TjR6eM2tUwU3NGnKXsmEap