React Native
VisionCore Module
The VisionCore module provides camera-independent functionality for the React Native Vision SDK. It allows you to perform OCR predictions, model management, and data logging without requiring the camera component.
Import and Setup
Environment Management
VisionCore.setEnvironment(environment)
Sets the environment for all VisionCore operations. This should be called once during app initialization.
Parameters
environment(required): Environment string -'staging' | 'dev' | 'sandbox' | 'qa' | 'production'
Example
Call setEnvironment() once at app startup before using any other VisionCore methods.
Model Management
DEPRECATED: The loadModel(), unLoadModel(), and predict() methods shown below are deprecated and will be removed in v3.0.0. Please use the new Model Management API for better control and features.
NEW in v2.0.2: VisionCore now includes a comprehensive Model Management API with 14 new methods for fine-grained control over on-device models. See the Model Management documentation for complete details.
Quick Comparison
Old API (Deprecated):
New API (Recommended):
Deprecated: VisionCore.loadModel(token, apiKey, modelType, modelSize)
DEPRECATED - Use downloadModel() + loadOCRModel() instead.
Loads on-device models without requiring the camera view. This method downloads and prepares models for offline OCR processing.
Parameters
token(optional): Authentication token (string | null)apiKey(optional): API key (string | null)modelType(required): Model type (string)'shipping_label''item_label''bill_of_lading''document_classification'
modelSize(required): Model size (string)'nano'- Smallest, fastest'micro'- Small and fast'small'- Balanced'medium'- Higher accuracy'large'- Best accuracy'xlarge'- Maximum accuracy
Returns
Promise<void>- Resolves when model loading starts
Example
Deprecated: VisionCore.unLoadModel(modelType, shouldDeleteFromDisk)
DEPRECATED - Use unloadModel() and/or deleteModel() instead.
Unloads on-device models to free up memory and disk space when they're no longer needed.
Parameters
modelType(required): Model type to unload (string | null)'shipping_label'- Unload specific model'item_label'- Unload specific model'bill_of_lading'- Unload specific model'document_classification'- Unload specific modelnull- Unload all models
shouldDeleteFromDisk(optional): Delete model files from disk (boolean, default:false)true- Removes model files from disk permanentlyfalse- Keeps files for faster reloading
Returns
Promise<string>- Success message
Example
Use Cases
- Free up memory when switching between different model types
- Clean up disk space after processing
- Prepare for app updates or model version changes
- Optimize app performance by removing unused models
Platform Differences
- iOS: Supports unloading specific models individually
- Android: Due to singleton pattern, unloading a specific model will destroy the entire singleton instance, effectively unloading all models
Deprecated: VisionCore.onModelDownloadProgress(callback)
DEPRECATED - Use the progressCallback parameter in downloadModel() instead.
Subscribes to model download progress updates. Returns a subscription that can be removed.
Parameters
callback(required): Function that receives progress updatesprogress(number): Download progress (0.0 to 1.0)downloadStatus(boolean): Whether model is downloadedisReady(boolean): Whether model is ready for use
Returns
Subscription- Event subscription with.remove()method
Example
Prediction Methods
On-Device Prediction
Deprecated: VisionCore.predict(imagePath, barcodes)
DEPRECATED - Use predictWithModule() instead for explicit model selection.
Performs on-device OCR prediction using the loaded model.
Parameters
imagePath(required): Path to image file (string)barcodes(optional): Array of detected barcodes (string[], default:[])
Returns
Promise<any>- OCR prediction result
Example
Cloud Prediction Methods
VisionCore.predictShippingLabelCloud(imagePath, barcodes, options)
Cloud-based shipping label prediction.
Parameters
imagePath(required): Image file path (string)barcodes(optional): Barcode array (string[], default:[])options(optional): Configuration objecttoken?: string | nullapiKey?: string | nulllocationId?: string | nulloptions?: {[key: string]: any} | nullmetadata?: {[key: string]: any} | nullrecipient?: {[key: string]: any} | nullsender?: {[key: string]: any} | nullshouldResizeImage?: boolean
Example
VisionCore.predictItemLabelCloud(imagePath, options)
Cloud-based item label prediction.
Parameters
imagePath(required): Image file path (string)options(optional): Configuration objecttoken?: string | nullapiKey?: string | nullshouldResizeImage?: boolean
VisionCore.predictBillOfLadingCloud(imagePath, barcodes, options)
Cloud-based bill of lading prediction.
Parameters
imagePath(required): Image file path (string)barcodes(optional): Barcode array (string[], default:[])options(optional): Configuration objecttoken?: string | nullapiKey?: string | nulllocationId?: string | nulloptions?: {[key: string]: any} | nullshouldResizeImage?: boolean
VisionCore.predictDocumentClassificationCloud(imagePath, options)
Cloud-based document classification.
Parameters
imagePath(required): Image file path (string)options(optional): Configuration objecttoken?: string | nullapiKey?: string | nullshouldResizeImage?: boolean
VisionCore.predictWithCloudTransformations(imagePath, barcodes, options)
Hybrid on-device + cloud prediction.
Parameters
imagePath(required): Image file path (string)barcodes(optional): Barcode array (string[], default:[])options(optional): Configuration object (same as shipping label options)
Logging Methods
VisionCore.logItemLabelDataToPx(imageUri, barcodes, responseData, token, apiKey, shouldResizeImage, metadata)
Logs item label data to PackageX Vision for analytics.
Parameters
imageUri(required): Image file path (string)barcodes(required): Barcode array (string[])responseData(required): OCR response data (any)token(optional): Auth token (string | null)apiKey(optional): API key (string | null)shouldResizeImage(optional): Resize image (boolean, default:true)metadata(optional): Custom metadata ({[key: string]: any} | null, default:{})
Returns
Promise<any>- Logging result
VisionCore.logShippingLabelDataToPx(imageUri, barcodes, responseData, token, apiKey, locationId, options, metadata, recipient, sender, shouldResizeImage)
Logs shipping label data to PackageX Vision for analytics.
Parameters
imageUri(required): Image file path (string)barcodes(required): Barcode array (string[])responseData(required): OCR response data (any)token(optional): Auth token (string | null)apiKey(optional): API key (string | null)locationId(optional): Location ID (string | null)options(optional): Additional options ({[key: string]: any} | null)metadata(optional): Custom metadata ({[key: string]: any} | null)recipient(optional): Recipient info ({[key: string]: any} | null)sender(optional): Sender info ({[key: string]: any} | null)shouldResizeImage(optional): Resize image (boolean, default:true)
Returns
Promise<any>- Logging result
Complete Setup Example
Related Documentation
- Model Management API - New comprehensive API for managing on-device models
- Headless OCR Prediction - Camera-independent OCR workflows
- Logging APIs - Data logging for analytics
- Props Reference - Camera component properties
VisionCore methods are completely independent of the camera component and can be used in any React Native app without requiring camera permissions or the VisionSdkView component.