vision-camera-code-scanner icon indicating copy to clipboard operation
vision-camera-code-scanner copied to clipboard

Barcode is not recognized correctly

Open jacob-li-hj opened this issue 2 years ago • 7 comments

The scanning speed of the camera is relatively fast, but there is a certain chance that the barcode will be recognized as wrong data. I tried to use the provided demo to test, but there is still such a problem.

demo app info:

"react": "17.0.2",
"react-native": "0.66.3",
"react-native-reanimated": "2.4.1",
"react-native-screens": "3.5.0",
"react-native-vision-camera": "^2.9.4"

device info: All IOS and android devices have a chance to reproduce

demo code: Replace the useScanBarcodes method in the provided demo code with the useFrameProcessor method. I checked that the principles of the two methods are the same, so there is no difference between the two methods.

import * as React from 'react';

import { StyleSheet } from 'react-native';
import { useCameraDevices, useFrameProcessor } from 'react-native-vision-camera';
import { Camera } from 'react-native-vision-camera';
import { useScanBarcodes, BarcodeFormat, scanBarcodes } from 'vision-camera-code-scanner';

export default function App() {
  const [hasPermission, setHasPermission] = React.useState(false);
  const devices = useCameraDevices();
  const device = devices.back;


  const frameProcessor = useFrameProcessor(
    frame => {
      // eslint-disable-next-line
      'worklet'
      const barcodes = scanBarcodes(frame, [BarcodeFormat.ALL_FORMATS])
      if(barcodes[0]?.content?.data){
        console.log('111111111111', barcodes[0]?.content?.data)
      }
    },
    []
  )

  React.useEffect(() => {
    (async () => {
      const status = await Camera.requestCameraPermission();
      setHasPermission(status === 'authorized');
    })();
  }, []);

  return (
    device != null &&
    hasPermission && (
      <>
        <Camera
          style={StyleSheet.absoluteFill}
          device={device}
          isActive={true}
          frameProcessor={frameProcessor}
          frameProcessorFps={5}
        />
      </>
    )
  );
}

Barcodes tested:Code-39 type barcode data generated by https://barcode.tec-it.com/en/Code39FullASCII?data=32343242 website:

image

Flipper log:

image

From the above test, we can find that in multiple scans, occasionally one barcode is recognized as another wrong data, and after testing, it is found that this problem occurs not only with barcodes in the format of code-39, but also other Some types of barcodes can also scan incorrectly.

jacob-li-hj avatar Sep 01 '22 16:09 jacob-li-hj

double post with https://github.com/mrousavy/react-native-vision-camera/issues/1224 - see the answer

Productivix avatar Sep 12 '22 06:09 Productivix

hi, if you test the sheet here, you read 29/29 barcodes.

30-codes-feuille.pdf

But, if you move the vertical EAN13 one in top right too close from the 128 over (pdf of tests not posted here), you get some confusing results : the 128 code is missing and the EAN13 is generated in 2 differents EAN13 + 1 EAN8. So , I thing that what we call in the barcode technology the "quiet zone" has to be respected at printing, or the software could be improved with a test also and not scan if some bars are in this Quiet Zone around.(for @rodgomesc : what do you think ?)

Productivix avatar Sep 15 '22 07:09 Productivix

any update or workaround bro? As I see, there are incorrect detection for 128 code

letrungtrung avatar Jan 06 '23 10:01 letrungtrung

hi, not really, the 128 code depends on the generator of labels, some are correct.

Productivix avatar Jan 06 '23 11:01 Productivix

Any update? This lib still scan very stupid in barcode case

nguyentuanit97 avatar Apr 27 '23 14:04 nguyentuanit97

Any update? This lib still scan very stupid in barcode case

I haven't found a solution for the time being, and this problem is very serious to me. I have to continue to use the deprecated react-native-camera.

jacob-li-hj avatar Apr 28 '23 03:04 jacob-li-hj