I have a question regarding the $vision.scan action for scanning barcodes and hope someone could help me with that. Do we need to provide any particular option to be able to scan EAN 13 or EAN 8 barcodes? The example : (https://jasonbase.com/things/PMj7) is able to scan QR codes without any issues but isn't able to scan any other type of barcode. The gif in the $vision.scan documentation shows that a number of different types of barcodes are being scanned. Could it be a version issue? I'm using a Oneplus 5, running Android 8.1.0. Any help would be really appreciated.
Asked
Active
Viewed 123 times
1 Answers
1
Yes, you need to change some code in Android Studio.
In App > Java > com.jasonette.seed > Service > Vision > JasonVisionService.java
Find setBarcodeFormats.
detector = new BarcodeDetector.Builder(context)
// .setBarcodeFormats(Barcode.QR_CODE)
.setBarcodeFormats(Barcode.EAN_13 | Barcode.EAN_8)
.build();
In the above example I've commented out the QR_CODE format and instead added my own to scan EAN_8 and EAN_13. More info: https://developers.google.com/android/reference/com/google/android/gms/vision/barcode/BarcodeDetector.Builder

veglinus
- 56
- 2
- 9