OnDeviceOcrEngine class

A PdfOcrEngine that recognizes pages on device, with no network call at recognition time - the model is downloaded once (see PdfOcrModelManager) and then runs locally.

The page geometry and span mapping are OcrRunnerEngine's; this adds the native, downloaded-model construction.

Use OnDeviceOcrEngine.fromDownloadedModel for the batteries-included path (PP-OCR on ONNX Runtime from a downloaded PdfOcrModel), or the default constructor to plug in any runner.

Inheritance

Constructors

OnDeviceOcrEngine(OcrModelRunner runner, {double minConfidence = 0})

Properties

hashCode → int
The hash code for this object.
no setterinherited
minConfidence → double
Lines below this confidence are dropped before mapping.
finalinherited
runner → OcrModelRunner
The inference backend.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → Future<void>
Releases the backend.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recognize(PdfOcrPageImage page) → Future<List<PdfOcrSpan>>
Recognizes the text on page. Returns one PdfOcrSpan per word (or line) with its user-space bounds and confidence.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fromDownloadedModel(PdfOcrModelManager manager, PdfOcrModel model, {double minConfidence = 0, bool useWorkerIsolate = true}) → Future<OnDeviceOcrEngine>
Builds an engine that runs model from files already downloaded by manager on ONNX Runtime. Throws PdfOcrModelException if the model is not downloaded. Inference runs on a long-lived worker isolate by default; set useWorkerIsolate false only to debug it on the calling isolate.
pixelRatioFor(PdfPage page, {double target = 3, int maxSidePixels = 4000}) → double
See OcrRunnerEngine.pixelRatioFor.
override