from concurrent.futures import ThreadPoolExecutor

import cv2
import yaml
from aip import AipOcr

from common import Constant
from util import YmlUtils
from util.OcrBaiduSdk import OcrBaiduSdk

client = AipOcr(str(28173504), 'kqrFE7VuygIaFer7z6cRxzoi',
                     'yp7xBokyl4TItyGhay7skAN1cMwfvEXf')
im0 = cv2.imread('/home/chenyukun/healthCode/jitimg/zc0vlz87kv_1667879673871_cityImage.jpg')

# or_result, or_image = cv2.imencode(".jpg", im0)
with open("/home/chenyukun/fk/fk_application.yml", 'r', encoding=Constant.UTF_8) as f:
    file_content = f.read()
    content = yaml.load(file_content, yaml.FullLoader)
    if not content:
        raise Exception("配置项不能为空：{}".format(Constant.APPLICATION_CONFIG))
    print("读取配置文件完成！")
    orc = OcrBaiduSdk(content)

def aa(a):
    res_image = orc.universal_text_recognition(im0,'aaaaaaaa')
    # res_image = orc.license_plate_recognition(im0,'aa')
    print(res_image)
    # print(res_image1)
with ThreadPoolExecutor(max_workers=100) as t:
    t.map(aa, range(1))







# or_result, or_image = cv2.imencode(".jpg", image)
# res_image = self.client.licensePlate(or_image.tobytes())