欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2019年08月28日 14:58:46   作者:MudFire  
這篇文章主要為大家詳細介紹了face++與python實現(xiàn)人臉識別簽到(考勤)功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

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

項目架構

項目使用場景

代碼:

流程代碼,主文件

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

建立云臉數(shù)據(jù)集的模塊:

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

初始建立云聯(lián)數(shù)據(jù)集的模塊: 

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

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • 詳解如何將python3.6軟件的py文件打包成exe程序

    詳解如何將python3.6軟件的py文件打包成exe程序

    這篇文章主要介紹了詳解如何將python3.6軟件的py文件打包成exe程序,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-10-10
  • python Matplotlib底圖中鼠標滑過顯示隱藏內(nèi)容的實例代碼

    python Matplotlib底圖中鼠標滑過顯示隱藏內(nèi)容的實例代碼

    這篇文章主要介紹了python Matplotlib底圖中鼠標滑過顯示隱藏內(nèi)容,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-07-07
  • python selenium登錄豆瓣網(wǎng)過程解析

    python selenium登錄豆瓣網(wǎng)過程解析

    這篇文章主要介紹了python selenium登錄豆瓣網(wǎng)過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-08-08
  • Django中URL的參數(shù)傳遞的實現(xiàn)

    Django中URL的參數(shù)傳遞的實現(xiàn)

    這篇文章主要介紹了Django中URL的參數(shù)傳遞的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-08-08
  • python語言線程標準庫threading.local解讀總結

    python語言線程標準庫threading.local解讀總結

    在本篇文章里我們給各位整理了一篇關于python threading.local源碼解讀的相關文章知識點,有需要的朋友們可以學習下。
    2019-11-11
  • Python類class參數(shù)self原理解析

    Python類class參數(shù)self原理解析

    這篇文章主要介紹了Python類class參數(shù)self原理解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-11-11
  • Pytorch使用visdom可視化問題

    Pytorch使用visdom可視化問題

    這篇文章主要介紹了Pytorch使用visdom可視化問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • pandas中實現(xiàn)將相同ID的字符串進行合并

    pandas中實現(xiàn)將相同ID的字符串進行合并

    這篇文章主要介紹了pandas中實現(xiàn)將相同ID的字符串進行合并問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • Python代碼顯得Pythonic(區(qū)別于其他語言的寫法)

    Python代碼顯得Pythonic(區(qū)別于其他語言的寫法)

    這篇文章主要介紹了Python代碼顯得Pythonic(區(qū)別于其他語言的寫法),對于字符串連接,相比于簡單的+,更pythonic的做法是盡量使用%操作符或者format函數(shù)格式化字符串,感興趣的小伙伴和小編一起進入文章了解更詳細相關知識內(nèi)容吧
    2022-02-02
  • python 實現(xiàn)手機自動撥打電話的方法(通話壓力測試)

    python 實現(xiàn)手機自動撥打電話的方法(通話壓力測試)

    今天小編就為大家分享一篇python 實現(xiàn)手機自動撥打電話的方法(通話壓力測試),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08

最新評論