React Native
On-Device AI Scanning (OCR)
The Vision SDK allows for on-device AI scanning (OCR), enabling offline extraction of structured information from documents such as shipping labels. This is ideal when low latency and offline functionality are critical, such as in warehouse and logistics environments.
🛠️ Step 1: Preparing On-Device OCR
Before using the on-device OCR, you must prepare the model using the imperative method:configureOnDeviceModel and set ocrMode prop to 'onDevice'. This ensures the necessary AI models are downloaded and ready to use.
Model Size and Type Configuration
If you want Vision SDK to automatically determine the best model size based on your PackageX subscription:
Please note that you need to wait before the model is successfully downloaded and configured. This would be a one time operation only. More on this in the next section.
⚙️ Android Model Execution Provider Configuration
For Android devices, you can configure the OCR model execution provider to optimize performance based on device capabilities using the modelExecutionProviderAndroid prop.
Available Providers
CPU(Default): Uses CPU for model execution - most compatible but slowerNNAPI: Uses Android Neural Networks API for hardware accelerationXNNPACK: Uses XNNPACK backend for optimized CPU execution
Provider Selection Guidelines
- Use
CPUfor maximum compatibility across all Android devices - Use
NNAPIfor newer Android devices (API level 27+) with neural processing units - Use
XNNPACKfor optimized CPU performance on devices without dedicated AI hardware
The modelExecutionProviderAndroid prop only affects Android devices. iOS devices automatically use the most appropriate execution method.
🧩 Model download progress events
You need to set onModelDownloadProgress event handler to receive download progress events
📝 Make sure the model is prepared successfully before scanning. Each model may vary in size and complexity depending on the document type.
🧠 Step 2: Extracting Data from Image
Once the model is prepared successfully, make sure you have ocrMode and ocrType props set appropriately. After that you can call imperative method cameraCaptureHandler to capture the image, the response will be available in onOCRScan event handler.
🔁 The returned data follows the same structure as the PackageX Cloud OCR API response.