利用百度云 华为云 腾讯云 科大讯飞云 阿里云 做提词工具-----用起来很牛逼 做起来 啧啧啧

critic think:互联网经济 有的时候总是慢慢的把人们养成一中懒的习惯 这样下去很可怕的,再加上大数据 的支撑和决策树 和神经网络科学的不断发展和使用,大家可以想想一下 你都不知道想要啥的时候 机器已经帮你安排好了一切 什么时候要什么 用什么样的方式购买 都帮你考虑好了(此处省略.......)话说回来:

看下百度云提供的免费开放接口:
1.你得有一个百度云账号 

2.找到你想要用的接口(比较人性化的是:接口基本上都有demo供参考)

3.进入到你的百度云控制台 创建一个工单

4.创建成功后会有两个key 以及相关工单的其他信息(两个key调用接口的时候有用)

def  ataintocke():
AK='MOLpEoO3vcBHA0yMHidLrRNE'
SK='A11UNvGFMsEyeLoIbGX6G6d5jVbkvQDW'
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={AK}&client_secret={SK}'.format(AK=AK,SK=SK)
response = requests.get(host)
return response.json()['access_token']
备注(如果用Python 调用要安装百度的接口模块-----具体Python安装包的方法请注意本博客的对应变化)

5.请求百度接口调用后,再调用提词接口:
def construe(request):
request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic"
# 二进制方式打开图片文件o
f = getFilePath(filepath='D:\新媒体包\新媒体内容\个人成长\图片\图片4\1.jpg')
img = base64.b64encode(f)
params = {"image": img}
access_token = ataintocke()
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=params, headers=headers)
word_content_result = []
for i in response.json()["words_result"]:
word_content = i['words']
word_content_result.append(word_content)
return render(request, 'phtotoWorld.html', {'word_content_result': word_content_result})(这里用的是django框架 后期也会写相关的技术博客 请大家留意本博客的相关动态)
6.图片上的文字被成功提取到页面上 并进行展示
原文地址:https://www.cnblogs.com/XiaoLaiTongXueA/p/13403036.html