码迷,mamicode.com
首页 > 其他好文 > 详细

pytesseract文字识别

时间:2019-11-29 12:47:06      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:识别   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)

 

pytesseract文字识别

标签:识别   box   pat   ocr   配置   Fix   str   data-   file   

原文地址:https://www.cnblogs.com/pythonclass/p/11957012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!