Administrator
2023-07-06 7284224d58773be6da3c569be3d54ac3b2646661
ocr/ocr_server.py
@@ -5,9 +5,9 @@
from http.server import BaseHTTPRequestHandler
import cv2
import ths_industry_util
import constant
from utils import ths_industry_util
from ocr import ocr_util
from ocr.ocr_util import OcrUtil
from third_data import kpl_util
from trade import bidding_money_manager
@@ -63,7 +63,7 @@
                        for r in range(0, rows):
                            for c in range(0, cols):
                                mat[r][c] = [datas[r * cols + c]]
                        # cv2.imwrite("D:/test.png", mat)
                        # cv2.imwrite(f"{constant.get_path_prefix()}/test.png", mat)
                        ocr_results = ocr_util.OcrUtil.ocr_with_key(mat, key)
                        if not ocr_results:
                            # 多重识别,防止识别出错
@@ -94,7 +94,7 @@
                        for r in range(0, rows):
                            for c in range(0, cols):
                                mat[r][c] = [datas[r * cols + c]]
                        # cv2.imwrite("D:/test.png", mat)
                        # cv2.imwrite(f"{constant.get_path_prefix()}/test.png", mat)
                        ocr_results = ocr_util.OcrUtil.ocr_with_key(mat, ".")
                        code_name = ""
                        for res in ocr_results:
@@ -114,7 +114,7 @@
                kpl_datas = kpl_util.parse_kpl_datas(results)
                if kpl_datas:
                    bidding_money_manager.set_bidding_money(kpl_datas)
                with open("D:/kpl.png", mode="wb") as f:
                with open(f"{constant.get_path_prefix()}/kpl.png", mode="wb") as f:
                    f.write(imgdata)
        except Exception as e:
            logging.exception(e)