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.
🧩 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.