コード例 #1
0
ファイル: discern.py プロジェクト: loopbings/bilcode
    # piclist = []
    # for i in range(0, len(list)):
    #     path = os.path.join(rootdir, list[i])
    #     if os.path.isfile(path):
    #         piclist.append(path)
    # 验证码list
    # codelist = []
    # for str_path in piclist:
    path = '{}/picture/{}'.format(os.getcwd(), '1525348077163796.png')
    # path = str_path
    im = Image.open(path)
    im.show()
    # 水滴算法
    captchainfo = Captcha(im)
    captchainfo.rgb_img2mat()
    im = captchainfo.get_img()
    im.show()
    # 拆分
    im = binarizing(im, 150)
    # 降噪
    im = depoint(im)
    im.show()
    # 转换
    text = pytesseract.image_to_string(im, config='-psm 7')
    print(text)
#     codelist.append('{}  {} \n'.format(path, text))
# # 写入文件
# with open(filename,'a') as f:
#     for code in codelist:
#         f.write(code)