增加ini 人脸超时限制

This commit is contained in:
冯佳
2025-09-12 11:32:19 +08:00
parent 0557ba7f1c
commit a3bb7f0701
12 changed files with 248 additions and 167 deletions

View File

@ -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:

View File

@ -70,9 +70,9 @@
<widget class="QGroupBox" name="group_log">
<property name="geometry">
<rect>
<x>0</x>
<y>570</y>
<width>1291</width>
<x>340</x>
<y>670</y>
<width>701</width>
<height>381</height>
</rect>
</property>
@ -94,7 +94,7 @@
<widget class="QPushButton" name="btn_save">
<property name="geometry">
<rect>
<x>550</x>
<x>0</x>
<y>0</y>
<width>211</width>
<height>41</height>
@ -120,10 +120,10 @@ color: rgb(170, 0, 0);</string>
<widget class="QTextEdit" name="txt_log">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>1111</width>
<height>321</height>
<x>-20</x>
<y>60</y>
<width>701</width>
<height>301</height>
</rect>
</property>
</widget>
@ -131,10 +131,10 @@ color: rgb(170, 0, 0);</string>
<widget class="QGroupBox" name="group_video">
<property name="geometry">
<rect>
<x>410</x>
<y>10</y>
<x>450</x>
<y>110</y>
<width>481</width>
<height>561</height>
<height>551</height>
</rect>
</property>
<property name="statusTip">
@ -146,7 +146,7 @@ color: rgb(170, 0, 0);</string>
<widget class="QLabel" name="video_label">
<property name="geometry">
<rect>
<x>70</x>
<x>60</x>
<y>50</y>
<width>360</width>
<height>480</height>
@ -191,8 +191,8 @@ color: rgb(170, 0, 0);</string>
<widget class="QGroupBox" name="group_cmd">
<property name="geometry">
<rect>
<x>260</x>
<y>20</y>
<x>340</x>
<y>110</y>
<width>109</width>
<height>551</height>
</rect>
@ -261,7 +261,7 @@ color: rgb(170, 0, 0);</string>
</rect>
</property>
<property name="statusTip">
<string>Index=0, Action=Verify,SelectImag=IMxx_00F.png</string>
<string>Index=0, Action=Verify,password,SelectImag=IMxx_00F.png</string>
</property>
<property name="text">
<string>识别</string>
@ -299,7 +299,63 @@ color: rgb(170, 0, 0);</string>
<string>用户管理</string>
</property>
</widget>
<widget class="QLineEdit" name="FaceRecogTimeoutEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>210</y>
<width>120</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>16</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="statusTip">
<string>System=FaceRecogTimeout, Action=ModifySystem, Index=13,SelectImag=P4_ParaSelect.png, password</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(85, 170, 127,0);
color: rgb(177, 229, 252);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</widget>
<widget class="QLabel" name="P05_01BG">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../image/FaceCameraView.png</pixmap>
</property>
</widget>
<zorder>P05_01BG</zorder>
<zorder>groupBox_sys</zorder>
<zorder>group_log</zorder>
<zorder>group_video</zorder>
<zorder>group_cmd</zorder>
</widget>
</widget>
<resources/>

View File

@ -864,11 +864,47 @@ color: rgb(207, 0, 13);</string>
</size>
</property>
</widget>
<widget class="QLineEdit" name="FaceRecogTimeoutEdit">
<property name="geometry">
<rect>
<x>880</x>
<y>640</y>
<width>120</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>16</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="statusTip">
<string>System=FaceRecogTimeout, Action=ModifySystem, Index=13,SelectImag=P4_ParaSelect.png, password</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(85, 170, 127,0);
color: rgb(177, 229, 252);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
<zorder>sys_P00_2</zorder>
<zorder>sys_P00_3</zorder>
<zorder>BindNum_Title</zorder>
<zorder>sys_home</zorder>
<zorder>sys_menu</zorder>
<zorder>FaceRecogTimeoutEdit</zorder>
</widget>
<widget class="QLabel" name="indicator_Label">
<property name="geometry">

View File

@ -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()