From a3bb7f0701cc61a738ba66c67d8485e85c33e9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E4=BD=B3?= <13101321+jfen5577@user.noreply.gitee.com> Date: Fri, 12 Sep 2025 11:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ini=20=E4=BA=BA=E8=84=B8?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QT5_Project/KD_ZM_8_XCF/APPWindow.py | 34 ++--- .../KD_ZM_8_XCF/UI/P05_01_FaceCameraView.ui | 86 +++++++++--- QT5_Project/KD_ZM_8_XCF/UI/P07SystemSet.ui | 36 +++++ QT5_Project/KD_ZM_8_XCF/UIFrameWork.py | 125 ++++++++++++++---- .../Shared_CODE/DialogFaceUserManage.py | 4 +- .../Shared_CODE/FaceRecognitionProtocol.py | 4 +- .../DialogModifyAlias.cpython-311.pyc | Bin 10077 -> 10077 bytes .../__pycache__/get_tip_prop.cpython-311.pyc | Bin 12496 -> 13240 bytes QT5_Project/Shared_CODE/get_tip_prop.py | 19 ++- QT5_Project/Shared_UI/main.ui | 104 --------------- QT5_Project/Shared_UI/users.csv | 2 +- system_parameter.ini | 1 + 12 files changed, 248 insertions(+), 167 deletions(-) delete mode 100644 QT5_Project/Shared_UI/main.ui 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 bd5d1cc34fdefbcb29178c7e177f1148de08e5de..7955efd76f29fc2dfe1da70764064ded0f2618e1 100644 GIT binary patch delta 20 acmccXch`@5IWI340}#~p9NNeoqz(W^UIs1z delta 20 acmccXch`@5IWI340}%Y}Y23&iqz(W`k_K!5 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 36a5c514687132fa5f3ee33a037be4cf084c3eab..235a0b715e5b46f9f4250231dec9398cff89269a 100644 GIT binary patch delta 1812 zcmb7De{54#6u!58uX`(7Te@znYrFnl+imPe7#P7Y7?X$zOfpRXfzj|f+;Ho1+cB9P z8wlD&hBIgCA}pdYC=jQFm>7w~fiW?Lq+6P-mKb8tfd1oK!V;tY;kmDD41q*%UcPtE zx!*nS+;_f{3V*TB@KIr*p5Xd4dF6#eo(qQSrL+@%E8VutAQv7bJB+dcF)vA8qB~5j zBxJm}**Zoo=QM=8Lu4vzWUVa7;wfQ(!a27e?6w;C%VLz6l1~zv(;~RVVjj>@bmcsF z-R2ji1eNpQak~vtHV@UqO1l%xc8^$q@dAwd;0K#kEJUx6vo@>s@fu~)O1vb_&AY2} z$-EUWowo>S*Z2rqF(AZk_hPakA)F+#5#F~KLxrOlzPHy?1D0n&%Pb_wX`||_aTHS% zY;_drvY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~(5aZ^p&Pg#E6-<4aYPfx$z^D{P1#Egj0pYrA~{ zcj94s7FZ&tUcs8;HOM9sjVO^RBr?5awLH4y4zGIQSmFc!HcYu5*loxQhO#^ET4X|=iHCh4rA>e`V0J%?pK|lsOk1CV&9_pPmYo0 zx<**q5q+A%b*+1PI~u_pNXV(eLscoTbtJP{T=+o-D z!f!Jv)lF?8SgsvEu;h-fs?eJKQ2ksK*TGNO=M!f{GjU2jDKI1OmB4v{S%C|n=i2CR z(3i_)n_1K*8+cA(ZFqrI)OuLbCL0LCce(vhx5{ER*&5Kb)2ts8bKXN# - - 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