React Native
VisionCamera Component
The VisionCamera component is a lightweight, minimal camera component designed for barcode scanning and OCR. Unlike the full VisionSdkView component, it provides a streamlined API without requiring API keys or cloud configuration for basic scanning functionality.
Features
- Photo capture with quality optimization
- Barcode & QR code scanning with multiple symbologies
- OCR (Optical Character Recognition) support
- Real-time object detection (text, barcodes, QR codes, documents)
- Flash control with toggle support
- Zoom control with adjustable levels
- Auto & Manual capture modes
- Image sharpness scoring for quality assurance
- Customizable overlay - render your own UI on top of the camera
- Camera switching - switch between front and back cameras (iOS)
Basic Usage
Scan Modes
Photo Mode
Basic photo capture without barcode or text detection:
Barcode Scanning
Detect and scan barcodes with enhanced metadata:
QR Code Scanning
Specifically scan QR codes:
OCR (Text Recognition)
Document and text detection:
Ref Methods
Access camera controls via ref:
Camera Auto-Start: The camera starts automatically when mounted - you don't need to call start() manually in most cases. Use start() only after you've previously stopped it (e.g., when returning to the camera screen from background).
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.
Event Handlers
Enhanced Barcode Detection
Image Capture with Quality Score
Real-time Recognition Updates
Sharpness Score Monitoring
Error Handling
iOS Error Filtering: On iOS, error codes 13, 14, 15, and 16 are automatically filtered and won't trigger the onError callback.
Advanced Examples
Custom Overlay with Controls
Barcode Scanner with Flash and Zoom
Document Scanner with Auto-Capture
Scan Area Restriction
Performance Tips
Throttle high-frequency events like
onSharpnessScoreUpdateandonRecognitionUpdate:Use
frameSkipto process fewer frames:Use
autoCapture={false}for manual control to reduce processingCleanup on unmount: The camera automatically stops when unmounted
Avoid hot reload during development: Kill and restart the app for best results
Platform Support
iOS
- Auto-starts camera when view is mounted
- Supports all scan modes
- Flash control available on supported devices
- Zoom range depends on device capabilities
- Camera switching fully supported (front/back)
Android
- Auto-starts camera when view is attached to window
- Supports all scan modes
- Flash control available on supported devices
- Zoom range depends on device capabilities
- Camera switching placeholder (not yet functional)
Related Documentation
- Props Reference - Complete VisionCamera props documentation
- Camera Switching - Guide to switching between front and back cameras
- VisionCore Module - Camera-independent operations
Troubleshooting
Camera feed not showing
- Ensure camera permissions are granted
- Check that the component has proper dimensions (flex: 1)
- Verify device has a working camera
Events not firing after hot reload
- This is a known React Native limitation with native views
- Workaround: Kill and restart the app instead of hot reloading
- Note: This does NOT affect production builds
Barcodes not detected
- Ensure good lighting conditions
- Check that
scanModeis set correctly - Verify barcode is within camera view and properly focused
Poor image quality
- Monitor
onSharpnessScoreUpdate- values above 0.7 are generally good - Ensure adequate lighting
- Keep device steady during capture