React Native
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
ref | React.Ref<VisionSdkRefProps> | — | No | Imperative ref to call methods (capture, start/stop, etc.) on the camera. |
apiKey | string | '' | No | API key for Vision SDK authentication. |
token | string | '' | No | Auth token for Vision SDK authentication. |
locationId | string | '' | No | Identifier for a specific location override. |
options | Record<string, any> | {} | No | Additional configuration options to pass to the native view. |
environment | 'dev' | 'qa' | 'staging' | 'prod' | 'sandbox' | 'prod' | No | Backend environment to use (prod, sandbox, etc.). |
captureMode | 'manual' | 'auto' | 'manual' | No | Whether captures are triggered manually or automatically. |
mode | 'barcode' | 'qrcode' | 'ocr' | 'photo' | 'barCodeOrQRCode' | 'priceTag' | 'barcode' | No | Scanning mode for barcodes, QR codes, OCR, photo-only, or mixed barCodeOrQRCode. |
ocrMode | 'cloud' | 'on-device' | 'on-device-with-translation' | 'bill-of-lading' | 'item_label' | 'document_classification' | 'cloud' | No | OCR processing mode (cloud vs. various on‑device options). |
ocrType | 'shipping_label' | 'bill_of_lading' | 'item_label' | 'document_classification' | … | 'shipping_label' | No | Specific OCR use‑case/type (e.g. shipping_label, item_label, document_classification, etc.). |
shouldResizeImage | boolean | true | No | Whether to resize images before sending to the SDK/API. |
isMultipleScanEnabled | boolean | false | No | Enable or disable multiple‑scan mode in one session. |
flash | boolean | false | No | Turn camera flash on or off. |
isEnableAutoOcrResponseWithImage | boolean | true | No | Automatically include the captured image in the OCR response. |
modelExecutionProviderAndroid | 'NNAPI' | 'CPU' | 'XNNPACK' | 'CPU' | No | ** DEPRECATED - Will be removed in future versions.** Configure OCR model execution provider for Android (NNAPI, CPU, or XNNPACK). |
zoomLevel | number | 1.8 | No | Zoom factor for the camera (device‑dependent). |
onModelDownloadProgress | (event: ModelDownloadProgress) => void | () => {} | No | Callback for model download progress events. |
onBarcodeScan | (event: BarcodeScanResult) => void | () => {} | No | Callback when a barcode scan result is received. |
onImageCaptured | (event: ImageCaptureEvent) => void | () => {} | No | Callback after an image has been captured. |
onOCRScan | (event: OCRScanResult) => void | () => {} | No | Callback for OCR scan results. |
onDetected | (event: DetectionResult) => void | () => {} | No | Callback for generic detection results (text, barcode, QR code, etc.). |
onCreateTemplate | (event: { data: 'created_template_id' }) => void | () => {} | No | Callback for receiving recently created template id. |
onDeleteTemplateById | (event: { data: 'deleted_template_id' }) => void | () => {} | No | Callback for receiving recently deleted template id. |
onDeleteTemplates | () => void | () => {} | No | Callback triggered when all templates are deleted successfully. |
onGetTemplates | (event) => void | () => {} | No | Callback that receives all available template ids. |
onBoundingBoxesDetected | (event: BoundingBoxesDetectedResult) => void | () => {} | No | Callback for receiving coordinates and dimensions for detected bounding boxes on screen. |
onPriceTagDetected | (event: PriceTagDetectionResult) => void | () => {} | No | Callback for price tag detection. |
onError | (event: ErrorResult) => void | () => {} | No | Callback when an error occurs within the SDK. |
# VisionSdkRefProps — Imperative Methods Reference
| Method | Parameters | Return | Description | Example |
|---|---|---|---|---|
stopRunningHandler | — | void | Stops any ongoing process in the Vision SDK (e.g. scanning or image processing). | visionSdkRef.current.stopRunningHandler() |
cameraCaptureHandler | — | void | Triggers the camera to capture an image for processing. | visionSdkRef.current.cameraCaptureHandler() |
restartScanningHandler | — | void | Restarts the scanning process after it has been stopped or interrupted. | visionSdkRef.current.restartScanningHandler() |
startRunningHandler | — | void | Starts the scanning or image‑processing task in the Vision SDK. | visionSdkRef.current.startRunningHandler() |
setMetadata | value: any | void | Sets arbitrary metadata to be sent along with the next capture or scan. | visionSdkRef.current.setMetadata({ orderId: 12345, customerName: 'John Doe' }) |
setRecipient | value: any | void | Sets recipient details (e.g. name, address) for shipping‑label workflows. | visionSdkRef.current.setRecipient({ name: 'Jane Smith', address: '123 Main St' }) |
setSender | value: any | void | Sets sender details (e.g. name, address) for shipping‑label workflows. | visionSdkRef.current.setSender({ name: 'John Doe', address: '456 Elm St' }) |
configureOnDeviceModel | payload: { type: ModuleType; size?: ModuleSize }, token?: string, apiKey?: string | void | Configures which on‑device model to use (e.g. item_label, shipping_label) and optionally its size. | visionSdkRef.current.configureOnDeviceModel({ type: 'item_label', size: 'small' }) |
getPrediction | image: any, barcode: string[] | void | Processes an image plus barcodes client‑side (on‑device) to get a prediction. | visionSdkRef.current.getPrediction(image, ['1234567890']) |
getPredictionWithCloudTransformations | image: any, barcode: string[], token?: string, apiKey?: string, locationId?: string, options?: any, metadata?: any, recipient?: any, sender?: any, shouldResizeImage?: boolean | void | Sends image & barcode to cloud with optional resizing and extra context for advanced transformations. | visionSdkRef.current.getPredictionWithCloudTransformations(image, ['1234567890']) |
getPredictionShippingLabelCloud | image: any, barcode: string[], token?: string, apiKey?: string, locationId?: string, options?: Record<string, any>, metadata?: any, recipient?: any, sender?: any, shouldResizeImage?: boolean | void | Sends a shipping‑label image & barcodes to cloud for OCR/prediction. | visionSdkRef.current.getPredictionShippingLabelCloud(image, ['9876543210']) |
getPredictionBillOfLadingCloud | image: any, barcode: string[], token?: string, apiKey?: string, locationId?: string, options?: Record<string, any>, shouldResizeImage?: boolean | void | Sends a bill‑of‑lading image & barcodes to cloud for OCR/prediction. | visionSdkRef.current.getPredictionBillOfLadingCloud(image, ['1234567890']) |
getPredictionItemLabelCloud | image: string, token?: string, apiKey?: string, shouldResizeImage?: boolean | void | Sends an item‑label image to cloud for OCR/prediction. | visionSdkRef.current.getPredictionItemLabelCloud(image) |
getPredictionDocumentClassificationCloud | image: string, token?: string, apiKey?: string, shouldResizeImage?: boolean | void | Sends a document image to cloud for classification & OCR. | visionSdkRef.current.getPredictionDocumentClassificationCloud(image) |
reportError | payload: ReportErrorType, token?: string, apiKey?: string | void | Reports a custom error (with type & size) to the SDK for debugging or telemetry. | visionSdkRef.current.reportError({ reportText: 'Error processing image.', type: 'shipping_label', size: 'small' }) |
createTemplate | callback?: (res: any, err: any) => void | void | Creates a new template in the SDK. | visionSdkRef.current.createTemplate((res, err) => { /* ... */ }) |
getAllTemplates | — | void | Retrieves all saved templates from the SDK. | visionSdkRef.current.getAllTemplates() |
deleteTemplateWithId | id: string | void | Deletes a specific template by its ID. | visionSdkRef.current.deleteTemplateWithId('template123') |
deleteAllTemplates | id: string | void | Deletes all templates stored in the SDK. (takes a dummy id param) | visionSdkRef.current.deleteAllTemplates() |
setFocusSettings | settings: any | void | Configures the SDK's camera focus settings (e.g. autoFocus). | visionSdkRef.current.setFocusSettings({ autoFocus: true }) |
setFocusSettings | settings: any | void | Configures the SDK’s camera focus settings (e.g. autoFocus). | visionSdkRef.current.setFocusSettings({ autoFocus: true }) |
setObjectDetectionSettings | settings: any | void | Configures object‑detection parameters (e.g. confidence threshold). | visionSdkRef.current.setObjectDetectionSettings({ confidenceThreshold: 0.85 }) |
setCameraSettings | settings: any | void | Configures camera parameters (e.g. resolution, exposure) for optimal capture. Includes cameraPosition (1 = back, 2 = front) for camera switching. iOS: Fully supported | Android: Placeholder (not yet functional) | visionSdkRef.current.setCameraSettings({ nthFrameToProcess: 10, cameraPosition: 2 }) |
# VisionCamera Component Props
The VisionCamera component is a lightweight, minimal camera component designed for barcode scanning and OCR. Unlike the full VisionSDK component, it provides a streamlined API without requiring API keys or cloud configuration for basic scanning functionality.
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<VisionCameraRefProps> | — | Imperative ref to call methods (capture, start/stop, etc.) on the camera. |
scanMode | 'photo' | 'barcode' | 'qrcode' | 'barcodeOrQrCode' | 'ocr' | 'photo' | Detection mode for the camera |
autoCapture | boolean | false | Automatically capture when detection is successful |
enableFlash | boolean | false | Enable/disable camera flash |
zoomLevel | number | 1.0 | Camera zoom level (device dependent, typically 1.0-5.0) |
cameraFacing | 'back' | 'front' | 'back' | Camera facing direction - 'back' for rear camera or 'front' for front-facing camera. iOS: Fully supported | Android: Placeholder (not yet functional) |
scanArea | { x: number, y: number, width: number, height: number } | undefined | Restrict scanning to a specific region (coordinates in dp) |
detectionConfig | object | See below | Configure object detection settings |
frameSkip | number | undefined | Process every Nth frame for performance optimization |
onBarcodeDetected | (event: { codes: Array<BarcodeResult> }) => void | () => {} | Fired when barcode(s) are detected |
onCapture | (event: { image: string, nativeImage: string, sharpnessScore?: number, barcodes?: Array<BarcodeResult> }) => void | () => {} | Fired when image is captured |
onRecognitionUpdate | (event: { text: boolean, barcode: boolean, qrcode: boolean, document: boolean }) => void | () => {} | Continuous updates of detected objects |
onSharpnessScoreUpdate | (event: { sharpnessScore: number }) => void | () => {} | Image sharpness score updates (0-1) |
onBoundingBoxesUpdate | (event: { barcodeBoundingBoxes: Array<DetectedCodeBoundingBox>, qrCodeBoundingBoxes: Array<DetectedCodeBoundingBox>, documentBoundingBox: BoundingBox }) => void | () => {} | Bounding boxes for detected objects |
onError | (event: { message: string, code?: number }) => void | () => {} | Error events |
# Detection Config Object
detectionConfig={{
text: true, // Enable text detection (iOS only)
barcode: true, // Enable barcode detection
document: true, // Enable document detection (iOS only)
barcodeConfidence: 0.5, // Barcode detection confidence (0-1, iOS only)
documentConfidence: 0.5, // Document confidence (0-1, iOS only)
documentCaptureDelay: 2.0 // Delay before auto-capture (seconds, iOS only)
}}
# VisionCameraRefProps — Imperative Methods Reference
| Method | Parameters | Return | Description | Example |
|---|---|---|---|---|
capture() | — | void | Capture image manually (when autoCapture is false) | cameraRef.current?.capture() |
start() | — | void | Start camera (only needed if you previously stopped it) | cameraRef.current?.start() |
stop() | — | void | Stop camera (e.g., when screen goes to background) | cameraRef.current?.stop() |
NOTE
Camera Auto-Start: The camera starts automatically when mounted - you don't need to call start() manually in most cases.
Property Control: Flash, zoom, and camera facing are controlled via props (enableFlash, zoomLevel, cameraFacing), not ref methods. Update the prop values to change these settings dynamically.
# VisionCore Methods
For camera-independent OCR prediction and logging operations, use the VisionCore module instead of the component ref methods:
- Headless OCR Prediction: Use
VisionCore.predict(),VisionCore.predictShippingLabelCloud(), etc. — See Documentation - Data Logging: Use
VisionCore.logItemLabelDataToPx(),VisionCore.logShippingLabelDataToPx()— See Documentation
import { VisionCore } from 'react-native-vision-sdk';
// Camera-independent prediction
const result = await VisionCore.predictShippingLabelCloud(imageUri, [], options);
// Data logging
await VisionCore.logItemLabelDataToPx(imageUri, barcodes, responseData, token, apiKey, true, metadata);