当前位置:网站首页>easyOCR 字符識別

easyOCR 字符識別

2022-07-05 14:45:00 天人合一peng

import easyocr
import cv2
import os
reader = easyocr.Reader(['en'],model_storage_directory="./easyOCRModel")

path = r"D:\BUFFER\Pycharm\RecognitionOCR\images\ROI_Images"

# path = r"D:\BUFFER\Pycharm\RecognitionOCR\images\rudeOCR"
for filename in os.listdir(path):  # listdir的參數是文件夾的路徑
    img_path = path + '\\' + filename
    # print(filenames)
    img_orig = cv2.imread(img_path, 1)
    # cv2.imshow("image", img_orig)
    # cv2.waitKey()
    result = reader.readtext(img_path)
    if result and result[0][2] >= 0.90:

        print(img_path)
        print(result[0][1])
        print(result[0][2])
        # str_j = 'python {}! format {}!'.format(666, 999)
        ocr_possible = ' {}-{}!'.format( result[0][1], result[0][2])

        cv2.putText(img_orig, ocr_possible , (2, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 0, 255), 2)
        cv2.imshow("image", img_orig)
        cv2.waitKey()



原网站

版权声明
本文为[天人合一peng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051442470222.html