温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用 tesseract-ocr生成训练库全部指令

发布时间:2020-07-04 17:45:56 来源:网络 阅读:3062 作者:yue者长歌 栏目:编程语言

coding:utf-8

import copy
from PIL import Image,ImageEnhance

im = Image.open('d:/workspace/captcha/0.png')
im = im.convert('RGB')
im4 = Image.open('d:/1.gif')

class ImageSequence:
def init(self, im):
self.im = im
def getitem(self, ix):
try:
if ix:
self.im.seek(ix)
return self.im
except EOFError:
raise IndexError # end of sequence

imS = ImageSequence(im4)

from PIL import ImageDraw,ImageFont
from pytesseract import pytesseract as pt

path = "D:\workspace\captcha\"
img = Image.open(path+"34.png")
img = img.convert("L")
s = pt.image_to_string(img,lang="dt",config="-psm 7")
print(s)

1、合并图片

2、生成box文件

tesseract dty.dt.exp0.tif dty.dt.exp0 -l eng -psm 7 batch.nochop makebox

3、修改box文件

4、生成font_properties

echo dt 0 0 0 0 0 >font_properties

5、生成训练文件

tesseract dty.dt.exp0.tif dty.dt.exp0 -l eng -psm 7 nobatch box.train

6、生成字符集文件

unicharset_extractor dty.dt.exp0.box

7、生成shape文件

shapeclustering -F font_properties -U unicharset -O dty.unicharset dty.dt.exp0.tr

8、生成聚集字符特征文件

mftraining -F font_properties -U unicharset -O dty.unicharset dty.dt.exp0.tr

9、生成字符正常化特征文件

cntraining dty.dt.exp0.tr

10、更名

rename normproto dt.normproto

rename inttemp dt.inttemp

rename pffmtable dt.pffmtable

rename unicharset dt.unicharset

rename shapetable dt.shapetable

11、合并训练文件,生成dt.traineddata

combine_tessdata dt.

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI