美文网首页
调用百度AI开放平台-----人流量统计API

调用百度AI开放平台-----人流量统计API

作者: 奶霜荔枝红茶 | 来源:发表于2020-07-10 15:58 被阅读0次

    调用人流量统计API的输入与输出源代码展示

    一、获得access_token
    • 输入
    # encoding:utf-8
    import requests 
    
    # client_id 为官网获取的AK, client_secret 为官网获取的SK
    host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=5uTlBnuwtxuVYjFkyOQ02YWa&client_secret=zjou7fPiQTSNUoTLIwsGVNBNlj88XW3t'
    response = requests.get(host)
    if response:
        print(response.json())
    
    • 输出
    {'refresh_token': '25.06d9d3198863e6cb16ab9478ab3afd66.315360000.1909723912.282335-21236519', 'expires_in': 2592000, 'session_key': '9mzdC3t6OT/oxS7HXKiNPwUGptgdVR5O8xjhJgFSd3ri3CDITUoD9nKeTw03LuYh4zI8hd6k4b5TnlFJjeAjw5XauXaOTA==', 'access_token': '24.0c0289a210b48d32b4c1318f86a1a889.2592000.1596955912.282335-21236519', 'scope': 'public brain_all_scope brain_body_analysis brain_body_attr brain_body_number brain_driver_behavior brain_body_seg brain_gesture_detect brain_body_tracking brain_hand_analysis wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理', 'session_secret': 'aa18e0918774cd1c85e402a19bd01081'}
    

    二、源代码展示

    • 输入
    import requests
    import base64
    request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/body_num"
    # 二进制方式打开图片文件
    f = open('Desktop/picture.jpg', 'rb')
    img = base64.b64encode(f.read())
    params = {"image":img}
    access_token = '24.0c0289a210b48d32b4c1318f86a1a889.2592000.1596955912.282335-21236519'
    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())
    
    • 输出源代码
    {'person_num': 26, 'log_id': 6154891608034342474}
    

    相关文章

      网友评论

          本文标题:调用百度AI开放平台-----人流量统计API

          本文链接:https://www.haomeiwen.com/subject/nmemcktx.html