import pytesseract | |
from IdentifyModel.cardModel import parse_id_card | |
from Plan.AiLLM import extract_entities | |
def ocr_recognition(image, validation_type, language): | |
try: | |
custom_config = r'--oem 3 --psm 6' | |
text = pytesseract.image_to_string(image, lang=language, config=custom_config) | |
entities = extract_entities(text) | |
return parse_id_card(text, validation_type, entities) | |
except Exception as e: | |
return str(e) | |