Skip to main content

Module ocr

Module ocr 

Source
Expand description

OCR fallback for scanned/image PDFs with no text layer — the bundled PP-OCRv6 pipeline, natively in Rust. Two ONNX stages: DB detection (image → text-region probability map) and CRNN recognition (each cropped region → text via CTC). Pages are rasterized with poppler pdftoppm. Gated behind the ocr feature (implies docs/onnx).

Detection post-processing is a pragmatic axis-aligned variant: binarize the prob map, take connected components’ bounding boxes (documents are near-horizontal), unclip slightly, crop, recognize.

Structs§

OcrEngine

Functions§

ocr_pdf
OCR a PDF by rasterizing its pages (poppler pdftoppm, 150 dpi) and running the PP-OCRv6 pipeline. Returns concatenated page text, or None if rasterization/models are unavailable.