百度AI api使用

# *********************************baidu-api-通用文字识别********************************************

# import requests
# import base64
#
# ‘‘‘
# 通用文字识别
# ‘‘‘
# host = ‘https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=3l39KDWEbBB5Rl82UacTfsdK&client_secret=t5Iz6BH9d8j0hcrQbbcYqeavxgT7psqe‘
# response = requests.get(host)
#
# access_token = response.json().get("access_token")
#
# request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"
# # 二进制方式打开图片文件
# f = open(‘image\微信图片_20191114012932.jpg‘, ‘rb‘)
# img = base64.b64encode(f.read())
#
# params = {"image":img}
# access_token = access_token
# 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)
# if response:
#     result = response.json()
#     item = result.get("words_result")
#     for i in item:
#         print(i.get("words"))

# *********************************baidu-api-人体分析********************************************

# import requests
# import base64
#
# host = ‘https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=H6ySgmBMEUvAXbZxWD0mNXK9&client_secret=jtrOT5jpbGdEmIEPqTCMLqbYqNDovjAy‘
# response = requests.get(host)
#
# access_token = response.json().get("access_token")
# print(access_token)
#
# import requests
# import base64
#
# ‘‘‘
# 人流量统计
# ‘‘‘
#
# request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/body_num"
# # 二进制方式打开图片文件
# f = open(‘image/36b377210df5e8198f8c99964d3c7b20.jpg‘, ‘rb‘)
# img = base64.b64encode(f.read())
#
# params = {"image":img}
# 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)
# if response:
#     print (response.json())
# encoding:utf-8

# *********************************baidu-api-人像分割********************************************

# import requests
# import base64
# host = ‘https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=H6ySgmBMEUvAXbZxWD0mNXK9&client_secret=jtrOT5jpbGdEmIEPqTCMLqbYqNDovjAy‘
# response = requests.get(host)
#
# access_token = response.json().get("access_token")
# print(access_token)
#
# ‘‘‘
# 人像分割
# ‘‘‘
# request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/body_seg"
# # 二进制方式打开图片文件
# f = open(‘image/76ce287be589d924822512912739498f.jpg‘, ‘rb‘)
# img = base64.b64encode(f.read())
#
# params = {"image":img}
# 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)
# if response:
#     print (response.json()["scoremap"])

 

百度AI api使用

上一篇:C#中ref和out关键字的应用以及区别


下一篇:C#6.0新特性