BarcodeScanner

Represents a Barcode Scanner that uses ML Kit Barcodes.

The BarcodeScanner can be used in a Frame Processor by calling scanCodes, or for static images by calling scanCodesInImageAsync. It holds native resources: dispose it (or use it in a use { } block) once it is no longer needed.

val scanner = createBarcodeScanner(BarcodeScannerOptions(listOf(TargetBarcodeFormat.ALL_FORMATS)))
frameOutput.setOnFrameCallback { frame ->
frame.use { scanner.scanCodes(it) }.forEach { println("Barcode value: ${it.rawValue}") }
}

See also

Functions

Link copied to clipboard
open override fun close()

Same as dispose, to use a BarcodeScanner with use { }.

Link copied to clipboard
abstract fun dispose()

Disposes this BarcodeScanner, releasing its native resources. It must not be used afterwards.

Link copied to clipboard
abstract fun scanCodes(frame: Frame): List<Barcode>

Synchronously detects Barcodes in the given frame.

Link copied to clipboard
abstract suspend fun scanCodesAsync(frame: Frame): List<Barcode>

Asynchronously detects Barcodes in the given frame.

Link copied to clipboard
abstract suspend fun scanCodesInImageAsync(image: Image): List<Barcode>

Asynchronously detects Barcodes in the given image.