tesseract的 安装以及使用
一:tesseract 的安装
(1)Tesseract本身没有windows的安装包,不过它指定了一个第三方的封装的windows安装包,在其wiki上有说明,大家可直接到这个地址进行下载: https://digi.bib.uni-mannheim.de/tesseract/
下载后就是一个exe安装包,直接右击安装即可,安装完成之后,配置一下环境变量,编辑 系统变量里面 path,
记得一定要配置环境变量
(2)安装成功之后,win+r --》cmd——》进入dos命令窗口——》输入tesseract
如图:
(3)安装Python的封装接口
1.pip install pillow
2.pip insatll pytesseract
只有前面两步成功了才可以执行第三步
二:在代码中的简单使用
import pytesseract
from PIL import Image
img=Image.open(‘5.png’)# 5.png是你将要识别的图片
img=img.convert(‘RGB’)
print(pytesseract.image_to_string(img))
三:在代码中使用时可能会遇到以下情况
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your path
解决方法:首先找到C:\Program Files\Python36\Lib\site-packages\pytesseract\pytesseract.py
然后将源码中的:
tesseract_cmd = ‘tesseract’
更改为:
tesseract_cmd = r’C:\Program Files (x86)\Tesseract-OCR\tesseract.exe’
再次运行之前的PY脚本,成功.
tesseract的基本简单使用
最新推荐文章于 2024-04-19 14:13:29 发布