Null check mrz_obj

This commit is contained in:
Nitwix
2025-04-12 22:29:54 +02:00
parent 1ec487f6ab
commit dde607d1a8

View File

@ -23,13 +23,15 @@ def process_passport(passport_b64: str) -> str:
image = Image.open(io.BytesIO(image_bytes)) image = Image.open(io.BytesIO(image_bytes))
tesseract_text = pytesseract.image_to_string(image, lang='eng') tesseract_text = pytesseract.image_to_string(image, lang='eng')
out_dict = { out_dict = {}
"country": mrz_obj.country, if not mrz_obj is None:
"names": mrz_obj.names, out_dict = {
"number": mrz_obj.number, "country": mrz_obj.country,
"surname": mrz_obj.surname, "names": mrz_obj.names,
"mrz": mrz_obj.aux["text"], "number": mrz_obj.number,
"raw": tesseract_text "surname": mrz_obj.surname,
} "mrz": mrz_obj.aux["text"],
}
out_dict["raw"] = tesseract_text
out = json.dumps(out_dict) out = json.dumps(out_dict)
return out return out