标签:识别 box pat ocr 配置 Fix str data- file
import pytesseract from PIL import Image im=Image.open(‘image.png‘) print(pytesseract.image_to_string(im))
安装注意:
环境变量需要配置两处
1、path
2、TESSDATA_PREFIX
初始路径
pytesseract.pytesseract.tesseract_cmd = ‘d://Tesseract-OCR//tesseract.exe‘
tessdata_dir_config = ‘--tessdata-dir "d://Tesseract-OCR//tessdata"‘
图像切割识别
im = Image.open(old_file) R,C = im.size newR = C//7 if right != 0: box = (left, low, right, high) else: box = (left,low,R,high) region = im.crop(box) s = pytesseract.image_to_string(region,lang=‘chi_sim‘)
标签:识别 box pat ocr 配置 Fix str data- file
原文地址:https://www.cnblogs.com/pythonclass/p/11957012.html