evermeer / PassportScanner

Scan the MRZ code of a passport and extract the firstname, lastname, passport number, nationality, date of birth, expiration date and personal numer.
BSD 3-Clause "New" or "Revised" License
464 stars 102 forks source link

Add support to scan the MRZ of an ID card #5

Closed evermeer closed 6 years ago

evermeer commented 8 years ago

As reported by @jrodriguezq there is no support for the MRZ for an ID card. I will add this as an enhanecment later.

Original question:

The last commit fixes the issue that I had with the camera, now it looks like this: img_3139

The OCR it's working, but I'm not able to correctly read the MRZ. As you can see, the image appears to be clear enough. The usual case of the mrz captured it's something like this:

INCHL1D41230409D26<<<<<<<<<<<< 9002063M2002064CHL17409866<2<6 CORTES<CONTRERAS<<SERGIO<JAV ll 12

This appears to be almost correct, but some numbers and blank characters usually stand in the way and I'm not able to scan the MRZ. Is there any configuration that I'm missing?

Again, many thanks for the library.

sahar12345 commented 7 years ago

Hi can I talk to u about the programe

evermeer commented 7 years ago

@sahar12345 sure

sahar12345 commented 7 years ago

I want to make programe in phone app like netbeans and xamrine must make iOS and android separate and I want connect to server can u the programe read I don't understand good to the folder code u put and how communicate with server that make confused

sahar12345 commented 7 years ago

Netbeans in java programe

sahar12345 commented 7 years ago

If that reading for national I'd card like Japan or negirea national card like this programe of passport

sahar12345 commented 7 years ago

And so thank you so much

evermeer commented 7 years ago

Passport scanner is a complete native iOS only solution. There is no support for Android. There is no server required. The OCR is done on the phone itself.

If you want to make an iOS app that sends the result of a scan to your own server, then you have to create your own logic for that. In the demo app you will have the file ViewController.swift which calls the PassportScanner interface. There in the function processMRZ you can add logic for handling the MRZ information.

sahar12345 commented 7 years ago

Thank you but in my opinion that netbeans can make programe to all kinds iOS and android and its supported,that idea of logic server I will make today and show you and am glad if reply on results that from ur kind,thnx to u.

punto2018 commented 6 years ago

Any news for this topic? Currently I'm working with 3 lines passports so I'm starting to develop the validator. I can't find technical infos (checksum, char position semantic, etc) in order to integrate the support.

evermeer commented 6 years ago

@punto2018 For the password MRZ I was able to create the logic based on what was described on wikipedia. See https://en.wikipedia.org/wiki/Machine-readable_passport as you can see there is also a description for official travel documents with 3 lines. That should be enough information.

punto2018 commented 6 years ago

Thanks for your reply. I'm using the official specifications document for a better parsing (https://www.icao.int/publications/Documents/9303_p5_cons_en.pdf). I'm able to acquire and parse a 3 lines MRZ, but I'm experimenting some issues with the camera. I don't want mix topics here, I will open a new issue.

Thanks

punto2018 commented 6 years ago

Good news, resolving the camera issues it seem that the parsing is working fine. If you agree I can share my changes and generate a pull request. The idea is to add a property in order to easily switch MRZ parsing type (2 lines or 3 lines), using the 2 lines as default for retrocompatibility reasons.

evermeer commented 6 years ago

A PR for that is definitely welcome! Maybe it's possible to autodetect it it's a MRZ 2 or 3? If you have an OCR result where 3 lines have more than 30 characters, then it's probably a MRZ 3?

punto2018 commented 6 years ago

This approach can be used, my only concern is in the performance in trying both parsers. It is not possible make simple assumptions in the number of lines. Italian ID Card for example have a barcode on top of MRZ and often the user also frame it, resulting in a 4 lines OCR result, where the first line is something like "I 1 III 1 || \ 1 .....". In this case filtering the first line is an important improvement in MRZ scan. Anyway, I suggest a 3 value parsing type: auto, 2 lines, 3 lines, where auto can use a sort of "smart" choice in order to select the first parser to try.

What do you think?

evermeer commented 6 years ago

Sounds good

Mattijah commented 6 years ago

@evermeer, @punto2018, @sahar12345. Here is a MRZ parser with support of all official documents. On top of that it does some OCR cleaning too. All you need to do is just set it up as a pod. Enjoy

https://github.com/Mattijah/QKMRZParser

evermeer commented 6 years ago

The PR has been merged, pushed and published. There is now support for 3 line MRZ. Thanks @punto2018 !