腾讯优图api接口+Python SDK(1)

腾讯优图开放平台
参考给的SDK开发文档

在新建个体时按照我的写法有提示题错误,如有对此了解的朋友希望你能帮助我,谢谢
这里写图片描述

下面代码主要是参考给的python_sdk开发文档来的,另外自己结合了json的关键字提取,将数量返回值做了一个简单的常规文字输出。

# -*- coding: utf-8 -*-

import time
import TencentYoutuyun

# pip install requests
# please get these values from http://open.youtu.qq.com
appid = 'xxxxxxxx'
secret_id = 'xxxxxxxxxxxx'
secret_key = 'xxxxxxxxxxxxxx'
userid = 'xxxxxxxx'

#choose a end_point
#end_point = TencentYoutuyun.conf.API_TENCENTYUN_END_POINT
#end_point = TencentYoutuyun.conf.API_YOUTU_VIP_END_POINT
end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT

youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)

#两张人脸比对,返回相似度
#session_id = id
#ret = youtu.FaceCompare(img1,img2)
#print (ret)

#新建个体ID
# ret = youtu.NewPerson(person_id="person1",image_path="zyx.jpg",group_ids="Students", person_name= 'zyx', tag='', data_type = 0)
# print(ret)

ret = youtu.DetectFace(image_path="zyx.jpg",mode = 0,data_type = 0)
print (ret)
#
for j in ret["face"]:
    if j["gender"] > 50:
        print("性别:男")
    else:
        print("性别:女")

    if j["expression"] >90:
        print("你在大笑")
    elif 50 <j["expression"] < 90:
        print("你在微笑")
    else:
        print("我没感觉你笑")
    if j["glass"]:
        print("你戴眼镜了")
    print("你的颜值:",j["beauty"])
    print("你的年龄:",j["age"])
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值