Python 进行 OCR识别 -- pytesseract库
程序员文章站
2022-05-29 07:56:22
pip install pytesseract 报错:tesseract is not installed or it's not in your path 下载安装 Tesseract OCR https://pan.baidu.com/s/1qXumxdltxOnb0geaE_1U Q 修改 p ......
pip install pytesseract
报错:tesseract is not installed or it's not in your path
- 下载安装 tesseract-ocr
- 修改 pytesseract 源码中的路径
- 文件位置: python安装目录 \lib\site-packages\pytesseract\pytesseract.py
- 将 tesseract_cmd 的值 改为 tesseract-ocr 的安装路径\tesseract.exe
识别中文需要新的字库
- https://pan.baidu.com/s/1gfspc5uef73b2oa8yudbgq
- 将下载的中文库放在 tesseract-ocr 安装目录下的 tessdata 文件夹中
图片:english.png
图片:chinese.png
识别
import pytesseract from pil import image im_en = image.open('english.png') im_ch = image.open('chinese.png') print('========识别字母========') print(pytesseract.image_to_string(im_en), '\n\n') print('========识别中文========') print(pytesseract.image_to_string(im_ch, lang='chi_sim'))
结果
上一篇: iframe 自适应高度JS代码,兼容FF ,IE
下一篇: 「BZOJ4173」数学