googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.58k stars 2.93k forks source link

Does the Barcode Scanner support I25(ITF) type for Brazil Boleto? #98

Closed yihanseattle closed 4 years ago

yihanseattle commented 4 years ago

Can't figure out the reason why we cannot scan I25(ITF) even though ITF is supported in ML Kit.

Wikipedia Link for Type I25(ITF): I25 Wikipedia

Please help if you know the reason if ML Kit support the format or not. And can we use custom model for barcode scanning.

Example image: image

I was testing out the Brazil Boleto ticket. You can test the Boleto ticket below: Example Boleto

Below is the tool to generate Boleto barcode: Boleto Generator

Thanks so much!

zhouyiself commented 4 years ago

Thanks for report! ITF type is supported. I have tried out the given sample and it can produce the correct result: 034193833200260001790001043510049102015000

Which barcode dependency you use in your build.gradle file?

yihanseattle commented 4 years ago

Hi @zhouyiself , thank you so much for the response!

I just tried the ML Kit quickstart sample. The default LivePreview didn't work.

Yes, we also discovered later that it worked if we changed the "Preview Resolution" to 1600 x 1200 or similar in both LivePreview and CameraXLivePreview.

May I ask how did you test it? What configuration did you use?

1) Which app and configuration did you use? (Preview Resolution, Camera or CameraX, etc) Do you recommend auto-focus enabled? 2) How about low-end Android devices that might not support Preview Resolution of 1600 x 1200? Do we have a recommended minimum Preview Resolution for Android? So we can try to get the highest Preview resolution if possible but not too large at the same time. 3) Do you happen to know that the Brazil Boleto (I-25) type can be scanned if we only use ITF type like below? Does it need to use other types to be scanned successfully? Does only Barcode.FORMAT_ITF instead of Barcode.FORMAT_ALL_FORMATS improve the accuracy as well? Trying to get as fast and accurate as possible. barcodeScanner = BarcodeScanning.getClient(new BarcodeScannerOptions.Builder().setBarcodeFormats(Barcode.FORMAT_ITF) .build());

4) One last question, have you test the fastest and average time to get a success result? We are trying to use it to improve our user experience.

Thanks so much!

zhouyiself commented 4 years ago

Thanks for reaching out!

  1. Which app and configuration did you use? (Preview Resolution, Camera or CameraX, etc) Do you recommend auto-focus enabled?

I'm also using the quickstart sample app but using StillImageActivity to test the image you posted. You're right that it works partially for this image (w:1024 option works but not w:640). Regarding "auto-focus", I prefer to leave it on.

  1. How about low-end Android devices that might not support Preview Resolution of 1600 x 1200? Do we have a recommended minimum Preview Resolution for Android? So we can try to get the highest Preview resolution if possible but not too large at the same time.

There're input image guidelines from the developer page that might helpful. https://developers.google.com/ml-kit/vision/barcode-scanning/android#input-image-guidelines

  1. Do you happen to know that the Brazil Boleto (I-25) type can be scanned if we only use ITF type like below? Does it need to use other types to be scanned successfully? Does only Barcode.FORMAT_ITF instead of Barcode.FORMAT_ALL_FORMATS improve the accuracy as well? Trying to get as fast and accurate as possible. barcodeScanner = BarcodeScanning.getClient(new BarcodeScannerOptions.Builder().setBarcodeFormats(Barcode.FORMAT_ITF) .build());

If your case only need to support ITF type, Barcode.FORMAT_ITF is better as it won't hurt accuracy but faster.

  1. One last question, have you test the fastest and average time to get a success result? We are trying to use it to improve our user experience.

Sorry I didn't do a comprehensive evaluation for this particular type.

yihanseattle commented 4 years ago

@zhouyiself

Thank you so much! That was a big help 👍

Will let you know if we have further questions :)

Bests,

Yi