python
主页 > 脚本 > python >

python识别文字(基于tesseract)的代码

2019-08-24 | 秩名 | 点击:

Ubuntu版本:

1.tesseract-ocr安装

 

sudo apt-get install tesseract-ocr

2.pytesseract安装
 
 
sudo pip install pytesseract

3.Pillow 安装
 
 
sudo pip install pillow

开始写代码:

 
from PIL import Image
from pytesseract import pytesseract
image = Image.open('test.png')
code = pytesseract.image_to_string(image,lang='chi_sim')
print(code)

报错了:



找到路径,发现没有chi_sim.traineddata这个训练包

# 安装训练数据(equ为数学公式包)
sudo apt-get install tesseract-ocr-eng tesseract-ocr-chi-sim tesseract-ocr-equ

安装之后就会有训练包了,可以正常运行。



英文识别正确率较高,中文就比较鸡肋了。


原文链接:https://www.cnblogs.com/codeDevotee/p/11376572.html
相关文章
最新更新