MLKitBarcodeScanning Framework Reference

BarcodeScanner

class BarcodeScanner : NSObject

A barcode scanner that scans barcodes in an image.

  • Returns a barcode scanner with the given options.

    Declaration

    Swift

    class func barcodeScanner(options: MLKBarcodeScannerOptions) -> Self

    Parameters

    options

    Options containing barcode scanner configuration.

    Return Value

    A barcode scanner configured with the given options.

  • Returns a barcode scanner with the default options.

    Declaration

    Swift

    class func barcodeScanner() -> Self

    Return Value

    A barcode scanner configured with the default options.

  • Unavailable. Use the class methods.

  • Processes the given image for barcode scanning.

    Declaration

    Swift

    func process(_ image: MLKitCompatibleImage) async throws -> [MLKBarcode]

    Parameters

    image

    The image to process.

    completion

    Handler to call back on the main queue with barcodes scanned or error.

  • Returns barcode results in the given image or nil if there was an error. The barcode scanning is performed synchronously on the calling thread.

    It is advised to call this method off the main thread to avoid blocking the UI. As a result, an NSException is raised if this method is called on the main thread.

    Declaration

    Swift

    func results(in image: MLKitCompatibleImage) throws -> [MLKBarcode]

    Parameters

    image

    The image to get results in.

    error

    An optional error parameter populated when there is an error getting results.

    Return Value

    Array of barcode results in the given image or nil if there was an error.