zxing-android-embedded
zxing-android-embedded copied to clipboard
Issue with Zxing Embedded Continuous QR Code Scanning
I'm currently using Zxing Embedded for QR code scanning in continuous mode. However, I'm encountering an issue where it scans randomly from various patterns, including clothes and other non-QR code elements. Has anyone else experienced this problem, and if so, could you please share any solutions or suggestions to fix this issue?
barcodeScannerView = findViewById(R.id.scanner_view);
Collection<BarcodeFormat> formats = Arrays.asList(BarcodeFormat.QR_CODE, BarcodeFormat.CODE_39);
barcodeScannerView.getBarcodeView().setDecoderFactory(new DefaultDecoderFactory(formats));
barcodeScannerView.initializeFromIntent(getIntent());
barcodeScannerView.setStatusText("");
beepManager = new BeepManager(this);
barcodeScannerView.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
barcodeScannerView.decodeContinuous(callback);
CameraSettings cameraSettings = new CameraSettings();
cameraSettings.setFocusMode(CameraSettings.FocusMode.AUTO);
cameraSettings.setAutoTorchEnabled(false);
if (mSession.getIs_top_camera_enabled().equals("1")) {
cameraSettings.setRequestedCameraId(1); // or CAMERA_FRONT or specific camera id
} else {
cameraSettings.setRequestedCameraId(0); // or CAMERA_BACK or specific camera id
}
barcodeScannerView.setCameraSettings(cameraSettings);
Thank you in advance for your help! Gaurav Kapoor
That's the CODE_39 format that unfortunately has many false detections with the current zxing:core algorithm.
The only workarounds I have right now:
- Disable CODE_39 completely if you don't need it.
- If you do need it but only scan specific barcodes, see if you can validate the barcode before proceeding, e.g. checking that the length matches.
Thanks, @rkistner, but we need to scan both QR Codes and Barcodes, and the length is not specific.