[原]Python 使用pytesseract库识别验证码(MAC系统)

OCR环境搭建与Python实现
本文详细介绍如何在Mac环境下安装配置OCR所需的各种依赖库,包括Python环境、PIL图像处理库、Leptonica、Tesseract-OCR等,并通过Python脚本实现图片文字识别。


1.安装python

brew install python


2.安装PIL及图片格式支持

下载
http://www.pythonware.com/products/pil/index.htm

解压
tar -xzf Imaging-1.1.7.tar.gz

安装PIL
cd Imaging-1.1.7
sudo python setup.py install

安装图片格式支持
brew install libpng
brew install jpeg
brew install libtiff

(注:安装了libtiff后PIL仍然无法支持tiff格式的图片,原因还没搞清楚)


3.安装leptonica

brew install leptonica


4.安装tesseract-ocr

brew install tesseract


5.安装pytesseract库

安装pip工具
sudo easy_install pip

安装pytesseract
sudo pip install pytesseract

 

6.写python脚本并运行

import pytesseract
from PIL import Image

image = Image.open('yzm.png')
image.load()
image.split()
vcode = pytesseract.image_to_string(image)
print vcode

其中yzm.png为验证码图片,和py脚本同一个目录

py脚本保存为yzm.py,运行之

python yzm.py

显示结果

 

转载于:https://www.cnblogs.com/liuqing0328/p/5914074.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值