Mattijah / QKMRZScanner

Scan MRZ (Machine Readable Zone) from identity documents (passport, id, visa) using iPhone/iPad (iOS)
MIT License
133 stars 77 forks source link

Detecting "0" as "O" #12

Open brqgoo-zz opened 4 years ago

brqgoo-zz commented 4 years ago

Hi all, I've have implemented the library which works well on passports. However it detects "0" as "O" in some parts of ID card (TD1) MRZ zone.

For instance, it's perceiving serial number as "AO0G028686" which is actually: "A00G028686"

IMAGE 2020-07-13 15:17:14

Mattijah commented 4 years ago

Hi @brqgoo, thanks for reporting the issue. I will have a look whether we can improve this in some way. The problem here is that these passports & IDs don't always use the exactly same font style and so the recognition of 0 and O may sometimes fail.

bugrym commented 3 years ago

Hello @Mattijah. I faced with the same problem while scanning ID card. Is it possible to improve this? I was trying to solve this by my own, but haven't found anything yet. Best regards.

Mattijah commented 3 years ago

Hi @bugrym, it is certainly possible to improve this and I will try, I'm just currently way too busy working on some other stuff 😕 Hopefully, I'll find some time soon. In regards to some data that should (do) consist of numbers only you can fix this for now easily by yourself. Just check whether the string contains letters and if so replace them with numbers. This is handled to a certain extend by the parser too https://github.com/Mattijah/QKMRZParser/blob/master/QKMRZParser/MRZFieldFormatter.swift#L39-L52. I do understand that this is not an ideal fix and I'll have to improve the actual recognition, but at least a little help.

https://github.com/Mattijah/QKMRZParser/blob/master/QKMRZParser/MRZFieldFormatter.swift#L119-L128

bugrym commented 3 years ago

@Mattijah I got it. Thanks a lot. I'll looking forward for any updates from yours.

emirbeytekin commented 3 years ago

the problem continues..

tolgasayan2 commented 2 years ago

@emirbeytekin at MRZFieldFormatter file; create a String extension in order to take elements by one by from an array to replace and to correct func; add case .documentNumber:

      return string[0] + string[1].replace("O", with: "0") + string[2] + string[3].replace("0", with: "O") + string[4] + string[5] + string[6] + string[7] + string[8]
Mattijah commented 2 years ago

@emirbeytekin it continues because it hasn't been resolved.