代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
# @Author : WuFanLong
# @Time : 2021/10/25 10:26
# @File : main.py
# @Software: PyCharm
# @Function:
import tkinter as tk
from tkinter import messagebox
from FaceDataCollect import Call1
from face_training import Call2
from face_recognition import Call3
def get_window_size(win, update=True):
""" 获得窗体的尺寸 """
if update:
win.update()
return win.winfo_width(), win.winfo_height(), win.winfo_x(), win.winfo_y()
def center_window(win, width=None, height=None):
""" 将窗口屏幕居中 """
screenwidth = win.winfo_screenwidth()
screenheight = win.winfo_screenheight()
if width is None:
width, height = get_window_size(win)[:2]
size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 3)
win.geometry(size)
class Main:
def __init__(self):
self.root = tk.Tk()
self.root.geometry("%dx%d" % (600, 400)) # 窗体尺寸
center_window(self.root) # 将窗体移动到屏幕中央
self.root.title("人脸识别") # 窗体标题
self.body()
@staticmethod
def call_back11(na):
if 'yes' == messagebox.askquestion('提示', '要执行此操作吗'): # 是/否,返回值yes/no
if len(na) != 0:
Call1.call_back1(na, 100)
else:
messagebox.showinfo("提示", "请输入待采集人脸数据的用户!")
@staticmethod
def call_back22():
if 'yes' == messagebox.askquestion('提示', '要执行此操作吗'): # 是/否,返回值yes/no
Call2.call_back2()
@staticmethod
def call_back33():
if 'yes' == messagebox.askquestion('提示', '要执行此操作吗'): # 是/否,返回值yes/no
Call3.call_back3()
def body(self):
tk.Label(self.root, text=" ").pack(fill='both', expand=True)
tk.Label(self.root, text=" ").pack(fill='both', expand=True, side='left')
tk.Label(self.root, text=" ").pack(fill='both', expand=True, side='bottom')
tk.Label(self.root, text=" ").pack(fill='both', expand=True, side='right')
frame1 = tk.Frame(self.root)
frame1.pack(fill='both', expand=True)
tk.Label(frame1, text="用户名:").pack(fill='both', expand=True, side='left')
name = tk.Entry(frame1)
name.pack(fill='both', expand=True, side='right')
tk.Button(self.root, text="人脸数据收集", command=lambda: self.call_back11(name.get())).pack(fill='both', expand=True)
tk.Button(self.root, text="训练人脸识别模型", command=self.call_back22).pack(fill='both', expand=True)
tk.Button(self.root, text="人脸识别", command=self.call_back33).pack(fill='both', expand=True)
if __name__ == "__main__":
app = Main()
app.root.mainloop()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。