Skip to content

Library for scanning documents via MRZ (Machine Readable Zones) using  Vision API

License

Notifications You must be signed in to change notification settings

romanmazeev/MRZScanner

Repository files navigation

Build and test SPM

MRZScanner

Library for scanning documents via MRZ using  Vision API.

Requirements

  • iOS 13.0+
  • macOS 10.15+
  • Mac Catalyst 13.0+
  • tvOS 13.0+

Installation guide

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/romanmazeev/MRZScanner.git", .upToNextMajor(from: "1.1.0"))
]

The library has an SPM dependency for MRZ code parsing.

Usage

  1. For both image scanning and live scanning, we need to create ScanningConfiguration
ScanningConfiguration(orientation: .up, regionOfInterest: roi, minimumTextHeight: 0.1, recognitionLevel: .fast)
  1. After you need to start scanning
/// Live scanning
for try await scanningResult in imageStream.scanForMRZCode(configuration: configuration) {
    // Handle `scanningResult` here
    
    // Use `return` to cancel scanning
    return
}

/// Single scanning
let scanningResult = try await image.scanForMRZCode(configuration: configuration)

Example

gif

The example project is located inside the Example folder. To run it, you need a device with the minimum required OS version.

License

The library is distributed under the MIT LICENSE.