diff --git a/QT5_Project/KD_ZM_8_XCF/APPWindow.py b/QT5_Project/KD_ZM_8_XCF/APPWindow.py
index e051b56..803f029 100644
--- a/QT5_Project/KD_ZM_8_XCF/APPWindow.py
+++ b/QT5_Project/KD_ZM_8_XCF/APPWindow.py
@@ -450,7 +450,7 @@ class QFaceCameraViewPage(PageTemplate):
self.btn_reset.clicked.connect(lambda: self.send(build_reset()))
self.btn_enroll.clicked.connect(self.do_enroll_itg_single)
self.btn_users.clicked.connect(self.do_manage_users)
- self.btn_verify.clicked.connect(self.do_verify)
+ # self.btn_verify.clicked.connect(self.do_verify)
# 定时器:串口监控 & 视频重连
@@ -536,21 +536,22 @@ class QFaceCameraViewPage(PageTemplate):
self.log(f"[ERR] write: {e}")
# 业务功能
- def do_verify(self):
- dlg = VerifyDialog(self)
- if dlg.exec_() == QDialog.Accepted:
- pd_val, timeout_val = dlg.values()
- self.send(build_verify(pd_val, timeout_val))
+ # def do_verify(self):
+ # dlg = VerifyDialog(self)
+ # if dlg.exec_() == QDialog.Accepted:
+ # pd_val, timeout_val = dlg.values()
+ # self.send(build_verify(pd_val, timeout_val))
- def do_enroll_itg_single(self):
- dlg = EnrollItgSingleDialog(self)
- if dlg.exec_() == QDialog.Accepted:
- admin_val, uname, face_dir, timeout_val, itg_val = dlg.values()
- self.last_enroll_name = uname
- self.send(build_enroll_itg_single(admin_val, uname, face_dir, timeout_val, itg_val))
- def do_manage_users(self):
- UserManageDialog(self, self.send).exec_()
+ # def do_enroll_itg_single(self):
+ # dlg = EnrollItgSingleDialog(self)
+ # if dlg.exec_() == QDialog.Accepted:
+ # admin_val, uname, face_dir, timeout_val, itg_val = dlg.values()
+ # self.last_enroll_name = uname
+ # self.send(build_enroll_itg_single(admin_val, uname, face_dir, timeout_val, itg_val))
+
+ # def do_manage_users(self):
+ # UserManageDialog(self, self.send).exec_()
def toggle_video(self):
running = self.video_worker and self.video_worker.isRunning()
@@ -636,8 +637,9 @@ class QFaceCameraViewPage(PageTemplate):
self.log(f"[REPLY] {info}")
if info.get("mid") in (CMD_ENROLL, CMD_ENROLL_ITG) and info.get("result") == 0x00:
user_id = info.get("user_id")
- user_name = self.last_enroll_name or ""
- if user_id and user_name:
+ # 如果用户名为空,使用用户ID作为用户名
+ user_name = self.last_enroll_name if self.last_enroll_name else str(user_id)
+ if user_id: # 只需检查user_id存在即可,因为user_name已确保有值
if save_user(user_id, user_name):
self.log(f"[INFO] 用户 {user_name}(ID={user_id}) 已保存")
else:
diff --git a/QT5_Project/KD_ZM_8_XCF/UI/P05_01_FaceCameraView.ui b/QT5_Project/KD_ZM_8_XCF/UI/P05_01_FaceCameraView.ui
index 9578a15..962a1b6 100644
--- a/QT5_Project/KD_ZM_8_XCF/UI/P05_01_FaceCameraView.ui
+++ b/QT5_Project/KD_ZM_8_XCF/UI/P05_01_FaceCameraView.ui
@@ -70,9 +70,9 @@
- 0
- 570
- 1291
+ 340
+ 670
+ 701
381
@@ -94,7 +94,7 @@
- 550
+ 0
0
211
41
@@ -120,10 +120,10 @@ color: rgb(170, 0, 0);
- 40
- 40
- 1111
- 321
+ -20
+ 60
+ 701
+ 301
@@ -131,10 +131,10 @@ color: rgb(170, 0, 0);
- 410
- 10
+ 450
+ 110
481
- 561
+ 551
@@ -146,7 +146,7 @@ color: rgb(170, 0, 0);
- 70
+ 60
50
360
480
@@ -191,8 +191,8 @@ color: rgb(170, 0, 0);
- 260
- 20
+ 340
+ 110
109
551
@@ -261,7 +261,7 @@ color: rgb(170, 0, 0);
- Index=0, Action=Verify,SelectImag=IMxx_00F.png
+ Index=0, Action=Verify,password,SelectImag=IMxx_00F.png
识别
@@ -299,7 +299,63 @@ color: rgb(170, 0, 0);
用户管理
+
+
+
+ 0
+ 210
+ 120
+ 25
+
+
+
+
+ Arial
+ 16
+
+
+
+ Qt::NoFocus
+
+
+ System=FaceRecogTimeout, Action=ModifySystem, Index=13,SelectImag=P4_ParaSelect.png, password
+
+
+ background-color: rgba(85, 170, 127,0);
+color: rgb(177, 229, 252);
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+ false
+
+
+
+
+
+ 0
+ 0
+ 1920
+ 1080
+
+
+
+
+
+
+ ../image/FaceCameraView.png
+
+
+ P05_01BG
+ groupBox_sys
+ group_log
+ group_video
+ group_cmd
diff --git a/QT5_Project/KD_ZM_8_XCF/UI/P07SystemSet.ui b/QT5_Project/KD_ZM_8_XCF/UI/P07SystemSet.ui
index 28b135a..9675463 100644
--- a/QT5_Project/KD_ZM_8_XCF/UI/P07SystemSet.ui
+++ b/QT5_Project/KD_ZM_8_XCF/UI/P07SystemSet.ui
@@ -864,11 +864,47 @@ color: rgb(207, 0, 13);
+
+
+
+ 880
+ 640
+ 120
+ 25
+
+
+
+
+ Arial
+ 16
+
+
+
+ Qt::NoFocus
+
+
+ System=FaceRecogTimeout, Action=ModifySystem, Index=13,SelectImag=P4_ParaSelect.png, password
+
+
+ background-color: rgba(85, 170, 127,0);
+color: rgb(177, 229, 252);
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+ false
+
+
sys_P00_2
sys_P00_3
BindNum_Title
sys_home
sys_menu
+ FaceRecogTimeoutEdit
diff --git a/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py b/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py
index a2a8c2a..079bdaa 100644
--- a/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py
+++ b/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py
@@ -20,7 +20,7 @@ from Shared_CODE.DialogModifyValue import DialogModifyValue
from Shared_CODE.DialogModifyAlias import DialogModifyAlias
from Shared_CODE.DialogModifyText import DialogModifyText
from Shared_CODE.DialogInform import DialogInform
-from QT5_Project.Shared_CODE.DialogFaceVerify import VerifyDialog
+from QT5_Project.Shared_CODE.FaceRecognitionProtocol import parse_reply
from QT5_Project.Shared_CODE.DialogFaceEnrollItgSingle import EnrollItgSingleDialog
from QT5_Project.Shared_CODE.DialogFaceUserManage import UserManageDialog
@@ -476,7 +476,7 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
self.check_widget_timeout_timer.timeout.connect(self.process_widget_timeout_list)
self.check_widget_timeout_timer.start(100)
self.page = get_tip_page(self.statusTip())
- self.menu_selectable_object_flush()
+ self.menu_selectable_object_flush()
def get_circuit_mask(self, child_widget : QWidget = None) :
widget :QWidget = child_widget
@@ -542,14 +542,15 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
)
def process_widget_timeout_list(self) :
- list_index = 0
+ list_index = 0
+ self.para_face() #刷新人脸数据显示
for timeout_items in self.widget_timeout_list:
time_limit = timeout_items[0]
cur_time = timeout_items[1]
cur_time += 100
if cur_time >= time_limit:
cur_time = 0
- timeout_widget : QWidget = timeout_items[2]
+ timeout_widget : QWidget = timeout_items[2]
if isinstance(timeout_widget, QLineEdit) :
lineedit_widget : QLineEdit = timeout_widget
lineedit_widget.setText("通信超时")
@@ -723,6 +724,7 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
self.create_alias_list()
self.process_alias_query()
self.para_or_measure_query()
+ self.para_face()
def create_alias_list(self, child = None) :
widget :QWidget = self
@@ -767,21 +769,43 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
def on_select_object_action_process(self, select_object : QWidget) :
tip_str = select_object.statusTip()
action_str = get_tip_value_str(tip_str, "Action", None)
+ input = False
if action_str != None :
- if "password" in tip_str :
- dialog_modify_text = DialogModifyValue(self)
- caption_str = "请输入密码:"
- dialog_modify_text.update_modify_info("", "0000", caption_str)
- input = False
-
- if dialog_modify_text.exec() == QDialog.Accepted:
- input = True
- modify_screen_time_str = dialog_modify_text.value
- pass_word = system_parameter()
- if modify_screen_time_str != pass_word.get_system_password() :
- inform_box : DialogInform = DialogInform()
- inform_box.information("提示", "密码错误,无法修改!")
- return
+ if "password" in tip_str:
+
+ # 第一步:弹出认证方式选择框
+ dialog_auth_choice = DialogModifyAlias(self)
+ auth_dict = {
+ "face": "人脸认证",
+ "word": "密码认证"
+ }
+ dialog_auth_choice.set_alias_item_info(auth_dict, "password", "请选择认证方式")
+
+ if dialog_auth_choice.exec() == QDialog.Accepted:
+ choice = dialog_auth_choice.value
+
+ # 第二步:根据选择执行不同的认证
+ if choice == "word":
+ dialog_modify_text = DialogModifyValue(self)
+ caption_str = "请输入密码:"
+ dialog_modify_text.update_modify_info("", "0000", caption_str)
+ input = False
+ if dialog_modify_text.exec() == QDialog.Accepted:
+ input = True
+ modify_screen_time_str = dialog_modify_text.value
+ pass_word = system_parameter()
+ if modify_screen_time_str != pass_word.get_system_password():
+ inform_box = DialogInform()
+ inform_box.information("提示", "密码错误,无法修改!")
+ return
+ print("密码认证成功")
+
+ elif choice == "face":
+ # face_page = self.parent_window.P05_01_FaceCameraView
+ input = True
+
+
+
else:
input = True
if input :
@@ -799,12 +823,13 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
if isinstance(select_object, QLineEdit) :
self.on_line_edit_modify_click(select_object)
elif "Users" in action_str :
- UserManageDialog(self, self.sender()).exec_()
+ self.do_manage_users()
elif "Verify" in action_str :
- dlg = VerifyDialog(self)
- if dlg.exec_() == QDialog.Accepted:
- pd_val, timeout_val = dlg.values()
- self.send(build_verify(pd_val, timeout_val))
+ self.do_verify()
+ elif "EnrollItgSingle" in action_str :
+ self.do_enroll_itg_single()
+ elif "Reset" in action_str :
+ self.reset_command()
self.virtual_widget_action_process(select_object, action_str)
@@ -818,7 +843,27 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
break
menu_index += 1
return match_object, menu_index
-
+################################################################################
+
+ def do_verify(self):
+ pd_val = 0
+ timeout_val = system_parameter().get_verify_timeout()
+ self.send(build_verify(pd_val, timeout_val))
+
+ def do_enroll_itg_single(self):
+ dlg = EnrollItgSingleDialog(self)
+ if dlg.exec_() == QDialog.Accepted:
+ admin_val, uname, face_dir, timeout_val, itg_val = dlg.values()
+ self.last_enroll_name = uname
+ self.send(build_enroll_itg_single(admin_val, uname, face_dir, timeout_val, itg_val))
+
+ def do_manage_users(self):
+ UserManageDialog(self, self.send).exec_()
+
+ def reset_command(self):
+ self.send(build_reset())
+
+################################################################################
#刷新屏幕上的系统信息, 例如时间日期之类
def flush_system_info(self, child = None) :
widget : QWidget= child
@@ -953,6 +998,22 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
pass_word.set_system_password(modify_screen_time_str)
dialog_inform = DialogInform(self)
dialog_inform.information("系统密码修改", "系统密码修改成功")
+
+ elif system == "FaceRecogTimeout":
+ dialog_modify_text = DialogModifyValue(self)
+ caption_str = "修改人脸识别超时时间(秒)"
+ frt = system_parameter()
+ dialog_modify_text.update_modify_info("", str(frt.get_verify_timeout()), caption_str)
+
+ if dialog_modify_text.exec() == QDialog.Accepted:
+ modify_screen_time_str = dialog_modify_text.value
+ result = frt.set_verify_timeout(modify_screen_time_str)
+
+ if result is not None:
+ self.FaceRecogTimeoutEdit.setText(str(result))
+ dialog_inform = DialogInform(self)
+ dialog_inform.information("人脸识别超时时间修改", "人脸识别超时时间修改成功")
+
def on_line_edit_modify_click(self, sender :QLineEdit) :
match_object : QLineEdit = None
match_object, menu_index = self.search_menu_match_object(sender)
@@ -1307,7 +1368,7 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
def menu_selectable_object_flush(self) :
menu_count = len(self.sort_menu_list)
- for i in range(menu_count):
+ for i in range(menu_count):
object : QWidget = self.sort_menu_list[i][1]
is_select_object_draw = False
@@ -1665,6 +1726,20 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
self.param_dict[mqtt_str] = ALIAS_QUERY_NONE
self.para_or_measure_query(child_widget)
+ def para_face(self, child = None) :
+ widget :QWidget = self
+ if child == None :
+ self.param_dict = {}
+ else :
+ widget = child
+ for child_widget in widget.children():
+ if hasattr(child_widget, "statusTip") :
+ tip_str : str = child_widget.statusTip()
+ if "FaceRecogTimeout" in tip_str :
+ frt = system_parameter()
+ child_widget.setText(str(frt.get_verify_timeout()))
+ continue
+ self.para_face(child_widget)
def flush_system_cycle(self) :
self.flush_system_info()
diff --git a/QT5_Project/Shared_CODE/DialogFaceUserManage.py b/QT5_Project/Shared_CODE/DialogFaceUserManage.py
index cdfe261..3813bed 100644
--- a/QT5_Project/Shared_CODE/DialogFaceUserManage.py
+++ b/QT5_Project/Shared_CODE/DialogFaceUserManage.py
@@ -68,7 +68,7 @@ def save_user(user_id: int, user_name: str) -> bool:
return True
class UserManageDialog(QDialog):
- def __init__(self, parent, send_func):
+ def __init__(self, parent=None, send_func=None):
super().__init__(parent)
self.send_func = send_func
uic.loadUi(users_ui_file_path, self)
@@ -91,7 +91,7 @@ class UserManageDialog(QDialog):
def delete_selected(self):
row = self.table.currentRow()
if row < 0:
- QMessageBox.warning(self, "提示", "请选择要删除的用户")
+ QMessageBox.warning(self, "提示", "删除选择用户")
return
uid = self.table.item(row, 0).text()
uname = self.table.item(row, 1).text()
diff --git a/QT5_Project/Shared_CODE/FaceRecognitionProtocol.py b/QT5_Project/Shared_CODE/FaceRecognitionProtocol.py
index 22420fa..ba8dbcf 100644
--- a/QT5_Project/Shared_CODE/FaceRecognitionProtocol.py
+++ b/QT5_Project/Shared_CODE/FaceRecognitionProtocol.py
@@ -87,6 +87,8 @@ CMD_NAMES = {
CMD_GET_VERSION: "获取版本信息",
CMD_INIT_ENCRYPTION: "初始化加密",
CMD_ENROLL_WITH_PHOTO: "照片录入注册",
+ CMD_FACE_VIEW: "人脸框显示切换",
+ CMD_UVC_VIEW: "视频模式切换",
}
# 结果码名称映射(结果码 -> 中文名称)
@@ -218,7 +220,7 @@ def build_led_control(state: int) -> bytes:
#pd_rightaway: int,验证成功后是否立即断电(0=不立即断电,1=立即断电),仅保留低8位有效(通过&0xFF确保)
#timeout: int,验证超时时间(单位:秒),范围通常为1-255秒,仅保留低8位有效(通过&0xFF确保)
-def build_verify(pd_rightaway: int = 0, timeout: int = 10) -> bytes:
+def build_verify(pd_rightaway, timeout: int = 10) -> bytes:
data = struct.pack("BB", pd_rightaway & 0xFF, timeout & 0xFF)
return pack_frame(CMD_VERIFY, data)
diff --git a/QT5_Project/Shared_CODE/__pycache__/DialogModifyAlias.cpython-311.pyc b/QT5_Project/Shared_CODE/__pycache__/DialogModifyAlias.cpython-311.pyc
index bd5d1cc..7955efd 100644
Binary files a/QT5_Project/Shared_CODE/__pycache__/DialogModifyAlias.cpython-311.pyc and b/QT5_Project/Shared_CODE/__pycache__/DialogModifyAlias.cpython-311.pyc differ
diff --git a/QT5_Project/Shared_CODE/__pycache__/get_tip_prop.cpython-311.pyc b/QT5_Project/Shared_CODE/__pycache__/get_tip_prop.cpython-311.pyc
index 36a5c51..235a0b7 100644
Binary files a/QT5_Project/Shared_CODE/__pycache__/get_tip_prop.cpython-311.pyc and b/QT5_Project/Shared_CODE/__pycache__/get_tip_prop.cpython-311.pyc differ
diff --git a/QT5_Project/Shared_CODE/get_tip_prop.py b/QT5_Project/Shared_CODE/get_tip_prop.py
index c1501b6..c471a16 100644
--- a/QT5_Project/Shared_CODE/get_tip_prop.py
+++ b/QT5_Project/Shared_CODE/get_tip_prop.py
@@ -149,7 +149,8 @@ class system_parameter :
default_config = {
'screen_blanking_time': '360',
'system_password': '2008',
- 'language': 'zh_CN'
+ 'language': 'zh_CN',
+ "facerecognition_timeout": '10',
}
# 如果配置文件存在,加载配置
@@ -161,6 +162,7 @@ class system_parameter :
self.screen_blanking_time = system_param.get('blanking_time', default_config['screen_blanking_time'])
self.system_password = system_param.get('password', default_config['system_password'])
self.language = system_param.get('language', default_config['language'])
+ self.facerecognition_timeout = system_param.get('facerecognition_timeout', default_config['facerecognition_timeout'])
except (configparser.Error, KeyError) as e:
# 处理读取配置文件时的错误
print(f"读取配置错误: {e}。使用默认设置。")
@@ -174,6 +176,7 @@ class system_parameter :
self.screen_blanking_time = default_config['screen_blanking_time']
self.system_password = default_config['system_password']
self.language = default_config['language']
+ self.facerecognition_timeout = default_config['facerecognition_timeout']
def write_to_ini(self):
"""将默认配置写入ini文件。"""
@@ -181,7 +184,8 @@ class system_parameter :
config['SystemParam'] = {
'blanking_time': self.screen_blanking_time,
'password': self.system_password,
- 'language': self.language
+ 'language': self.language,
+ 'facerecognition_timeout': self.facerecognition_timeout
}
with open("system_parameter.ini", 'w') as configfile:
config.write(configfile)
@@ -208,12 +212,21 @@ class system_parameter :
def get_system_language(self):
return self.language
+ def set_verify_timeout(self, timeout):
+ self.facerecognition_timeout = timeout
+ self.write_to_ini()
+
+ def get_verify_timeout(self):
+ return int(self.facerecognition_timeout)
+
# 向文件存储系统信息
def write_to_ini(self):
system_param = configparser.ConfigParser()
system_param['SystemParam'] = {'language': self.language,
'blanking_time': self.screen_blanking_time,
- 'password': self.system_password}
+ 'password': self.system_password,
+ 'facerecognition_timeout': self.facerecognition_timeout}
+
with open('system_parameter.ini', 'w') as f:
system_param.write(f)
\ No newline at end of file
diff --git a/QT5_Project/Shared_UI/main.ui b/QT5_Project/Shared_UI/main.ui
deleted file mode 100644
index bd31b54..0000000
--- a/QT5_Project/Shared_UI/main.ui
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
- MainWindow
-
-
- 人脸识别测试软件 (PyQt5)
-
-
-
-
- 8
-
-
-
- -
-
-
- 串口设置
-
-
-
- Port:
-
- - Baud:
-
- - 刷新端口
- - 连接
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
-
- 命令
-
- 6
-
- 复位
- - 视频模式
- - 显示人脸框
- - 识别
- - ITG注册
- - 用户管理
- -
-
- Qt::Vertical
-
- 2040
-
-
-
-
-
-
-
-
- USB 视频流
-
- 6
- -
-
- 未打开
- Qt::AlignCenter
- 360480
- QFrame::Box
- QFrame::Sunken
-
-
- - 打开视频
-
-
-
-
-
-
- -
-
- 日志
-
- 6
-
-
-
- true
-
- Consolas10
-
-
-
- - 保存日志
-
-
-
-
-
-
-
-
-
-
diff --git a/QT5_Project/Shared_UI/users.csv b/QT5_Project/Shared_UI/users.csv
index 41bb842..2f3e6c3 100644
--- a/QT5_Project/Shared_UI/users.csv
+++ b/QT5_Project/Shared_UI/users.csv
@@ -1 +1 @@
-1,冯佳,2025-09-02 09:05:45
+1,1,2025-09-11 16:21:21
diff --git a/system_parameter.ini b/system_parameter.ini
index cf1b138..8f03ebb 100644
--- a/system_parameter.ini
+++ b/system_parameter.ini
@@ -2,4 +2,5 @@
language = zh_CN
blanking_time = 360
password = 2008
+facerecognition_timeout = 20