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)
相关推荐
神的孩子都在歌唱2 分钟前
记一次sql查询优化
数据库·sql·oracle
严格格3 分钟前
关系数据库和非关系数据库
java·数据库
(⊙o⊙)~哦3 分钟前
Oracle 物化视图创建(materialized)
数据库·oracle
coffee_baby3 分钟前
深入探索迭代器模式的原理与应用
java·spring boot·迭代器模式·list
好悬给我拽开线8 分钟前
【知识点】python whl安装与源码安装
开发语言·python
南七澄江9 分钟前
python爬虫:从12306网站获取火车站信息
开发语言·爬虫·python
哟哟-10 分钟前
python多线程开发
开发语言·前端·python
JSON_L19 分钟前
PHP 递归遍历目录
开发语言·后端·php
2401_8582861120 分钟前
E33.【C语言】数据在内存中的存储练习集(未完)
c语言·开发语言
ajax_beijing_java22 分钟前
记录一次排查sql server 服务调用异常的问题
java·服务器·数据库