简单的python识别的代码_python 简单图像识别--验证码(示例代码)

python  简单图像识别--验证码

记录下,准备工作安装过程很是麻烦。

首先库:pytesseract,image,tesseract,PIL

windows安装PIL,直接exe进行安装更方便(https://files.cnblogs.com/files/Oran9e/PILwin64.zip)(https://files.cnblogs.com/files/Oran9e/PILwin32.zip)

安装 image:pip install image

安装 pytesseract:pip install pytesseract

安装 tesseract:pip install tesseract  (安装 tesseracr,这里是个坑,需要安装到C盘里C:\Program Files (x86)\Tesseract-OCR,也就是默认路径 ,不然运行 python 代码的时候调用不了 tesseract.exe )

修改 tesseract.py 代码:\python\Lib\site-packages\pytesseract\tesseract.py

tesseract_cmd 改成 tesseract.exe的路径,进行调用。

tesseract_cmd = ‘C:/Program Files (x86)/Tesseract-OCR/tesseract.exe‘

准备完上面的工作,基本上就可以进行简单的验证码识别了。

代码:

#coding=utf-8

from PIL import Image

import pytesseract

image = Image.open(‘2.jpg‘)

orange = pytesseract.image_to_string(image)

print orange

下篇文章将会写个自动识别验证码,实现自动登陆的小脚本。

任重而道远!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值