android-vision icon indicating copy to clipboard operation
android-vision copied to clipboard

Serious Bug in Barcode detection Api **Scan the attached image to see it **

Open monajafi opened this issue 8 years ago • 3 comments
trafficstars

Sometimes while camera preview is open, Barcode Api detects non barcode items as barcode and returns random barcode number( detects barcode by itself without seeing any barcode image). If you want to test this behaviour keep the camera 10 to 15 cm above the left side of MacBook Pro keyboard it detects keyboard as barcode continuously(Scan following image of keyboard to see the bug ,regardless of orientation it detects image as barcode).

20170403_091601

This does not happen in other SDK like Scandit, i-nigma or Manatee . Just Vision Api detects wrongly; increasing preview resolution increases detection error.
here is my createcamerasource method in barcodecapture activity class :

@SuppressLint("InlinedApi")
    private void createCameraSource(boolean autoFocus) {
        Context context = getApplicationContext();
        BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).setBarcodeFormats(Barcode.EAN_13 | Barcode.EAN_8 | Barcode.UPC_A).build();
        this.mScanFeedback = new ScanFeedback(this);
        mScanFeedback.setBeepEnabled(true);
        barcodeDetector.setProcessor(new Detector.Processor<Barcode>() {
            @Override
            public void receiveDetections(Detector.Detections<Barcode> detections) {

                SparseArray<Barcode> barcodes = detections.getDetectedItems();
                if (barcodes != null && (barcodes.size() > 0)) {
                    String barcode =barcodes.valueAt(0).displayValue;
                    if (!barcode.isEmpty()) {
                        showBarcode(barcode);
                    }
                }
            }

            @Override
            public void release() {

            }
        });

        if (!barcodeDetector.isOperational()) {
            Toast.makeText(context, R.string.barcodeOperationalErr, Toast.LENGTH_SHORT).show();
            IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
            boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;

            if (hasLowStorage) {
                Toast.makeText(this, R.string.lowStorageErr, Toast.LENGTH_LONG).show();
            }
        }

        CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector).setRequestedPreviewSize(2560, 1440)
                .setFacing(CameraSource.CAMERA_FACING_BACK);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            builder = builder.setFocusMode(
                    autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null);
        }
        mCameraSource = builder
                .setFlashMode(Camera.Parameters.FLASH_MODE_OFF)
                .build();
        flashBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    mCameraSource.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);

                } else {
                    mCameraSource.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                }
            }
        });
    }

monajafi avatar Apr 03 '17 03:04 monajafi

Yes, I noticed that too, it just scanned my desk without any barcodes when I was explaining something to the QA a few times.

vpdsouza avatar Apr 18 '17 11:04 vpdsouza

yes it scanned my jeans, and it is reproducible. some serious issues while scanning, i believe it has to with the surface its scanning, anywhere with lines it scans. any work around?

sunnyjain avatar Feb 01 '19 14:02 sunnyjain

Have the same issue as @sunnyjain mentioned . The camera is scanning weird patterns on Jeans which is not specifically a barcode.

Is it something to do with the Confidence level?

theEpicGunner avatar Feb 11 '19 16:02 theEpicGunner