from paddleocr import PaddleOCR
from core.ocr import IdCardOcr
from core.direction import *

# 初始化ocr模型和后处理模型
ocr = PaddleOCR(use_angle_cls=True,
                rec_model_dir="./idcard_rec_infer/",
                det_model_dir="./idcard_det_infer/",
                cls_model_dir="idcard_cls_infer",
                rec_algorithm='CRNN',
                ocr_version='PP-OCRv2',
                rec_char_dict_path="./ppocr_keys_v1.txt",
                lang="ch", use_gpu=False)

# 定义文件路径
img_path = "images/back.jpeg"
image = cv2.imread(img_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# 反面
image_type = '1'

m = IdCardOcr(ocr)
res = m .predict(image, image_type)
print(res)