Incorrect barcode read by Mobile Vision API
Asked Answered
I

4

6

Recently I've been doing some kind of Android barcode scanning app. Everything was fine until I realized that the same app made by my friend on IOS is much better at detecting barcodes. Google Mobile Vision API is often wrong, it detects barcodes like "72345...." when a real barcode is "12345..." . Is this a general problem? Are there any solutions?

Sample barcode: enter image description here

This barcode is detected fine when I keep my device above, but after any small move there is big chance to get incorrect code.

Incorporeal answered 11/5, 2017 at 14:34 Comment(4)
I am using ZBar library where sometimes I have wrong scanning but not so often as you mention, so its worth a try. If someone has a solution for this I am really interested as well.Orren
I was considering switch to ZBar or ZXing but I don't really know if it will be any better. Interesting is fact, that IPhones are able to do it waaaaay better, almost without any incorrect scanning.Hersh
Yes I know, same situation here! We are developing same app on android and iOS but on Android there are few times of wrong scanning...Hope someone can help in your question!Orren
did you find any solution. In fact I am facing same problem. even though I have changed speed, Enhanced the preview for better barcode image, but still there are wrong reading by Scanning api. Looking at the scandit they are flawless. So how they are doing that and why google api is not so much better. ???Detach
N
6

I found that not using the first match but applying a simple debounce strategy works pretty well. For example I only consider a valid match after a barcode appears in 3 continuous frames. This can be easily done in a custom Detector<Barcode> that uses a com.google.android.gms.vision.barcode.BarcodeDetector internally. It slows down detection a bit but makes them more reliable.

Nikolenikoletta answered 10/10, 2017 at 11:1 Comment(3)
True. Probably the best way to go for now.Hersh
Where you found BarcodeDetector implementation or can you provide solution how to do it? @IncorporealMoan
I've implemented it myself, there is plenty of tutorials available online for free.Hersh
M
1

For anyone who wants fast solution based on google barcode sample. To the BarcodeGraphicTracker add three fields:

String currentBarcode = null;
int confirmCounter = 0;
final static int CONFIRM_VALUE = 10;

Update BarcodeUpdateListener interface with new method:

 @UiThread
 void onBarcodeConfirmed(Barcode barcode);

Add this snippet to the overriden onUpdate method:

if (currentBarcode != null && currentBarcode.equals(item.displayValue)){
        confirmCounter++;
        if (confirmCounter >= CONFIRM_VALUE){
            confirmCounter = 0;
            mBarcodeUpdateListener.onBarcodeConfirmed(item);
        }
    }else{
        currentBarcode = item.displayValue;
        confirmCounter = 0;
    }
}

Now you can tune it by setting fps to camera source and changing CONFIRM_VALUE.

Moan answered 22/5, 2019 at 7:38 Comment(0)
I
0

The best solution I've found so far is to set FPS of cameraSource to 15.0f. It will slow down preview, but results will be more reliable. However, still less reliable than IPhone's ones.

Sample from Google:

https://github.com/googlesamples/android-vision/blob/master/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/BarcodeCaptureActivity.java

.setRequestFps()

is a method to go.

Incorporeal answered 11/5, 2017 at 14:49 Comment(1)
well I do not think so that it is the way to go. Different phone could have different frame rate. Moreover I have good results about in scanning all other barcodes. But one of the barcode is creating problem even though it is UPC-A. and All others are also of same kind.Detach
F
0

My idea was to improve the scanner reliability by evaluate the barcode "check digit" - the last digit in the scanned code.

Recently I scanned like 500 codes - mostly EAN-13, EAN-8, UPC-A - and all of them are valid, they have correct check digit. At least 20 of them are not scanned correctly, the result is different code - but still a valid one..

Conclusion - Mobile Vision API Barcode Scanner do have the check digit logic integrated.

Flan answered 14/1, 2022 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.