【python 图像识别】图像识别从菜鸟走向大神系列1
2017-08-28 09:09
591 查看
一、安装配置(python2.7)
2
3
4
5
1
2
3
4
5
二、识别英文
三、识别验证码
二、实现源代码
1、识别英文
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2、识别验证码
1.pip install pytesseract 2、pip install pyocr 3、pip install pillow 4、安装tesseract-ocr:http://jaist.dl.sourceforge.net/project/tesseract-ocr-alt/tesseract-ocr-setup-3.02.02.exe,安装在C:\Program Files\下 5、找到 pytesseract.py 更改 tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'1
2
3
4
5
1
2
3
4
5
二、识别英文
三、识别验证码
二、实现源代码
1、识别英文
#-*-coding:utf-8-*- import sys reload(sys) sys.setdefaultencoding('utf-8') import time time1 = time.time() from PIL import Image import pytesseract image = Image.open(r'D:\Program Files\Python27\Lib\site-packages\pytesseract\test.png') code = pytesseract.image_to_string(image) print(code)1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2、识别验证码
#-*-coding:utf-8-*- import sys reload(sys) sys.setdefaultencoding('utf-8') import time time1 = time.time() from PIL import Image import pytesseract ###########二值化算法 def binarizing(img,threshold): pixdata = img.load() w, h = img.size for y in range(h): for x in range(w): if pixdata[x, y] < threshold: pixdata[x, y] = 0 else: pixdata[x, y] = 255 return img image = Image.open(r'E:\taqu\12.png') ###########去除干扰线算法 def depoint(img): #input: gray image pixdata = img.load() w,h = img.size for y in range(1,h-1): for x in range(1,w-1): count = 0 if pixdata[x,y-1] > 245: count = count + 1 if pixdata[x,y+1] > 245: count = count + 1 if pixdata[x-1,y] > 245: count = count + 1 if pixdata[x+1,y] > 245: count = count + 1 if count > 2: pixdata[x,y] = 255 return img # 转化为灰度图 img = image.convert('L') # 把图片变成二值图像。 img1=binarizing(img,190) # img2=depoint(img1) img1.show() code = pytesseract.image_to_string(img1) print "识别该验证码是:" + str(code)
相关文章推荐
- [置顶] 【python 图像识别】图像识别从菜鸟走向大神系列1
- [置顶] 【mysql 存储过程】数据库从菜鸟走向大神系列2
- [置顶] 【mysql 存储过程】数据库从菜鸟走向大神系列3
- [置顶] 【mysql 存储过程】数据库从菜鸟走向大神系列3
- [置顶] 【mysql 存储过程】数据库从菜鸟走向大神系列1
- 百度定制化图像开放平台使用--调用识别接口(python3代码)
- python libsvm 图像分割 字符识别
- MySQL---数据库从入门走向大神系列(十五)-Apache的DBUtils框架使用
- python实现图像识别功能
- 【脚本语言系列】关于Python图像处理PIL,你需要知道的事
- MySQL---数据库从入门走向大神系列--基础入门
- 学习笔记系列-Python量化交易(1)-matplotlib库plot后图像不显示问题
- Caffe笔记:python图像识别与分类
- 学习python图像识别
- 图像识别 python+opencv的简单人脸识别
- python图像文字识别的环境搭建
- 人脸检测及识别python实现系列(4)——卷积神经网络(CNN)入门
- Matlab图像识别/检索系列(5)—10行代码完成深度学习网络之CNN/Autoencoder