bonaparta13/mrz_scanner
bonaparta13/mrz_scanner open-source repository details.
- Stars
- 6
- Forks
- 19
- 最近推送(UTC)
- 2026年3月13日
- 项目状态
- 未归档
语言DartRubySwiftKotlinObjective-C
使用的依赖
依赖清单 6 项
- flutter
{"sdk":"flutter"} - camera
^0.12.0 - flutter_tesseract_ocr
^0.4.30 - path_provider
^2.1.5 - flutter_test开发依赖
{"sdk":"flutter"} - flutter_lints开发依赖
^2.0.0
原始 README
以下为英文项目原文快照,最新内容请访问 GitHub。
展开 / 收起项目 README
MRZ Scanner
A lightweight Flutter plugin for scanning and parsing Machine Readable Zones (MRZ) from passports, ID cards, and visas. Supports both live camera scanning and image file parsing.
Supported Formats
| Format | Description | Lines |
|---|---|---|
| TD1 | ID Cards | 3 x 30 chars |
| TD2 | ID Cards | 2 x 36 chars |
| TD3 | Passports | 2 x 44 chars |
| MRVA | Visas | 2 x 44 chars |
| MRVB | Visas | 2 x 36 chars |
Platform Support
| Android | iOS | |
|---|---|---|
| Support | SDK 24+ | iOS 13+ |
Note: Camera scanning requires a real device, not an emulator.
Setup
Android
Add to AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
iOS
Add to Info.plist:
<key>NSCameraUsageDescription</key>
<string>Allow Camera to scan MRZ</string>
Usage
import 'package:mrz_scanner/mrz_scanner.dart';
Camera Scanning
Use the MRZScanner widget for live camera-based scanning:
MRZScanner(
onSuccess: (mrzResult, lines) {
print(mrzResult.documentNumber);
print(mrzResult.givenNames);
print(mrzResult.surnames);
print(mrzResult.birthDate);
print(mrzResult.expiryDate);
print(mrzResult.sex);
print(mrzResult.countryCode);
},
)
Options
| Parameter | Type | Default | Description |
|---|---|---|---|
onSuccess |
Function(MRZResult, List<String>) |
required | Callback with parsed result and raw MRZ lines |
initialDirection |
CameraLensDirection |
back |
Camera to use |
showOverlay |
bool |
true |
Show document frame overlay |
controller |
MRZController? |
null |
Controller for resetting scan state |
Resetting the Scanner
Use a controller to reset scanning after a successful read:
final controller = MRZController();
MRZScanner(
controller: controller,
onSuccess: (result, lines) {
// Process result, then allow scanning again
controller.currentState?.resetScanning();
},
)
Image File Scanning
Use MRZScanner.scanImage() to parse an MRZ from a file path (e.g. from gallery or file picker):
try {
final result = await MRZScanner.scanImage('/path/to/document.jpg');
print(result.documentNumber);
} on FormatException {
print('No valid MRZ found in image');
}
MRZResult Fields
| Field | Type | Description |
|---|---|---|
documentType |
String |
Document type (P, I, V, etc.) |
countryCode |
String |
Issuing country code |
surnames |
String |
Holder's surnames |
givenNames |
String |
Holder's given names |
documentNumber |
String |
Document number |
nationalityCountryCode |
String |
Nationality country code |
birthDate |
DateTime |
Date of birth |
sex |
Sex |
Sex.male, Sex.female, or Sex.none |
expiryDate |
DateTime |
Expiry date |
personalNumber |
String |
Personal/optional number |
Demo
Demo
License
mrz_scanner is released under a MIT License. See LICENSE for details.