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
VisionCore.loadModel(token, apiKey, modelType, modelSize)
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
VisionCore.onModelDownloadProgress(callback)
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
VisionCore.predict(imagePath, barcodes)
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 | null
apiKey?: string | null
locationId?: string | null
options?: {[key: string]: any} | null
metadata?: {[key: string]: any} | null
recipient?: {[key: string]: any} | null
sender?: {[key: string]: any} | null
shouldResizeImage?: boolean
Example
VisionCore.predictItemLabelCloud(imagePath, options)
Cloud-based item label prediction.
Parameters
imagePath
(required): Image file path (string
)options
(optional): Configuration objecttoken?: string | null
apiKey?: string | null
shouldResizeImage?: 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 | null
apiKey?: string | null
locationId?: string | null
options?: {[key: string]: any} | null
shouldResizeImage?: boolean
VisionCore.predictDocumentClassificationCloud(imagePath, options)
Cloud-based document classification.
Parameters
imagePath
(required): Image file path (string
)options
(optional): Configuration objecttoken?: string | null
apiKey?: string | null
shouldResizeImage?: 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
- 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.