Parse MRZ (Machine Readable Zone) from identity documents. Heavily inspired by QKMRZParser.
- TD1
- TD2
- TD3
- MRV-A
- MRV-B
Add to pubspec.yaml
dependencies:
mrz_parser: ^2.0.0final mrz = [
'P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<',
'L898902C36UTO7408122F1204159ZE184226B<<<<<10'
];
final result = MRZParser.tryParse(mrz);
// Alternatively use parse and catch MRZException descendants
try {
final result = MRZParser.parse(mrz);
} on MRZException catch(e) {
print(e);
}final driverLicense = [
'D1NLD11234567890ABCDEFGHIJKLM7'
];
final result = DriverLicenseParser.tryParse(driverLicense);
// Alternatively use parse and catch MRZException descendants
try {
final result = DriverLicenseParser.parse(driverLicense);
print(result.documentNumber); // 1234567890
print(result.countryCode); // NLD
} on MRZException catch(e) {
print(e);
}Performance benchmarks for parsing different MRZ formats:
| Format | Type | Average Parse Time |
|---|---|---|
| TD3 | Passport | ~103.34 µs |
| TD2 | ID Card | ~13.81 µs |
| TD1 | ID Card | ~15.67 µs |
| Driver License | Driver License | ~16.33 µs |
Run benchmarks yourself:
dart run benchmark/mrz_parser_benchmark.dartmrz_parser is released under a MIT License. See LICENSE for details.