BarcodeScanning

public class BarcodeScanning extends Object

Entry point to get a BarcodeScanner for recognizing barcodes (in a variety of 1D and 2D formats) in a supplied InputImage.

A BarcodeScanner is created via getClient(BarcodeScannerOptions) or getClient(). The default option is not recommended because it tries to scan all barcode formats, which is slow. For example, the code below creates a barcode scanner for Barcode.FORMAT_PDF417.

 BarcodeScanner barcodeScanner =
      BarcodeScanning.getClient(
          new BarcodeScannerOptions.Builder()
              .setBarcodeFormats(Barcode.FORMAT_PDF417)
              .build()); 

To perform barcode scanning in an image, you first need to create an instance of InputImage from a Bitmap, ByteBuffer, etc. See InputImage documentation for more details. For example, the code below creates an InputImage from an Image.

 InputImage image = InputImage.fromMediaImage(mediaImage, rotationDegrees); 

Then the code below can scan barcodes in the supplied InputImage.

 Task<List<Barcode>> task = barcodeScannerClient.process(image);
 task.addOnSuccessListener(...).addOnFailureListener(...); 

Public Method Summary

static BarcodeScanner
getClient(BarcodeScannerOptions options)
Creates a new instance of barcode scanner with the specified options.
static BarcodeScanner
getClient()
Creates a new instance of barcode scanner with the default options.

Inherited Method Summary

Public Methods

public static BarcodeScanner getClient (BarcodeScannerOptions options)

Creates a new instance of barcode scanner with the specified options.

To release the resources associated with a BarcodeScanner, you need to ensure that BarcodeScanner.close() is called on the resulting BarcodeScanner object once it will no longer be used.

public static BarcodeScanner getClient ()

Creates a new instance of barcode scanner with the default options.

To release the resources associated with a BarcodeScanner, you need to ensure that BarcodeScanner.close() is called on the resulting BarcodeScanner object once it will no longer be used.