File size: 459 Bytes
e651999
 
 
03b6d75
e651999
 
 
 
 
c5475c8
03b6d75
 
e651999
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)