python调用Face++,玩坏了!
2017-07-02 18:51
267 查看
看到一句话,如果你写代码没有写诗一样的感觉,那你不适合做程序猿!
还是直接上代码吧:
如果帮到你了,请赞赏支持:
还是直接上代码吧:
import requests from json import JSONDecoder import cv2 import os http_url ="https://api-cn.faceplusplus.com/facepp/v3/detect" # your key and your secret,急用的话,可以加微信lp9628。 key ="***" secret ="***" filename = '/Users/liupeng/Desktop/anaconda/widerface/WIDER_train/images' for filename1 in os.listdir(filename): print filename1 if (filename1[0] != '.'): filename1 = filename + '/' + filename1 for filename2 in os.listdir(filename1): print filename2 if (filename2[0] != '.'): filename2 = filename1 + '/' + filename2 filepath = filename2 data = {"api_key":key, "api_secret":secret, "return_landmark":"1"} 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 (len(req_dict[u'faces'])) face_num = len(req_dict[u'faces']) frame = cv2.imread(filepath) for i in range(face_num): box = req_dict[u'faces'][i][u'face_rectangle'] print(box) x, y, w, h = box[u'left'], box[u'top'],box[u'width'],box[u'height'] color = (0, 255, 0) cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2) #显示图像 cv2.imshow("faceDetecion", frame) c = cv2.waitKey(10) cv2.destroyAllWindows()
如果帮到你了,请赞赏支持:
相关文章推荐
- 【Python调用Face++ API的人脸识别】
- Python3调用face++免费API接口识别身份证信息
- Python2,python3调用face++api
- Python调用Face++人脸检测API
- C# 调用批python 脚本
- 《扩展和嵌入python解释器》1.6 从C中调用Python函数
- PYTHON中的函数指针调用的一种方法
- 在c++程序中调用python脚本函数
- Python的可调用对象
- PYTHON 与C相互交互调用实例解析
- 使用Python 3.0a1 调用外部应用程序
- python调用mysql和postgresql的不同之处
- Python实列:计时器调用
- java调用python的webservice
- python第十五课——图形界面文本框排列和调用
- Python调用C的DLL和VC调用有什么区别?
- python调用cx_Oracle开发(-)---cx_Oracle安装
- Python的可调用对象
- IronPython脚本调用C#实现的dll库
- python写的调用ms sqlserver数据并发送邮件的小程序