Passport Validator
2023

What it does
Passport Validator takes an image of a scanned passport and returns the holder's structured information together with a separate portrait image. The project focuses on the machine-readable zone, or MRZ: the two lines of standardized characters printed at the bottom of a passport identity page.
Reading those lines is only the first step. OCR can produce text that looks plausible while changing a single character, and one character is enough to make a passport number or date wrong. The tool therefore treats extraction and validation as separate jobs.
How it works
PassportEye locates the MRZ and returns its raw text. I then parse the fields myself according to ICAO 9303, including the document type, name, nationality, passport number, date of birth, expiration date, and country-specific optional data.
The validator implements the ICAO check-digit algorithm for the passport number, birth date, and expiration date. Each check digit is calculated from the field that precedes it, so the program can report whether an extracted value is internally consistent instead of merely repeating the OCR output.
The country code is resolved through pycountry, and face_recognition isolates the portrait from the page and saves it separately. The command-line entry point keeps the workflow simple: provide an image, parse and validate the MRZ, then extract the face.
What I learned
The useful lesson was that standards make ambiguous documents tractable. OCR alone gives probabilities; ICAO 9303 adds positions, field lengths, and checksums that can challenge the OCR result. Combining a statistical tool with deterministic constraints produced something much more useful than either approach alone.
The project implements a focused subset of the standard rather than pretending to be a complete identity-verification system. It parses the fields present in the MRZ, validates three check digits, maps country codes, and preserves optional data without trying to infer what every country stores there.