1.准备验证码图片

 import os
from urllib.request import urlretrieve urlPath='http://www.189.cn/portal/captcha/simple.do?date=1503125232339'
localPath='G:\python_work\chapter11\captcha' # 根据文件名创建文件
def createFileByFileName(localPath,fileName):
if not os.path.exists(localPath):
os.makedirs(localPath)
totalPath=localPath+'\\'+fileName
if not os.path.exists(totalPath):
file=open(totalPath, 'a+')
file.close()
return totalPath # 根据图片的地址, 下载图片并保存在本地
def getAndSaveImg(imgUrl, filename):
if(len(imgUrl)!=0):
file=filename+'.jpg'
urlretrieve(imgUrl, createFileByFileName(localPath, file)) # 下载图片
i=0
while i<100:
getAndSaveImg(urlPath, str(i))
i=i+1

2.将验证码图片转为灰度图 , 扩展名改为.tif

 import os
from PIL import Image def getFileList(path):
# 返回目录中所有jpg图像的文件名列表
return [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.jpg')] # 批量将图片转为灰度图
def patchConvert(srcPath, destPath):
fileList = getFileList(srcPath)
for file in fileList:
img = Image.open(file).convert('L')
name_ext = getFileNameAndExt(file)
destFile = os.path.join(destPath, name_ext[0]+'.tif')
img.save(destFile) # 获取文件名和扩展名
def getFileNameAndExt(filename):
# 取目录与文件名
(filepath, tempfilename) = os.path.split(filename)
# 取文件名(不带扩展名)和扩展名
(shotname, extension) = os.path.splitext(tempfilename)
return shotname, extension patchConvert('captcha', 'captcha_gray')

3. 后续步骤参考原先的博客:

http://www.cnblogs.com/CoolJayson/p/7395824.html

问题: 生成box文件后, 用jTessBoxEditor修改box文件时, 里面的矩形画的误差较大, 字符个数识别不准确 , 应该如何对矩形进行修改???

用Tesseract训练验证码遇到的问题的更多相关文章

  1. Tesseract训练中文字体识别

    注:目前仅说明windows下的情况 前言 网上已经有大量的tesseract的识别教程,但是主要有两个缺点: 大多数比较老,有部分内容已经不适用. 大部分只是就英文的训练进行探索,很少针对中文的训练 ...

  2. tensorflow训练验证码识别模型

    tensorflow训练验证码识别模型的样本可以使用captcha生成,captcha在linux中的安装也很简单: pip install captcha 生成验证码: # -*- coding: ...

  3. Tesseract 对验证码的识别原理和实现步骤

    一. Steps: 学习图片库--->处理图片(初步处理)--->校正.学习图片 二. Tesseract: 1. 采集图片库(一般每个出现的字符出现20次左右识别效果比较好),根据图片特 ...

  4. Tesseract训练笔记

    [参考] http://www.cnblogs.com/samlin/p/Tesseract-OCR.html https://code.google.com/p/tesseract-ocr/wiki ...

  5. Tesseract训练

    最近在用Tesseract做一个图片识别的小应用,目标图像只有数字和英文字母,在实际使用过程中发现个别数识别错误,因此不得不研究学习Tesseract的训练. http://www.cnblogs.c ...

  6. tesseract 训练

    下载chi_sim.traindata字库下载tesseract-ocr-setup-3.02.02.exe 下载地址:http://code.google.com/p/tesseract-ocr/d ...

  7. 跟我学算法- tensorflow 卷积神经网络训练验证码

    使用captcha.image.Image 生成随机验证码,随机生成的验证码为0到9的数字,验证码有4位数字组成,这是一个自己生成验证码,自己不断训练的模型 使用三层卷积层,三层池化层,二层全连接层来 ...

  8. tesseract训练手写体

    前面的步骤都一样,从第4步开始 4.使用tesseract生成.box文件: tesseract eng.handwriting.exp0.tif eng.handwriting.exp0 -l en ...

  9. tesseract系列(3) -- tesseract训练

    tessract的训练有个工具叫 jTessBoxEditor 1.jTessBoxEditor是用java写的,首先要装java的环境 jdk-8u191-windows-x64.exe 这个我想从 ...

随机推荐

  1. C++: typedef与template的配合使用;

    利用STL的vector能够实现多维矩阵,但是写起来不怎么好看,使用typedef定位为 固定的格式: //多维矩形,vector实现: template<class T> class i ...

  2. jsp中${pageContext.request.contextPath}的意思

    ${pageContext.request.contextPath}是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> . 也就是取出部署的应用程 ...

  3. Spring Cloud构建微服务架构(六)高可用服务注册中心

    http://blog.didispace.com/springcloud6/ https://www.jianshu.com/p/df9393755a05 http://www.ityouknow. ...

  4. JSON的简单使用_向前台发送JSON数据

    转自:http://www.cnblogs.com/digdeep/p/5574366.html 1.前台页面 <%@ page language="java" conten ...

  5. Hadoop生态圈-Knox网关的应用案例

    Hadoop生态圈-Knox网关的应用案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Knox网关简介 据Knox官网所述(http://knox.apache.org/) ...

  6. centos之Too many open files问题-修改linux最大文件句柄数

    linux服务器大并发调优时,往往需要预先调优linux参数,其中修改linux最大文件句柄数是最常修改的参数之一. 在linux中执行ulimit -a 即可查询linux相关的参数,如下所示: [ ...

  7. Java Web之验证码

    今天来模拟一下验证码,我们需要三个文件,两个Servlet,一个jsp 直接贴代码吧 RandomCodeServlet:主要负责生产验证码 package com.vae.RandomCode; i ...

  8. python第二次周末大作业

    题目 ''' HR人力资源管理. 1. 菜单: ("查看员⼯信息","添加员⼯信息", "修改员⼯信息", "删除员⼯信息&quo ...

  9. Linux记录-定时crontab

    /etc/crontab文件和crontab -e命令区别 1.格式不同 分 时 日 月 星期 要运行的命令 第1列分钟1-59 第2列小时1-23(0表示子夜) 第3列日1-31 第4列月1-12 ...

  10. Spring Boot 2下使用Feign找不到@EnableFeignClients的解决办法

    最近在实践Spring Boot 2+Spring Cloud(Finchley.M9),在用到Feign的时候发现@EnableFeignClients注解开不了,独立使用Feign是可以的,但就是 ...