Library for scanning documents via Machine Readable Zones using Vision API
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.0.0"))
]
The library has an SPM dependency for MRZ code parsing.
Usage
- For both image scanning and live scanning, we need to create
ScanningConfiguration
ScanningConfiguration(orientation: .up, regionOfInterest: roi, minimumTextHeight: 0.1, recognitionLevel: .fast)
- After you need to start scanning
/// Live scanning
for try await scanningResult in MRZScanner.scanLive(imageStream: imageStream, configuration: configuration) {
// Handle `scanningResult` here
}
/// Single scanning
let scanningResult = try await MRZScanner.scanSingle(image: image, configuration: configuration)
Also, for the convenience of transforming coordinates into a normalized form and back, there is a static method convertRect
MRZScanner.convertRect(to: .normalizedRect, rect: rect, imageWidth: imageWidth, imageHeight: imageHeight)
Example
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.