Barcode Scanning using Firebase ML kit

Updated 2 January 2020

Save

In order to get the information from the barcode and trigger the action, We can use ML kit’s barcode scanning API.
Steps to implement Firebase ML kit
1. We have to add Firebase in the project.
2. Add the dependencies for the ML Kit Android libraries to your module (app-level) Gradle file (usually app/build.gradle)<

Configure Barcode detector
It will be better to know the formate of the barcode in order to improve performance and getting the information
The following formats are supported:-Code 128 (FORMAT_CODE_128), Code 39 (FORMAT_CODE_39), Code 93 (FORMAT_CODE_93), Codabar (FORMAT_CODABAR), EAN-13, (FORMAT_EAN_13), Aztec (FORMAT_AZTEC), Data Matrix (FORMAT_DATA_MATRIX)

Run the Barcode Detector
1. Create FirebaseVisionImage object.
FirebaseVisionImage image = FirebaseVisionImage.fromMediaImage(media_image, rotation);
We can also get the instance of FirebaseVisionImage object from a file URI.

2. Create an instance of FirebaseVisionBarcodeDetector:

3. Finally, pass the image to the “detectInImage” method:

Get Information from barcodes

You can also go through the following link in order to get details:-
https://firebase.google.com/docs/ml-kit/android/read-barcodes
https://github.com/firebase/mlkit-material-android

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home