def vcode(fn): r = requests.get(url) with open(fn, 'wb') as f: f.writelines(r.content) im = Image.open(fn) im = im.convert('L') im = im.point(lambda x: 255 if x > 140 else 0) im = ecp(im) code = image_to_string(im, lang='kp', config='-psm 8') return code
def vcode(fn): r = requests.get(url) with open(fn, 'wb') as f: f.writelines(r.content) im = Image.open(fn) im = im.convert('L') im = im.point(lambda x: 255 if x > 160 else 0) im = ecp(im) code = image_to_string(im, lang='scqcp', config='-psm 8') return code
def vcode(fn): r = requests.get(url) with open(fn, 'wb') as f: f.writelines(r.content) im = Image.open(fn) im = im.convert('L') im = im.point(lambda x: 255 if x > 190 else 0) im = ecp(im, 7) code = image_to_string(im, lang='mp', config='-psm 7') info = re.findall(r'[0-9]', str(code)) code = ''.join(info) if len(code.strip()) == 4: return code else: return 'Fail'
def vcode(fn): r = requests.get(url) with open(fn, 'wb') as f: f.writelines(r.content) im = Image.open(fn) sim = im im = im.convert('L') im = im.point(lambda x: 255 if x > 225 else 0) im = ecp(im, 8) code = image_to_string(im, lang='qdky', config='-psm 8') code = re.findall(r'[0-9a-zA-Z]', str(code)) code = ''.join(code) if len(code) == 4: sim.save(code + '.png') return code else: return 0
def vcode(fn): r = requests.get(url) with open(fn, 'wb') as f: f.writelines(r.content) im = Image.open(fn) im = im.convert('L') im = im.point(lambda x: 255 if x > 140 else 0) im = ecp(im) try: code = image_to_string(im, lang='bus365', config='-psm 8') # print(code) info = re.findall(r'[0-9a-zA-Z]', str(code)) code = ''.join(info) if len(code.strip()) != 4: return 'Failed!!!' return code except Exception as e: print(e)
def vcode(fn): r = requests.get(url) with open(fn, 'wb') as f: f.writelines(r.content) im = Image.open(fn) sim = im im = im.convert('L') im = im.point(lambda x: 255 if x > 160 else 0) im = ecp(im, 7) im = fff(im, 4, 15) code = image_to_string(im, lang='gdcd', config='-psm 8') code = re.findall(r'[0-9a-fA-F]', str(code)) code = ''.join(code) letter = [('l', '1'), ('o', '0'), ('O', '0'), ('L', '1'), ('s', '5'), ('S', '5'), ('B', '8'), ('A', '4')] if len(code) == 4: for x in letter: code = code.replace(x[0], x[1]) sim.save(code + '.png') return code else: return 0
def cnoise(fn): if fn.endswith('.png'): im = Image.open(fn) # im = rmbg(im, 20) im = im.convert('L') im = im.point(lambda x: 255 if x > 190 else 0) # im = im.crop((140, 70, 225, 90)).convert( # 'L').point(lambda x: 255 if x > 160 else 0) # im = cv2.imread(fn) # im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) # im = cv2.adaptiveThreshold( # im, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 40) im = ecp(im, 7) # im = fff(im, 4, 8) # im = im.filter(ImageFilter.MedianFilter()) # im.show() return im nfn = fn[:-4] + '_g.png' print nfn # print(nfn) # # cv2.imwrite(nfn, im) im.save(nfn)
def cnoise(fn): if fn.endswith('.png'): im = Image.open(fn) # im = rmbg(im, 20) im = im.convert('L') im = im.point(lambda x: 255 if x > 225 else 0) # im = im.crop((140, 70, 225, 90)).convert( # 'L').point(lambda x: 255 if x > 160 else 0) # im = cv2.imread(fn) # im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) # im = cv2.adaptiveThreshold( # im, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 40) im = ecp(im, 8) # im = fff(im, 4, 20) # im = im.filter(ImageFilter.MedianFilter()) # im.show() # return im nfn = fn[:-4] + '_g.png' print nfn # print(nfn) # # cv2.imwrite(nfn, im) im.save(nfn)