VerticalOCRModule
TypeScript API implementation of the useVerticalOCR hook.
API Reference
- For detailed API Reference for
VerticalOCRModulesee:VerticalOCRModuleAPI Reference. - For all alphabets available in ocr out-of-the-box in React Native ExecuTorch see: OCR Supported Alphabets.
High Level Overview
import { VerticalOCRModule, OCR_ENGLISH } from 'react-native-executorch';
const imageUri = 'path/to/image.png';
// Creating an instance
const verticalOCRModule = new VerticalOCRModule();
// Loading the model
await verticalOCRModule.load(OCR_ENGLISH);
// Running the model
const detections = await verticalOCRModule.forward(imageUri);
Methods
All methods of VerticalOCRModule are explained in details here: VerticalOCRModule API Reference
Loading the model
To load the model, use the load method. It accepts an object:
-
model- Object containing:detectorSource- Location of the used detector.recognizerSource- Location of the used recognizer.language- Language used in OCR.
-
independentCharacters- Flag indicating to either treat characters as independent or not. -
onDownloadProgressCallback- Callback to track download progress.
This method returns a promise, which can resolve to an error or void.
For more information on loading resources, take a look at loading models page.
Running the model
To run the model, you can use the forward method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The method returns a promise, which can resolve either to an error or an array of OCRDetection objects. Each object contains coordinates of the bounding box, the label of the detected object, and the confidence score.