The Java – Mobile Vision API reads incorrect barcodes

Mobile Vision API reads incorrect barcodes… here is a solution to the problem.

Mobile Vision API reads incorrect barcodes

Recently I’ve been doing some android barcode scanning apps. EVERYTHING WAS FINE UNTIL I REALIZED THAT THE SAME APP MY FRIEND MADE ON IOS WAS MUCH BETTER AT DETECTING BARCODES. The Google Mobile Vision API often makes errors when the real barcode is “12345…” , it detects something like “72345…” barcode. Is this a common problem? Is there any solution?

Barcode example:
enter image description here

This barcode is well detected when I put the device on top, but after any small action, I will most likely get the wrong code.


I’ve found that not using the first match and instead applying a simple debounce strategy works well. For example, I only consider a valid match after the barcode appears in 3 consecutive frames.
This can be easily done in Custom Detector<Barcode> using internally.
It slows down the detection slightly, but makes them more reliable.

Related Problems and Solutions