pub struct OcrEngine { /* private fields */ }Expand description
A loaded, warm OCR engine.
Build once on a dedicated worker thread; reuse across slides. DirectML sessions are GPU-state-bound — keep on the same thread.
Implementations§
Source§impl OcrEngine
impl OcrEngine
Sourcepub fn load(model_dir: &Path) -> Result<Self, OcrError>
pub fn load(model_dir: &Path) -> Result<Self, OcrError>
Load using the currently characterized manifest. This deliberately fails closed until its conflicting model provenance label is resolved.
Sourcepub fn load_with_manifest(
model_dir: &Path,
manifest: &OcrArtifactManifest,
) -> Result<Self, OcrError>
pub fn load_with_manifest( model_dir: &Path, manifest: &OcrArtifactManifest, ) -> Result<Self, OcrError>
Load det + rec sessions from an explicit, verified model directory.
Probes DirectML first on Windows and records any CPU fallback.
Expected files:
<model_dir>/det.onnxdetector ONNX<model_dir>/rec.onnxrecognizer ONNX<model_dir>/en_dict.txtcharacter dictionary (UTF-8, one char/line)
pub fn provider_diagnostics(&self) -> &[ProviderDiagnostic]
Sourcepub fn run(&mut self, img: &RgbImage) -> Result<String, OcrError>
pub fn run(&mut self, img: &RgbImage) -> Result<String, OcrError>
OCR a pre-loaded RGB image; returns newline-joined text.
Sourcepub fn run_lines(&mut self, img: &RgbImage) -> Result<Vec<OcrLine>, OcrError>
pub fn run_lines(&mut self, img: &RgbImage) -> Result<Vec<OcrLine>, OcrError>
OCR with per-line geometry: one OcrLine per visual line, rect =
union of the line’s detected boxes normalized to the image (top-left
origin), confidence = mean CTC character score when the recognizer
emits probabilities.
Auto Trait Implementations§
impl !RefUnwindSafe for OcrEngine
impl !UnwindSafe for OcrEngine
impl Freeze for OcrEngine
impl Send for OcrEngine
impl Sync for OcrEngine
impl Unpin for OcrEngine
impl UnsafeUnpin for OcrEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more