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§
fn name(&self) -> &'static str
Sourcefn recognize(
&self,
image: &[u8],
options: &OcrOptions,
) -> SpdfResult<Vec<OcrResult>>
fn recognize( &self, image: &[u8], options: &OcrOptions, ) -> SpdfResult<Vec<OcrResult>>
Run OCR on an image (PNG/JPEG bytes).
Provided Methods§
Sourcefn recognize_batch(
&self,
images: &[&[u8]],
options: &OcrOptions,
) -> SpdfResult<Vec<Vec<OcrResult>>>
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.