1

Scanning on Android is not working as intended, or it takes time to scan

3 different libraries i Have used: zxy firebase-ml-vision Google vision

Config is:: react-native-cli: 2.0.1 react-native: 0.62.2 "react-native-camera": "3.37.0"

rchgupta
  • 89
  • 1
  • 1
  • 6

2 Answers2

1

/**
*  Boosts up barcode read performance on Android
*/
import { RNCamera, RNCameraProps } from 'react-native-camera';


const RNCameraProps: RNCameraProps = {};

if (Platform.OS === OS.IOS) {
  RNCameraProps.onBarCodeRead = ({ data }) => {
    console.log(data);
  };
} else {
  RNCameraProps.onGoogleVisionBarcodesDetected = ({ barcodes }) => {
    const response = barcodes[0];
    console.log(response);
  };
}

return(
  <RNCamera
    type={RNCamera.Constants.Type.back}
    style={styles.camera}
    {...RNCameraProps}
  />
);
Lilian Tonofa
  • 151
  • 2
  • 5
0

A solution from 2022:

  1. Use the Vision Camera component https://mrousavy.com/react-native-vision-camera/ because it is very close to native performance.
  2. For QR/Barcode detection use this frame processor for Vision Camera https://github.com/rodgomesc/vision-camera-code-scanner which uses ML Kit under the hood.
Kirill Novikov
  • 2,576
  • 4
  • 20
  • 33