vision-camera-code-scanner
vision-camera-code-scanner copied to clipboard
Barcode is not recognized correctly
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:
Flipper log:
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.
double post with https://github.com/mrousavy/react-native-vision-camera/issues/1224 - see the answer
hi, if you test the sheet here, you read 29/29 barcodes.
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 ?)
any update or workaround bro? As I see, there are incorrect detection for 128 code
hi, not really, the 128 code depends on the generator of labels, some are correct.
Any update? This lib still scan very stupid in barcode case
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.