jllarraz / AndroidPassportReader

Android application to read passports with MRZ
122 stars 48 forks source link

Remove all whitespaces #14

Closed IvanSyabro closed 4 years ago

IvanSyabro commented 4 years ago

Hi, thanks for a great example of passport scanning via ML I've tried it with several documents and it works great except one of them. I've performed some debug actions and found that ML scanner determines excess whitespaces when there are actually no whitespaces in any line in MRZ. As a result it takes around one minute to scan password. I've solved that issue by removing whitespaces from the fullRead variable

So in OcrMrzDetectorProcessor class I replaced this line:

temp = temp.replace("\r".toRegex(), "").replace("\n".toRegex(), "").replace("\t".toRegex(), "")

with this one

temp = temp.replace("\r".toRegex(), "").replace("\n".toRegex(), "").replace("\t".toRegex(), "").replace(" ", "")

And now it works better. Maybe it will help you!

akeilox commented 4 years ago

On the note of white spaces I noticed for passports with middle names all the spacing are removed; replaces "<" with "" because it prints all the first names without separation. This is very common in Asian as well as other regions' names; John Doe Dee Dan Tan

Similar change was made to other related project where this was based on, please refer to https://github.com/tananaev/passport-reader/pull/18

akeilox commented 4 years ago

I too have noticed extended delay in detecting MRZ on some passports, even ones that I have quickly scanned before. I didnt pay attention if it was due to the white spaces. Normally I had to exit from the App completely and run it back on again and it will behave better.

Not sure if its related to white spaces (dont have access to the test passports at the moment) or it was a memory/leak related.

jllarraz commented 4 years ago

It's done