zxing-android-embedded icon indicating copy to clipboard operation
zxing-android-embedded copied to clipboard

Issue with Zxing Embedded Continuous QR Code Scanning

Open gauravk1 opened this issue 1 year ago • 2 comments

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

gauravk1 avatar Jan 31 '24 06:01 gauravk1

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:

  1. Disable CODE_39 completely if you don't need it.
  2. 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.

rkistner avatar Jan 31 '24 06:01 rkistner

Thanks, @rkistner, but we need to scan both QR Codes and Barcodes, and the length is not specific.

gauravk1 avatar Jan 31 '24 07:01 gauravk1