Detect Barcode Using Google Vision API

Barcode is a method of representing data in a visual, machine-readable form. It represents data by varying parallel lines in width and distance. In other words, we can say a barcode is a way to encode information in a visual pattern that a device (a barcode scanner) can read (those black lines and white spaces). A barcode scanner can read and translate this black and white bar pattern into a line of test that your retail point of sale system can understand.

Applications of Barcode:

1. Barcodes are used to identify products in retail stores.

2. Barcodes save time because It offers fast recognition and implementation of data.

3. Barcode provides security for our data.

Formats of Barcodes:

1. Code 128

2. Code 39

3. Code 93

4. Codabar

5. EAN-13

6. EAN-8

7. ITF

8. UPC-A

9. UPC-E

10. QR Code

11. PDF417

12. Aztec

13. Data Matrix

The Steps to Execution: 

Barcodes deliver automatic product identification, extremely fast recognition and implementation of data. There are following steps as below:

1.  At Build.Gradle file 

2. In your project-level build.gradle file, Ensure that both your buildscript and allprojects sections include Google’s Maven repository.

3. Include surfaceview in the layout file.

4. Create an Instance of BarcodeDetector class because It will detect the barcode of any format.

By default, it detects all format of barcodes.

5. If we want to detect QRCode or any specific type of barcode then we have to set barcode format.

6. Create an instance of CameraSource and pass the instance of Barcode detector.

7. Register the callbacks of surfaceview and start the camera after surface created

and stop the camera on destroying the surface.

8. Add callback of barcode processor for receiving barcode after scanning the barcode.    

 

Leave a Reply