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 makebox3、修改box文件4、生成font_propertiesecho dt 0 0 0 0 0 >font_properties5、生成训练文件tesseract dty.dt.exp0.tif dty.dt.exp0 -l eng -psm 7 nobatch box.train6、生成字符集文件unicharset_extractor dty.dt.exp0.box7、生成shape文件shapeclustering -F font_properties -U unicharset -O dty.unicharset dty.dt.exp0.tr8、生成聚集字符特征文件mftraining -F font_properties -U unicharset -O dty.unicharset dty.dt.exp0.tr9、生成字符正常化特征文件cntraining dty.dt.exp0.tr10、更名rename normproto dt.normprotorename inttemp dt.inttemprename pffmtable dt.pffmtablerename unicharset dt.unicharsetrename shapetable dt.shapetable11、合并训练文件,生成dt.traineddatacombine_tessdata dt.