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

When scanning a real passport, it has a hard time to scan the MRZ #41

Open LaurentDaudelin opened 3 years ago

LaurentDaudelin commented 3 years ago

Not sure why. I have both a Canadian and US passport. The Canadian did scan on the first try. I got one shot at the US but subsequent attempts failed. I just get this warning in the console:

Scan quality insufficient : 0.0
2020-12-21 12:03:57.630215-0500 PassportScanner[1519:784903] [Unknown process name] CGImageCreate: invalid image alphaInfo: kCGImageAlphaNone. It should be kCGImageAlphaNoneSkipLast
- Start recognize
Scan result : bylaw 1w xf I  L

I have ideal light, the code appears clearly on the iPhone 11 that I'm using.

evermeer commented 3 years ago

As you can see the Scan result shows some gibberish. For the scan I am using the tesseract library I have seen before that certain passports have bad scan results. I added some filters, but probably the standard does not work well with US passports You could try playing around with the parameters that are trying to improve the scan result You can find these in the lines below line 144 in https://github.com/evermeer/PassportScanner/blob/master/Pod/PassportScannerController.swift If you are able to set better parameters, then I would really like to hear what those are.