Python verification code recognition method and python verification code recognition
This document describes how to identify a Python verification code. Share it with you for your reference. The specific implementation method is as follows:
# Encoding = utf-8import Image, ImageEnhance, ImageFilterimport sysimage_name = ". /22.jpeg "# interference point im = Image. open (image_name) im = im. filter (ImageFilter. medianFilter () enhancer = ImageEnhance. contrast (im) im = enhancer. enhance (2) im = im. convert ('1') # im. show () # test view s = 12 # start cutting point xt = 2 # start cutting point yw = 10 # Cut width + yh = 15 # Cut Length + xim_new = [] for I in range (4): # Verification Code cut im1 = im. crop (s + w * I + I * 2, t, s + w * (I + 1) + I * 2, h) im_new.append (im1) # im_new [0]. show () # test xsize, ysize = im_new [0]. sizegd = [] for I in range (ysize): tmp = [] for j in range (xsize): if (im_new [0]. getpixel (j, I) = 255): tmp. append (1) else: tmp. append (0) gd. append (tmp) # view results for I in range (ysize): print gd [I]
I hope this article will help you with Python programming.