Google is committed to advancing racial equity for Black communities. See how.

BarcodeDetector

public final class BarcodeDetector extends Detector<Barcode>

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

Build new BarcodeDetector instances using BarcodeDetector.Builder. By default, BarcodeDetector searches for barcodes in every supported format. For the best performance it is highly recommended that you specify a narrower set of barcode formats to detect. For example, to create a detector that recognizes only Data Matrix and QR codes:

BarcodeDetector detector = new BarcodeDetector.Builder(context)
     .setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE)
     .build();
 
Recognition results are returned by detect(Frame) as Barcode instances.

Adding the vision functionality dependency to your project's AndroidManifest.xml will indicate to the installer that it should download the dependency on application install.

Nested Class Summary

class BarcodeDetector.Builder Barcode detector builder. 

Public Method Summary

SparseArray<Barcode>
detect(Frame frame)
Recognizes barcodes in the supplied Frame.
boolean
void

Inherited Method Summary

Public Methods

public SparseArray<Barcode> detect (Frame frame)

Recognizes barcodes in the supplied Frame.

Returns
  • mapping of int to Barcode, where the int domain represents an opaque ID for the barcode. Identical barcodes (as determined by their raw value) will have the same ID across frames.

public boolean isOperational ()

public void release ()