Python pytesseract验证码识别库用法解析
作者:Alpiny’ Blog 时间:2023-06-13 19:04:02
环境 centos7 python3
pytesseract只是tesseract-ocr的一种实现接口。所以要先安装tesseract-ocr(大名鼎鼎的开源的OCR识别引擎)。
依赖安装
yum install-y automake autoconf libtool gcc gcc-c++
yum install-y libpng-devel libjpeg-devel libtiff-devel giflib-devel
安装依赖的leptonica库
wget http://www.leptonica.com/source/leptonica-1.72.tar.gz
tar -xzvf leptonica-1.72.tar.gz
cd leptonica-1.72
./configure
make && make install
安装tesseract-ocr
wget https://github.com/tesseract-ocr/tesseract/archive/3.04.00.tar.gz
mv 3.04.00 Tesseract3.04.00.tar.gz
tar -xvf Tesseract3.04.00.tar.gz
cd tesseract-3.04.00/
./configure
make && make install
安装语言包:
wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata #英文默认包
wget https://github.com/tesseract-ocr/tessdata/raw/master/chi_sim.traineddata #中文繁体
wget https://github.com/tesseract-ocr/tessdata/raw/master/chi_tra.traineddata #中文简体
cp/mv *.traineddata /usr/local/share/tessdata/ #移动下载的包到/usr/local/share/tessdata/ 这个路径下,也可以手动移动
安装pytesseract:
pip install Pillow
pip install pytesseract
至此安装完成,附上使用方法:
import pytesseract
from PIL import Imag
image = Image.open("port_img.jpg")
text = pytesseract.image_to_string(image)
print(text)
来源:https://www.cnblogs.com/alpiny/p/10487191.html
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python configparser中默认值的设定方式
SpringBoot配置连接两个或多个数据库的实现
Python爬虫DNS解析缓存方法实例分析
MySQL如何查看元数据锁阻塞在哪里
vue中Axios添加拦截器刷新token的实现方法
Pycharm无法显示动态图片的解决方法
![](https://img.aspxhome.com/file/2023/0/89420_0s.jpg)
python网络编程socket实现服务端、客户端操作详解
windows server 2003+IIS6 出现 'ASP 不正常,因为执行请求
不要使用@import[译]
![](https://img.aspxhome.com/file/UploadPic/20095/1/01-39s.gif)
PyPy 如何让Python代码运行得和C一样快
![](https://img.aspxhome.com/file/2023/2/81672_0s.gif)
深入理解python try异常处理机制
vue中的stylus及stylus-loader版本问题
基于python实现高速视频传输程序
Python 排序最长英文单词链(列表中前一个单词末字母是下一个单词的首字母)
用 Python 元类的特性实现 ORM 框架
![](https://img.aspxhome.com/file/2023/3/127313_0s.png)
Python实现简单截取中文字符串的方法
vscode调试container中的程序的方法步骤
![](https://img.aspxhome.com/file/2023/8/130898_0s.png)
python控制windows剪贴板,向剪贴板中写入图片的实例
jupyter notebook更换皮肤主题的实现
![](https://img.aspxhome.com/file/2023/9/131559_0s.jpg)