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
457 stars 101 forks source link

How to validate 3-lines MRZ? #13

Closed andymedvedev closed 6 years ago

andymedvedev commented 7 years ago

Hello @evermeer, awesome work!

I met the challenge - how to validate second line of triple-lined MRZ. I saw the wikipedia but there is no exhaustive info about how to do that. And other question... in your MRZ.swift i saw that you extract passportNumber like two leading letters and other is numbers.. where you found this format? I want the same explanation for document number for triple-lined MRZ's.

Thanks in advance!

evermeer commented 7 years ago

Doing a 3 line MRZ code is also on my wishlist. See https://github.com/evermeer/PassportScanner/issues/5

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.

andymedvedev commented 7 years ago

@evermeer in wiki is written that passport number consist of alpha+num+< but in your code for passport number there is only two leading characters satisfying this condition, other chars is numbers. Code snippet: passportNumber = line2.subString(0, to: 1) + line2.subString(2, to: 8).toNumber() Where you obtained this info?

evermeer commented 7 years ago

The only reason why I did that is to clean up the last part of the number. The .toNumber() function will replace none numeric characters to numeric characters that look similar. So it will replace an O with an 0. I believe in all cases (I'm not 100% sure) only the first 2 characters can be alphanumeric. So those are not cleaned up.

evermeer commented 6 years ago

Closing this since the actual 3 line MRZ issue is registered here: #5