face++與python實現(xiàn)人臉識別簽到(考勤)功能-創(chuàng)新互聯(lián)

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

創(chuàng)新互聯(lián)建站主營安陽網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,成都APP應用開發(fā),安陽h5成都微信小程序搭建,安陽網(wǎng)站營銷推廣歡迎安陽等地區(qū)企業(yè)咨詢

項目架構(gòu)

項目使用場景

代碼:

流程代碼,主文件

#!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("未找到")

網(wǎng)站標題:face++與python實現(xiàn)人臉識別簽到(考勤)功能-創(chuàng)新互聯(lián)
URL分享:http://bm7419.com/article36/hdepg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護、品牌網(wǎng)站設計、外貿(mào)網(wǎng)站建設、網(wǎng)站排名網(wǎng)站導航、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作