FirebaseVisionBarcodeDetector

public class FirebaseVisionBarcodeDetector extends Object
implements Closeable Closeable

Recognizes barcodes (in a variety of 1D and 2D formats) in a supplied FirebaseVisionImage.

A barcode detector is created via getVisionBarcodeDetector(FirebaseVisionBarcodeDetectorOptions) or getVisionBarcodeDetector(). The default option is not recommended because it tries to detect all barcode formats, which is slow. For example, the code below creates a barcode detector for FORMAT_PDF417.

 
 FirebaseVisionBarcodeDetector barcodeDetector =
      FirebaseVision.getInstance().getVisionBarcodeDetector(
          new FirebaseVisionBarcodeDetectorOptions.Builder()
              .setBarcodeFormats(FirebaseVisionBarcode.FORMAT_PDF417)
              .build());
 

 
To perform barcode detection in an image, you first need to create an instance of FirebaseVisionImage from a Bitmap, ByteBuffer, etc. See FirebaseVisionImage documentation for more details. For example, the code below creates a FirebaseVisionImage from a Image.
 FirebaseVisionImage image =
    FirebaseVisionImage.fromMediaImage(mediaImage, ImageFormat.YUV_420_888);
 
Then the code below can detect barcodes in the supplied FirebaseVisionImage.

 Task<List<FirebaseVisionBarcode>> task = barcodeDetector.detectInImage(image);
 task.addOnSuccessListener(...).addOnFailureListener(...);
 

Public Method Summary

void
close()
Closes this FirebaseVisionBarcodeDetector and releases its model.
Task<List<FirebaseVisionBarcode>>
detectInImage(FirebaseVisionImage image)
Detects barcodes from the supplied image.

Inherited Method Summary

Public Methods

public void close ()

Closes this FirebaseVisionBarcodeDetector and releases its model.

Throws
IOException

public Task<List<FirebaseVisionBarcode>> detectInImage (FirebaseVisionImage image)

Detects barcodes from the supplied image.

For best efficiency, create a FirebaseVisionImage object using one of the following ways:

All other FirebaseVisionImage factory methods will work as well, but possibly slightly slower.

To get the best detection result, we recommend the following:

Returns

Send feedback about...

Need help? Visit our support page.