圆月山庄资源网 Design By www.vgjia.com
项目实现利用face++开发一个课堂签到的软件,实现面向摄像头即可完成记录学号、姓名和时间的签到工作。
项目架构
项目使用场景
代码:
流程代码,主文件
#!usr/bin/ # -*- coding: utf-8 -*- import requests from json import JSONDecoder import csv import cv2 import time import tkinter as tk search_url = "https://api-cn.faceplusplus.com/facepp/v3/search" getdetail_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail" key = "***************" secret = "*********************" filename = time.time() filepath = "photo/" + str(filename) + ".jpg" cap = cv2.VideoCapture(0) while(1): # get a frame ret, frame = cap.read() # show a frame cv2.imshow("capture", frame) if cv2.waitKey(1) & 0xFF == ord('1'): cv2.imwrite(filepath, frame) break cap.release() cv2.destroyAllWindows() print("waiting...") csvfile = open('face_token.csv','r') freader = csv.reader(csvfile) dic = dict(freader) csvfile.close() faceID_dict = {v:k for k,v in dic.items()} print("...") data = {"api_key": key, "api_secret": secret, "outer_id":'zbpm'} files = {"image_file": open(filepath, "rb")} response = requests.post(search_url, data=data, files=files) req_con = response.content.decode('utf-8') req_dict = JSONDecoder().decode(req_con) pre_face_token = req_dict["results"][0]["face_token"] pre_confidence = req_dict["results"][0]["confidence"] pre_thresholds = req_dict["thresholds"]["1e-5"] print("...") data = {"api_key": key, "api_secret": secret,"outer_id":'zbpm'} response = requests.post(getdetail_url, data=data) req_con = response.content.decode('utf-8') req_dict = JSONDecoder().decode(req_con) faces_token = req_dict["face_tokens"] print("...") if pre_face_token in faces_token and pre_confidence >= pre_thresholds: labaltext = faceID_dict[pre_face_token] + "\n\n\n" +str(time.asctime(time.localtime())) window = tk.Tk() window.title = ('FaceID') window.geometry = ('200x200') var = tk.StringVar() l = tk.Label(window,bg = 'yellow',text = labaltext,font=("黑体",20 ,"bold"),width = 30,height = 20) l.pack() l.config(text=labaltext+var.get()) #tk.messagebox.askokcancel('faceId', faceID_dict[pre_face_token] + "\n" +str(time.asctime(time.localtime()))) print(faceID_dict[pre_face_token]) else: tkinter.messagebox.askokcancel('提示', '未找到') print("未找到")
建立云脸数据集的模块:
#!usr/bin/ # -*- coding: utf-8 -*- import requests import time from json import JSONDecoder import csv http_url ='https://api-cn.faceplusplus.com/facepp/v3/faceset/addface' key = "z_qkMMqK1efq8ikgAPOEn89A7And-lAa" secret = "***********************" faceset_token = '******************************' face_tokens_str = '' csvfile = open('face_token.csv','r') freader = csv.reader(csvfile) facedata = [] i = 0 for item in freader: i = i + 1 face_tokens_str = face_tokens_str + item[1] + ',' if i%5 == 0: face_tokens_str = face_tokens_str[:-1] facedata.append (face_tokens_str) face_tokens_str = '' face_tokens_str = face_tokens_str[:-1] facedata.append (face_tokens_str) csvfile.close() for item in facedata: print(item) data = {"api_key":key,"api_secret":secret,"faceset_token":faceset_token,"face_tokens":item} response = requests.post(http_url, data=data) print(response) print(response.text)
初始建立云联数据集的模块:
#!/usr/bin/env/ python # _*_ coding:utf-8 _*_ import requests from json import JSONDecoder http_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/create" get_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/getfacesets" getdetails_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail" key = "**********************" secret = "*********************" data = {"api_key":key,"api_secret":secret,"display_name":'SEUers',"outer_id":'zbpm'} repn = requests.post(http_url,data = data) print(repn) print(repn.text) data = {"api_key":key,"api_secret":secret} repn = requests.post(get_url,data = data) print(repn) print(repn.text) data = {"api_key":key,"api_secret":secret,"outer_id":'zbpm'} repn = requests.post(getdetails_url,data = data) print(repn) print(repn.text)
生成存储facetoken:
这里从171860学号开始生成我的facetoken
#!usr/bin/ # -*- coding: utf-8 -*- import requests from json import JSONDecoder import csv id = 171860 http_url ='https://api-cn.faceplusplus.com/facepp/v3/detect' key = "*******************" secret = "*******************" faceID_List = [] face_token_List = [] for i in range (0,10): faceID = str(id + i) file = "picture/"+ faceID + ".jpg" data = {"api_key":key,"api_secret":secret,"return_landmark":1,} file = {"image_file":open(file,'rb')} response = requests.post(http_url,data = data,files = file) req_con = response.content.decode('utf-8') req_dict = JSONDecoder().decode(req_con) face_token = req_dict["faces"][0]["face_token"] faceID_List.append(faceID) face_token_List.append(face_token) print(faceID_List) print(face_token_List) csvfile = open('face_token.csv','a',newline = '') fwriter = csv.writer(csvfile) for i in range(len(faceID_List)): fwriter.writerow([faceID_List[i],face_token_List[i]]) csvfile.close()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年11月05日
2024年11月05日
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]