91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

face++與python實現人臉識別簽到(考勤)功能

發布時間:2020-08-19 18:01:29 來源:腳本之家 閱讀:170 作者:MudFire 欄目:開發技術

項目實現利用face++開發一個課堂簽到的軟件,實現面向攝像頭即可完成記錄學號、姓名和時間的簽到工作。

項目架構

face++與python實現人臉識別簽到(考勤)功能

項目使用場景

face++與python實現人臉識別簽到(考勤)功能

代碼:

流程代碼,主文件

#!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()

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

平陆县| 醴陵市| 长寿区| 肇州县| 舞阳县| 阳城县| 临洮县| 沙坪坝区| 新密市| 长治县| 宁陕县| 上虞市| 土默特右旗| 阿荣旗| 西林县| 盘山县| 嘉鱼县| 天水市| 孟津县| 盈江县| 申扎县| 疏勒县| 曲麻莱县| 阜宁县| 黄梅县| 长泰县| 邵阳县| 湛江市| 平湖市| 新余市| 赤峰市| 富蕴县| 双流县| 商河县| 博客| 台山市| 林西县| 渝北区| 东台市| 凤庆县| 岳西县|