Android APIs
public final class

BarcodeDetector

extends Detector<Barcode>
java.lang.Object
   ↳ com.google.android.gms.vision.Detector<com.google.android.gms.vision.barcode.Barcode>
     ↳ com.google.android.gms.vision.barcode.BarcodeDetector

Class Overview

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

Build new BarcodeDetector instances using BarcodeDetector.Builder. 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();
 
The full list of supported formats (these constants may be passed into setBarcodeFormats(int)): 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.

Summary

Nested Classes
class BarcodeDetector.Builder Barcode detector builder. 
Public Methods
SparseArray<Barcode> detect(Frame frame)
Recognizes barcodes in the supplied Frame.
boolean isOperational()
Indicates whether the detector has all of the required dependencies available locally in order to do detection.
[Expand]
Inherited Methods
From class com.google.android.gms.vision.Detector
From class java.lang.Object

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 ()

Indicates whether the detector has all of the required dependencies available locally in order to do detection.

When an app is first installed, it may be necessary to download required files. If this returns false, those files are not yet available. Usually this download is taken care of at application install time, but this is not guaranteed. In some cases the download may have been delayed.

If your code has added a processor, an indication of the detector operational state is also indicated with the detectorIsOperational() method. You can check this in your app as it processes detection results, and can convey this state to the user if appropriate.

Returns
  • true if the detector is operational, false if the dependency download is in progress