rchgupta
rchgupta

Reputation: 99

Barcode Scanner using RN Camera is very slow in android expected as smooth as that of ios

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"

Upvotes: 1

Views: 1710

Answers (2)

Kirill Novikov
Kirill Novikov

Reputation: 3067

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.

Upvotes: 0

Lilian Tonofa
Lilian Tonofa

Reputation: 311


/**
*  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}
  />
);

Upvotes: 1

Related Questions