BarcodeScanner

interface BarcodeScanner extends HybridObject

Represents a Barcode Scanner that uses MLKit Barcodes.

The BarcodeScanner can be used in a Frame Processor by calling scanCodes(...).

Methods

scanCodes()

scanCodes(frame: Frame): Barcode[]

Synchronously detects Barcodes in the given Frame.

All coordinates in the Barcode are relative to the Frame's coordinate system.

You can convert Barcode coordinates to Camera coordinates using Frame.convertFramePointToCameraPoint(...), and then convert the Camera coordinates to Preview View coordinates using PreviewViewMethods.convertCameraPointToViewPoint(...).

Example

const scanner = // ...
const frame = // ...
const previewView = // ...

const barcodes = scanner.scanCodes(frame)
for (const barcode of barcodes) {
  console.log('Barcode value:', barcode.rawValue)
  for (const point of barcode.cornerPoints) {
    const cameraPoint = frame.convertFramePointToCameraPoint(point)
    const previewPoint = previewView.convertCameraPointToViewPoint(cameraPoint)
    console.log('Corner Point:', previewPoint)
  }
}

scanCodesAsync()

scanCodesAsync(frame: Frame): Promise<Barcode[]>

Asynchronously detects Barcodes in the given Frame.

See

scanCodes