Class: OCRModule
Defined in: modules/computer_vision/OCRModule.ts:11
Module for Optical Character Recognition (OCR) tasks.
Methods
delete()
delete():
void
Defined in: modules/computer_vision/OCRModule.ts:95
Release the memory held by the module. Calling forward afterwards is invalid.
Note that you cannot delete model while it's generating.
Returns
void
forward()
forward(
imageSource):Promise<OCRDetection[]>
Defined in: modules/computer_vision/OCRModule.ts:87
Executes the model's forward pass, where imageSource can be a fetchable resource or a Base64-encoded string.
Parameters
imageSource
string
The image source to be processed.
Returns
Promise<OCRDetection[]>
The OCR result as a OCRDetection[].
fromCustomModel()
staticfromCustomModel(detectorSource,recognizerSource,language,onDownloadProgress?):Promise<OCRModule>
Defined in: modules/computer_vision/OCRModule.ts:65
Creates an OCR instance with a user-provided model binary.
Use this when working with a custom-exported OCR model.
Internally uses 'custom' as the model name for telemetry.
Parameters
detectorSource
A fetchable resource pointing to the text detector model binary.
recognizerSource
A fetchable resource pointing to the text recognizer model binary.
language
The language for the OCR model.
"abq" | "ady" | "af" | "ava" | "az" | "be" | "bg" | "bs" | "chSim" | "che" | "cs" | "cy" | "da" | "dar" | "de" | "en" | "es" | "et" | "fr" | "ga" | "hr" | "hu" | "id" | "inh" | "ic" | "it" | "ja" | "kbd" | "kn" | "ko" | "ku" | "la" | "lbe" | "lez" | "lt" | "lv" | "mi" | "mn" | "ms" | "mt" | "nl" | "no" | "oc" | "pi" | "pl" | "pt" | "ro" | "ru" | "rsCyrillic" | "rsLatin" | "sk" | "sl" | "sq" | "sv" | "sw" | "tab" | "te" | "tjk" | "tl" | "tr" | "uk" | "uz" | "vi"
onDownloadProgress?
(progress) => void
Optional callback to monitor download progress, receiving a value between 0 and 1.
Returns
Promise<OCRModule>
A Promise resolving to an OCRModule instance.
Remarks
The native model contract for this method is not formally defined and may change between releases. Refer to the native source code for the current expected tensor interface.
fromModelName()
staticfromModelName(namedSources,onDownloadProgress?):Promise<OCRModule>
Defined in: modules/computer_vision/OCRModule.ts:29
Creates an OCR instance for a built-in model.
Parameters
namedSources
An object specifying the model name, detector source, recognizer source, and language.
detectorSource
language
"abq" | "ady" | "af" | "ava" | "az" | "be" | "bg" | "bs" | "chSim" | "che" | "cs" | "cy" | "da" | "dar" | "de" | "en" | "es" | "et" | "fr" | "ga" | "hr" | "hu" | "id" | "inh" | "ic" | "it" | "ja" | "kbd" | "kn" | "ko" | "ku" | "la" | "lbe" | "lez" | "lt" | "lv" | "mi" | "mn" | "ms" | "mt" | "nl" | "no" | "oc" | "pi" | "pl" | "pt" | "ro" | "ru" | "rsCyrillic" | "rsLatin" | "sk" | "sl" | "sq" | "sv" | "sw" | "tab" | "te" | "tjk" | "tl" | "tr" | "uk" | "uz" | "vi"
modelName
"ocr-abq" | "ocr-ady" | "ocr-af" | "ocr-ava" | "ocr-az" | "ocr-be" | "ocr-bg" | "ocr-bs" | "ocr-chSim" | "ocr-che" | "ocr-cs" | "ocr-cy" | "ocr-da" | "ocr-dar" | "ocr-de" | "ocr-en" | "ocr-es" | "ocr-et" | "ocr-fr" | "ocr-ga" | "ocr-hr" | "ocr-hu" | "ocr-id" | "ocr-inh" | "ocr-ic" | "ocr-it" | "ocr-ja" | "ocr-kbd" | "ocr-kn" | "ocr-ko" | "ocr-ku" | "ocr-la" | "ocr-lbe" | "ocr-lez" | "ocr-lt" | "ocr-lv" | "ocr-mi" | "ocr-mn" | "ocr-ms" | "ocr-mt" | "ocr-nl" | "ocr-no" | "ocr-oc" | "ocr-pi" | "ocr-pl" | "ocr-pt" | "ocr-ro" | "ocr-ru" | "ocr-rsCyrillic" | "ocr-rsLatin" | "ocr-sk" | "ocr-sl" | "ocr-sq" | "ocr-sv" | "ocr-sw" | "ocr-tab" | "ocr-te" | "ocr-tjk" | "ocr-tl" | "ocr-tr" | "ocr-uk" | "ocr-uz" | "ocr-vi"
recognizerSource
onDownloadProgress?
(progress) => void
Optional callback to monitor download progress, receiving a value between 0 and 1.
Returns
Promise<OCRModule>
A Promise resolving to an OCRModule instance.
Example
import { OCRModule, OCR_ENGLISH } from 'react-native-executorch';
const ocr = await OCRModule.fromModelName(OCR_ENGLISH);