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)
}public interface TextRecognizer {
RecognizedWord[] Recognize(byte[] rgba, uint width, uint height, string language);
void Progress(uint done, uint total);
}pub trait TextRecognizer: Send + Sync {
fn recognize(&self, rgba: Vec<u8>, width: u32, height: u32, language: String) -> Vec<RecognizedWord>;
fn progress(&self, done: u32, total: u32);
}Methods you implement
recognize
language: "auto", "de", "en"
func recognize(rgba: Data, width: UInt32, height: UInt32, language: String) -> [RecognizedWord]RecognizedWord[] Recognize(byte[] rgba, uint width, uint height, string language)pub fn recognize(&self, rgba: Vec<u8>, width: u32, height: u32, language: String) -> Vec<RecognizedWord>Parameters
| Name | Type | Swift / C# |
|---|---|---|
rgba | Vec<u8> | rgba |
width | u32 | width |
height | u32 | height |
language | String | language |
Returns
Vec<RecognizedWord>
Errors
Does not throw.
progress
done of total pages read
func progress(done: UInt32, total: UInt32)void Progress(uint done, uint total)pub fn progress(&self, done: u32, total: u32)Parameters
| Name | Type | Swift / C# |
|---|---|---|
done | u32 | done |
total | u32 | total |
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.