Reference · Callback interface · lib.rs

TextRecognizer Callback interface

The one thing a platform has to bring for Texterkennung: words in a picture (Apple: Vision, Windows: Windows.Media.Ocr). Everything around it, from rendering the page to writing the invisible text, is the engine's.

protocol TextRecognizer {
    func recognize(rgba: Data, width: UInt32, height: UInt32, language: String) -> [RecognizedWord]
    func progress(done: UInt32, total: UInt32)
}

Methods you implement

recognize

language: "auto", "de", "en"

func recognize(rgba: Data, width: UInt32, height: UInt32, language: String) -> [RecognizedWord]

Parameters

NameTypeSwift / C#
rgbaVec<u8>rgba
widthu32width
heightu32height
languageStringlanguage

Returns

Vec<RecognizedWord>

Errors

Does not throw.

progress

done of total pages read

func progress(done: UInt32, total: UInt32)

Parameters

NameTypeSwift / C#
doneu32done
totalu32total

Returns

Nothing.

Errors

Does not throw.

Used by

recognize_pages, run_tool, run_tool_batch, run_workflow, upright_turns

Signatures are generated from the engine’s code. Swift is checked against the generated bindings; C# follows the bindings generator’s naming rules.