-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathface.py
More file actions
91 lines (80 loc) · 2.81 KB
/
face.py
File metadata and controls
91 lines (80 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import sys
from tkinter import *
from tkinter import filedialog,messagebox
from PIL import Image, ImageTk
from CommonFunctions import *
from deepface import DeepFace
from FaceDataBaseDialog import *
from FaceFindialog import *
from os import *
#预定义窗口变量
mainWindow=None
##########################
#功能:显示人脸入库窗口
#输入:
# 无
#输出:
# 无
##########################
def ShowDBaseWindow():
window = FaceDataBaseDialog( mainWindow )
window.grab_set()
return
##########################
#功能:显示人脸识别窗口
#输入:
# 无
#输出:
# 无
##########################
def ShowRecoganizeWindow():
window = FaceFindialog( mainWindow )
window.grab_set()
return
# 判断人脸库目录是否存在,不存在则创建
if ( not os.path.exists(FACE_DB)):
os.makedirs(FACE_DB)
# 设置deepface 预训练库位置环境变量
deepfaceHome=os.getenv('DEEPFACE_HOME')
# 判断DEEPFACE_HOME环境变量是否存在,若不存在则用自己的FACE_MODEL创建DEEPFACE_HOME环境变量
if ( deepfaceHome==None or len(deepfaceHome)<1 ):
os.environ['DEEPFACE_HOME']= os.path.abspath(FACE_MODELS)
#创建主窗口
mainWindow = Tk()
mainWindow.title('VisageX by NeverForever.space')
mainWindow.geometry("480x270")
mainWindow.resizable(False,False)
centerWindow(mainWindow,480,270)
#创建人脸入库按钮
buttonFaceDBase = Button(mainWindow,
text="人脸入库",
height=2,
font=("Microsoft Yahei", 14),
highlightbackground="black",
highlightcolor="green",
highlightthickness=2,
justify="center",
overrelief="raised",
padx=10,
pady=5,
width=12,
foreground='#444',
command=ShowDBaseWindow)
# 创建人脸识别按钮
buttonFaceRecoganize = Button(mainWindow,
text="人脸识别",
height=2,
font=("Microsoft Yahei", 14),
highlightbackground="black",
highlightcolor="green",
highlightthickness=2,
justify="center",
overrelief="raised",
padx=10,
pady=5,
width=12,
foreground='#444',
command=ShowRecoganizeWindow)
buttonFaceDBase.place(x=50,y=90)
buttonFaceRecoganize.place(x=249,y=90)
mainWindow.mainloop()