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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bc25070 · Mar 1, 2025
Feb 2, 2025
Feb 2, 2025
Feb 8, 2025
Feb 26, 2025
Mar 1, 2025
Feb 26, 2025
Feb 2, 2025
Feb 2, 2025
Feb 26, 2025
Feb 26, 2025
Feb 26, 2025

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.6"))
]

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.

Credits

The project started as a fork of the public repository which I created when was working in App In The Air.

License

The library is distributed under the MIT LICENSE.