Camera and Barcodes

expo-camera and Barcode Scanning

<CameraView> is a live preview you can style and lay out like any view; useCameraPermissions() returns the permission state and a function that asks for it. Scanning is built in: list the symbologies you want, and onBarcodeScanned fires for each code in view. A book's ISBN-13 is printed as an EAN-13 barcode:

src/app/scan.tsx: a live preview that scans EAN-13 barcodes (excerpt)TSX
      <CameraView ref={camera} style={{ flex: 1 }} facing="back"
        barcodeScannerSettings={{ barcodeTypes: ['ean13'] }}
        onBarcodeScanned={found ? undefined : ({ data }) => onIsbn(data)} />

Passing undefined once a book is found stops the callback, which otherwise fires many times a second for the same code. Under the hood, the Android side runs Google's ML Kit barcode model on CameraX 234 frames (expo-camera's Gradle 19,597 file adds com.google.mlkit:barcode-scanning:17.3.0), on the device, with no network; iOS uses Apple's own scanning APIs. The same scanner reads still images with scanFromURLAsync(uri, types), which Cover Photo Scanner uses.

The config plugin in app.json sets the iOS NSCameraUsageDescription text, and recordAudioAndroid: false removes the RECORD_AUDIO permission that video recording would need, so Android does not ask for the microphone. The emulator's back camera is a virtual 3D scene, which the preview showed as a blocky room (right in the figure in Cover Photo Scanner); it has no barcodes to point at, so on the emulator the scanner is exercised through images. On a phone, test in poor light and at an angle, and add a torch button (enableTorch).