验证码破解的问题会是一个难点,需要学习深度学习,图像识别的内容,

验证码破解的问题会是一个难点,需要学习深度学习,图像识别的内容,

否则的话,就是使用打码平台,比如百度的图像识别接口,

第一步,需要开通,

申请百度AI接口:
申请地址:http://ai.baidu.com/

然后用你的账号登入,登入以后依次单击“产品服务”,“全部产品”,“图像识别”,然后在“图像识别”中选择创建应用,在接口选择那栏选择你想要的识别方式那打钩,我选择银行卡识别

申请完,会给你几个东西,

 ####

第二步,这样就创建成功了,接下来会用到的就是AppID,API Key以及Secret Key这三个

接下来打开你的Pycharm 新建python项目,然后执行以下代码即可:(注意以下代码只针对银行卡识别,如果你是其它识别,代码略有不同,具体请到官网查看)

注意要安装一下百度的包pip install baidu-aip 

代码:

# *_* coding :UTF-8 *_*
import os
from aip import AipOcr

# 定义常量,请用你刚才自己申请的AI接口
APP_ID = '16011*****' 

API_KEY = '7mcdwwDZjiYrWYf4*******'# 公钥

SECRET_KEY = 'WGL6woXzXXOhUOHDMoL***********' # 密钥

aipOcr = AipOcr(APP_ID, API_KEY, SECRET_KEY)  # 初始化AipFace对象

Path="E:/cards"   # 读取图片

bank_card_type='不能识别'   #银行卡的类型

counts=0   #计数器,用于图片的迭代
all_pickture_Path = os.listdir(Path)  #统计文件下图片个数
file=open("E:/cardsnew/cardsnew.txt",'w',encoding='gbk')  #打开你一会需要把信息写入的文件


def get_file_content(pickturePath):
    with open(pickturePath, 'rb') as fp:
        return fp.read()

options = {}

strover = '识别结果:
'  #用于结果输出
# bank_card_type  银行卡类型,0:不能识别; 1: 借记卡; 2: 信用卡
#迭代识别文件下的所有图片
for count in all_pickture_Path:
    pickturePath = os.path.join('E:', 'cards',all_pickture_Path[counts]) #用来组合并返回图片路径,all_pickture_Path[counts]为图片名称
    print(pickturePath)                                                  #输出图片路径用于观察,可省略
    result=aipOcr.bankcard(get_file_content(pickturePath),options)       #接收aip返回的识别结果
    for key in result['result']:                                         #改写返回结果输出格式
        try:
            if result['result']['bank_card_type'] == 0:
                bank_card_type = '不能识别'
            elif result['result']['bank_card_type'] == 1:
                bank_card_type = '借记卡'
            elif result['result']['bank_card_type'] == 2:
                bank_card_type = '信用卡'
        except BaseException:
            error_msg = result['error_msg']
            strover += '错误:
 {} 
'.format(error_msg)
    strover += ' 卡号:{} 
  银行:{} 
  '.format(result['result']['bank_card_number'], result['result']['bank_name'])
    strover += '类型:{}
'.format(bank_card_type)
    file.write(strover)
    counts+=1
    strover = '识别结果:
'
file.close()

具体的接口使用,要去官网看,

#####

但是这个是要收费的,

每个月都有免费额度1000次,然后后续的收费不同接口不同收费,图像这种,大概就是1万次50块钱这样的,

有空还是要用一下,

但是后续还是需要自己去学习深度学习,图像识别的问题,简单图像识别还是可以的,

#####

#####

原文地址:https://www.cnblogs.com/andy0816/p/15335555.html