# BarcodeScanning

public class **BarcodeScanning** extends [Object](https://developer.android.com/reference/java/lang/Object.html)  
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](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScanner.md.txt) | [getClient](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScanning.md.txt#getClient(com.google.mlkit.vision.barcode.BarcodeScannerOptions))([BarcodeScannerOptions](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.md.txt) options) Creates a new instance of barcode scanner with the specified options. |
| static [BarcodeScanner](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScanner.md.txt) | [getClient](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScanning.md.txt#getClient())() Creates a new instance of barcode scanner with the default options. |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public static [BarcodeScanner](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScanner.md.txt)
**getClient** ([BarcodeScannerOptions](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.md.txt) 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](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/BarcodeScanner.md.txt)
**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.