清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from PIL import Image, ImageEnhance Mods = [] for i in range( 10 ): Mods.append((str(i), Image.open( 'D:/Python源码/图片/%d-.png' % i))) def regonize(): for n in range( 50 ): image = Image.open( 'D:/Python源码/图片/%d.png' % n) image2 = image.convert( '1' ) result = [] for i in range( 4 ): #将验证码分割4份 w1 = 23 #根据验证码大小确定,为宽度 box = (w1 * i, 0 , w1 + w1 * i, 37 ) image_crop = image2.crop(box) points = [] for Mod in Mods: different = 0 for y in range( 23 ): for x in range( 37 ): if y > 0 and x > 0 : if (Mod[ 1 ].getpixel((y - 1 , x - 1 )) ! = image_crop.getpixel((y - 1 , x - 1 ))): different + = 1 points.append((different, Mod[ 0 ])) points.sort() result.append((points[ 0 ][ 1 ])) print (result, n) regonize() |