python使用 pytesseract + tesseract-ocr 进行验证码识别
tesseract
tesseract-ocr/tesseract: 是一个开源的光学字符识别(OCR)引擎,适用于从图像中提取和识别文本。特点是可以识别多种语言,具有较高的识别准确率,并且支持命令行和API调用。
项目地址:https://gitcode.com/gh_mirrors/te/tesseract

·
使用 pytesseract + tesseract-ocr 进行验证码识别,需要安装的第三方库:pytesseract 、tesseract-ocr,在使用pytesseract 之前,必须安装tesseract-ocr,因为 pytesseract 依赖于tesseract-ocr,否则无法使用。
1、tesseract-ocr下载安装与配置:tesseract-ocr下载安装与配置
2、pytesseract 安装:pip install pytesseract
3、修改pytesseract.py脚本
在python的安装目录下找到pytesseract 的安装路径,在pytesseract 文件夹下的pytesseract.py脚本中,用记事本打开pytesseract.py,通过ctrl+f快速搜索功能定位tesseract_cmd,修改后面的文件路径。
4、用pytesseract识别验证码
from PIL import Image
import pytesseract
# 用pytesseract识别验证码
# 1:打开需要识别的图片
image = Image.open(r'image\code.png')
# 2:pytesseract识别为字符串
code = pytesseract.image_to_string(image)
# 3:输出识别的内容
print(code)




tesseract-ocr/tesseract: 是一个开源的光学字符识别(OCR)引擎,适用于从图像中提取和识别文本。特点是可以识别多种语言,具有较高的识别准确率,并且支持命令行和API调用。
最近提交(Master分支:5 个月前 )
014b9d00 - 1 个月前
13c966b7 - 1 个月前
更多推荐
所有评论(0)