Skip to main content

OcrEngine

Trait OcrEngine 

Source
pub trait OcrEngine: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn recognize(
        &self,
        image: &[u8],
        options: &OcrOptions,
    ) -> SpdfResult<Vec<OcrResult>>;

    // Provided method
    fn recognize_batch(
        &self,
        images: &[&[u8]],
        options: &OcrOptions,
    ) -> SpdfResult<Vec<Vec<OcrResult>>> { ... }
}
Expand description

OCR engine contract. Mirrors OcrEngine in liteparse/src/engines/ocr/interface.ts.

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn recognize( &self, image: &[u8], options: &OcrOptions, ) -> SpdfResult<Vec<OcrResult>>

Run OCR on an image (PNG/JPEG bytes).

Provided Methods§

Source

fn recognize_batch( &self, images: &[&[u8]], options: &OcrOptions, ) -> SpdfResult<Vec<Vec<OcrResult>>>

Default batch impl delegates to recognize sequentially. Engines with real batch APIs (e.g. a remote server that accepts a JSON array) should override for a meaningful throughput win.

Implementors§