Administrator
2025-08-29 e95ea73d04c06f4cd46a3d1497c39c80352a8cd0
ocr/ocr_util.py
@@ -1,19 +1,25 @@
import re
import time
import cv2
import easyocr
from cnocr import CnOcr
try:
    import easyocr
    from cnocr import CnOcr
except:
    pass
# 图像识别类
class OcrUtil:
    __ocr = CnOcr()
    reader = easyocr.Reader(['en'], gpu=False)
    reader = easyocr.Reader(['ch_sim', 'en'], gpu=False)
    @classmethod
    def ocr(cls, mat):
        res = cls.__ocr.ocr(mat)
        return res
    @classmethod
    def easy_ocr(cls, mat):
        res = cls.reader.readtext(mat, detail=1)
        return res
    # 返回(识别内容,位置信息)
@@ -48,5 +54,4 @@
if __name__ == "__main__":
    result = OcrUtil.ocr_num("D:/test1.png", "000977")
    print(result)
    pass