AI-generated Key Takeaways
-
BarcodeScanning is used to get a BarcodeScanner for recognizing barcodes in an InputImage.
-
A BarcodeScanner is created using
getClient(BarcodeScannerOptions)orgetClient(), with the option using specified formats being recommended for better performance. -
To scan barcodes, first create an InputImage from a source like a Bitmap or ByteBuffer, and then process it using the BarcodeScanner's
process()method. -
Remember to call
BarcodeScanner.close()on the BarcodeScanner object when it's no longer needed to release resources.
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.