Flutter
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 following methods. This ensures the necessary AI models are downloaded and ready to use.
β οΈ You must wait for the configure process to complete before proceeding to OCR extraction.
π§© Selecting the Model Type
When preparing for on-device AI scanning, you can choose which document model you want to use by specifying the modelClass
parameter. This lets the SDK know which type of document youβre scanning so it can load the appropriate AI model.
Here are the supported options:
π¦ For Shipping Labels
Use this to scan and extract structured data from shipping labels.
π For Bill of Lading (BOL)
Use this to extract data from Bill of Lading documents.
π·οΈ For Item Labels
Use this to process and extract structured details from product/item labels.
π 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, use the following method to perform OCR on a given image.
Parameters:
byteArrayImage
: TheUint8List
byte array of image you want to process.barcodes
: A list ofString
values representing barcodes detected in the image (if any).
π The returned data follows the same structure as the PackageX Cloud OCR API response.
β² Step 3: Release resources
It is important that when you are done with predictions and you are not planning to get more predictions on-device, or you want to configure a different AI model, then you release the memory being held by AI model. You can do that by using following code:
Available On-Device AI Scanning
Following table explains all the on-device AI scanning options available currently.