Face++API调用

人脸检测API调用

python 复制代码
import requests
import json
#将自己的KEY和Secret进行替换
API_KEY='your_API_KET'  
API_SECRET='your_API_Secret'

# 人脸识别的URL
URL = 'https://api-cn.faceplusplus.com/facepp/v3/detect'

# 请求参数,需要什么参数传入什么参数
data = {"api_key":API_KEY, 
        "api_secret":API_SECRET, 
        "image_url":'https://ts1.cn.mm.bing.net/th?id=OIP-C.Lc7aekOkY0t0Fii9a_xzYwHaK3&w=115&h=150&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
        #期望返回的参数
        "return_attributes": "gender,age,smiling,beauty",
        #  return_landmark 不写默认是不返回检测点,1为返回83个人脸检测点,2为返回106个检测点       
        "return_landmark":1}
# 发送请求
response = requests.post(URL,data=data)
req_con = response
print(req_con)
req_con = response.json()
print(req_con)

运行结果截图:

人脸美颜API调用

python 复制代码
from PIL import Image
import base64
import io
import requests
import json

#将自己的KEY和Secret进行替换
API_KEY='your_API_KET'  
API_SECRET='your_API_Secret'

# 人脸美颜的URL
URL = 'https://api-cn.faceplusplus.com/facepp/v1/beautify'

# 请求参数,需要什么参数传入什么参数
data = {"api_key":API_KEY, 
        "api_secret":API_SECRET, 
        "image_url":'https://ts1.cn.mm.bing.net/th?id=OIP-C.Lc7aekOkY0t0Fii9a_xzYwHaK3&w=115&h=150&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
        "whitening":80,
        "smoothing":80
       }
# 发送请求
response = requests.post(URL,data=data)
req_con = response
print(req_con)
req_con = response.json()
print(req_con)
#获取美颜后的照片
base64_str=req_con['result']

image_data = base64.b64decode(base64_str)
image = Image.open(io.BytesIO(image_data))
image.save("output.jpg")

人脸对比

python 复制代码
import requests
import json

#将自己的KEY和Secret进行替换
API_KEY='your_API_KET'  
API_SECRET='your_API_Secret'

# 人脸对比的URL
URL = 'https://api-cn.faceplusplus.com/facepp/v3/compare'

# 请求参数,需要什么参数传入什么参数
data = {"api_key":API_KEY, 
        "api_secret":API_SECRET, 
        "image_url1":'https://ts1.cn.mm.bing.net/th?id=OIP-C.Lc7aekOkY0t0Fii9a_xzYwHaK3&w=115&h=150&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
        "image_url2":'https://ts1.cn.mm.bing.net/th/id/R-C.717bfafeb2991c64790c4e89bbea5bda?rik=QOqbwamEroQU9A&riu=http%3a%2f%2fa2.att.hudong.com%2f51%2f28%2f01300001066597135114289686481.jpg&ehk=Ku6dkcMh2Cg3oX0YFkXs7VBs2UA54B0DzFY0mqN117g%3d&risl=&pid=ImgRaw&r=0'
        
       }
# 发送请求
response = requests.post(URL,data=data)
req_con = response
print(req_con)
req_con = response.json()
print(req_con)
相关推荐
君不见,青丝成雪1 分钟前
Hadoop技术栈(四)HIVE常用函数汇总
大数据·数据库·数据仓库·hive·sql
刘一说7 分钟前
CentOS 系统 Java 开发测试环境搭建手册
java·linux·运维·服务器·centos
卷福同学14 分钟前
来上海三个月,我在马路边上遇到了阿里前同事...
java·后端
Hy行者勇哥2 小时前
Python 与 VS Code 结合操作指南
开发语言·python
bingbingyihao2 小时前
多数据源 Demo
java·springboot
不羁。。5 小时前
【撸靶笔记】第七关:GET - Dump into outfile - String
数据库·笔记·oracle
yangchanghua1117 小时前
pgsql 如何查询今天范围内的数据(当天0点0分0秒 - 当天23点59分59秒....)
数据库·pgsql
larance7 小时前
SQLAlchemy 的异步操作来批量保存对象列表
数据库·python
python_chai7 小时前
从数据汇总到高级分析,SQL 查询进阶实战(下篇)—— 分组、子查询与窗口函数全攻略
数据库·sql·mysql
在努力的前端小白7 小时前
Spring Boot 敏感词过滤组件实现:基于DFA算法的高效敏感词检测与替换
java·数据库·spring boot·文本处理·敏感词过滤·dfa算法·组件开发