face++人脸检测(三)搜索
2018-01-02 19:42
351 查看
搜索要分为三步,先创建faceset,添加图片,再搜索。搜索是在faceset中寻找最像输入图片中人脸的内容。
下面是我的代码:
代码如下:
第三步 搜索
额, 番茄是谁大家不用管。。。
代码如下:
那么关于face++人脸识别的简单内容基本就在这里了,更深入的应用我如果有深入了解会写出来的。
首先创建faceset:
下面是我的代码:
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/1/2 18:43 # @Author : He Hangjiang # @Site : # @File : CreatFcaeSet.py # @Software: PyCharm import requests from json import JSONDecoder import cv2 http_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/create" key = "2PX56nNhKpVd57QNKc9sQt9ASRczWlIr" secret = "7gwhn-gVp6J3we_vdj_bIlL1bGpuZdlp" data = {"api_key": key, "api_secret": secret, 'display_name':'FacesStore',"outer_id":"hhj"} response = requests.post(http_url, data=data) print(response) print(response.text) # req_con = response.content.decode('utf-8') # req_dict = JSONDecoder().decode(req_con) # # print(req_dict)
第二步 添加图片
需要注意的是,这里的face_tokens就是我们之前人脸检测中得到的face_tokens,每个对应一个人脸代码如下:
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/1/2 18:55 # @Author : He Hangjiang # @Site : # @File : AddFace.py # @Software: PyCharm import requests from json import JSONDecoder import cv2 http_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/addface" key = "2PX56nNhKpVd57QNKc9sQt9ASRczWlIr" secret = "7gwhn-gVp6J3we_vdj_bIlL1bGpuZdlp" data = {"api_key": key, "api_secret": secret, "outer_id": "hhj","face_tokens":'d6eee462bc73858ae8ed7accca1f6632,c06b924cb227711477291c346b2cb40f'} # filepath = "face2.jpg" # files = {"image_file": open(filepath, "rb")} response = requests.post(http_url, data=data) print(response) print(response.text) # req_con = response.content.decode('utf-8') # req_dict = JSONDecoder().decode(req_con) # # print(req_dict)
第三步 搜索
额, 番茄是谁大家不用管。。。
代码如下:
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/1/2 19:12 # @Author : He Hangjiang # @Site : # @File : SearchFace.py # @Software: PyCharm import requests from json import JSONDecoder import cv2 http_url = "https://api-cn.faceplusplus.com/facepp/v3/search" key = "2PX56nNhKpVd57QNKc9sQt9ASRczWlIr" secret = "7gwhn-gVp6J3we_vdj_bIlL1bGpuZdlp" filepath = "face4.jpg" data = {"api_key": key, "api_secret": secret, "outer_id": "hhj"} files = {"image_file": open(filepath, "rb")} response = requests.post(http_url, data=data, files=files) req_con = response.content.decode('utf-8') req_dict = JSONDecoder().decode(req_con) print(req_dict) faces_token = ["d6eee462bc73858ae8ed7accca1f6632","5e85caf4c983b9523f17bebd77715d17"] if req_dict["results"][0]["face_token"] in faces_token and req_dict["results"][0]["confidence"]>=req_dict["thresholds"]["1e-5"]: print("是番茄") else: print("不是番茄")
那么关于face++人脸识别的简单内容基本就在这里了,更深入的应用我如果有深入了解会写出来的。
相关文章推荐
- Face++ 人脸检测之POST[img](0)
- 人脸检测--SSH: Single Stage Headless Face Detector
- 人脸检测--S3FD: Single Shot Scale-invariant Face Detector
- 人脸检测“Joint Cascade Face Detection and Alignment”
- face landmark 人脸特征点检测
- 鲁棒的实时人脸检测:Robust Real-Time Face Detection
- 人脸检测-- Face R-FCN + Face R-CNN
- 快速多尺度人脸检测--Multi-Scale Fully Convolutional Network for Fast Face Detection
- Android应用开发FaceDetector(人脸检测)
- 多尺度人脸检测--Face Detection through Scale-Friendly Deep Convolutional Networks
- 人脸检测--Faceness-Net: Face Detection through Deep Facial Part Responses
- 人脸检测解析json的工具类face_test
- 人脸检测工具face_recognition的安装与应用
- Android配置opencv开发环境并运行face-detection 人脸检测例程
- 使用滑动窗口进行人脸检测 Face detection with a sliding window
- 实时人脸检测 (Real-Time Face Detection)
- Android API教程:人脸检测(Face Detect)
- Face++离线版实现拍照进行人脸检测
- 人脸检测源码facedetection
- OpenCV学习笔记(11):libfacedetection人脸检测的配置与使用