• 大小: 22KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: Python
  • 标签: python  dlib  

资源简介

基于Dlib的人脸识别样本采集,宿舍智能出入管理窗口系统,支持宿舍的增删,人脸的采集录入,日志管理,通过验证就播放语音“welcome!”(模拟开门)

资源截图

代码片段和文件信息

#!/usr/bin/env python
# coding: utf-8

# In[1]:


import wx
import wx.grid
import sqlite3
from time import localtimestrftime
import os
from skimage import io as iio
import io
import zlib
import dlib  # 人脸识别的库dlib
import numpy as np  # 数据处理的库numpy
import cv2  # 图像处理的库OpenCv
import _thread
import threading
import stat
import shutil
from playsound import playsound
import pyttsx3



ID_NEW_REGISTER = 160
ID_DELETE_MEMBER = 161

ID_START_PUNCHCARD = 190
ID_END_PUNCARD = 191

ID_NEW_MANAGER = 220

ID_OPEN_LOGCAT = 283
ID_CLOSE_LOGCAT = 284

ID_WORKER_UNAVIABLE = -1

PATH_FACE = “F:/WorkAttendanceSystem-master/V2.0/data/face_img_database/“

facerec = dlib.face_recognition_model_v1(“F:/WorkAttendanceSystem-master/V2.0/model/dlib_face_recognition_resnet_model_v1.dat“)
# Dlib 预测器
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(‘F:/WorkAttendanceSystem-master/V2.0/model/shape_predictor_68_face_landmarks.dat‘)


# In[2]:


def return_euclidean_distance(feature_1 feature_2):
    feature_1 = np.array(feature_1)
    feature_2 = np.array(feature_2)
    dist = np.sqrt(np.sum(np.square(feature_1 - feature_2)))#欧式距离
    if dist > 0.4:
        return “diff“
    else:
        return “same“

class WAS(wx.frame):
    def __init__(self):
        wx.frame.__init__(selfparent=Nonetitle=“宿舍管理系统“size=(920560))
        self.initMenu()
        self.initInfoText()
        self.initGallery()
        self.initDatabase()
        self.initData()

    def initData(self):
        self.name = ““
        self.id =ID_WORKER_UNAVIABLE
        self.face_feature = ““
        self.pic_num = 0
        self.flag_registed = False
        self.loadDatabase(1)

    def initMenu(self):

        menuBar = wx.MenuBar()  #生成菜单栏
        menu_Font = wx.Font()#Font(faceName=“consolas“pointsize=20)
        menu_Font.SetPointSize(14)
        menu_Font.SetWeight(wx.BOLD)


        registerMenu = wx.Menu() #生成菜单
        self.new_register = wx.MenuItem(registerMenuID_NEW_REGISTER“新建录入“)
        self.new_register.SetBitmap(wx.Bitmap(“F:/WorkAttendanceSystem-master/V2.0/drawable/new_register.png“))
        self.new_register.SetTextColour(“SLATE BLUE“)
        self.new_register.SetFont(menu_Font)
        registerMenu.Append(self.new_register)

        self.delete_member = wx.MenuItem(registerMenuID_DELETE_MEMBER“人员删除“)
        self.delete_member.SetBitmap(wx.Bitmap(“F:/WorkAttendanceSystem-master/V2.0/drawable/finish_register.png“))
        self.delete_member.SetTextColour(“SLATE BLUE“)
        self.delete_member.SetFont(menu_Font)
        registerMenu.Append(self.delete_member)


        puncardMenu = wx.Menu()
        self.start_punchcard = wx.MenuItem(puncardMenuID_START_PUNCHCARD“开始监测“)
        self.start_punchcard.SetBitmap(wx.Bitmap(“F:/WorkAttendanceSystem-master/V2.0/drawable/start_punchcard.png“))
        self.start_punchcard.SetTextColour(“SLATE BLUE“)
        self.start_punchcard.SetFont(menu_Font)
        puncardMenu.Append(self.start_punchcard)

        s

评论

共有 条评论