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)
相关推荐
2301_1472583696 分钟前
7月1日作业
java·前端·算法
背影疾风6 分钟前
C++之路:类基础、构造析构、拷贝构造函数
linux·开发语言·c++
Ting-yu10 分钟前
Java中Stream流的使用
java·开发语言·windows
一只猿Hou27 分钟前
java分页插件| MyBatis-Plus分页 vs PageHelper分页:全面对比与最佳实践
java·mybatis
程序员弘羽32 分钟前
C++ 第四阶段 内存管理 - 第二节:避免内存泄漏的技巧
java·jvm·c++
旷世奇才李先生36 分钟前
Tomcat 安装使用教程
java·tomcat
【ql君】qlexcel39 分钟前
Notepad++ 复制宏、编辑宏的方法
开发语言·javascript·notepad++··宏编辑·宏复制
Zevalin爱灰灰1 小时前
MATLAB GUI界面设计 第六章——常用库中的其它组件
开发语言·ui·matlab
勤奋的知更鸟1 小时前
Java 编程之策略模式详解
java·设计模式·策略模式
qq_4924484461 小时前
Java 访问HTTP,信任所有证书,解决SSL报错问题
java·http·ssl