实现精细化人脸识别功能,人脸交互详细, UI部分还需要优化
This commit is contained in:
@ -42,7 +42,7 @@ import serial.tools.list_ports
|
||||
from Shared_CODE.FaceRecognitionProtocol import (
|
||||
build_reset, build_uvc_view, build_face_view, build_verify,
|
||||
build_enroll_itg_single, build_delete_all, build_get_all_userid,
|
||||
build_delete_user, unpack_frame, parse_reply, parse_note,
|
||||
build_delete_user, unpack_frame, parse_reply, parse_note,build_enroll_single,
|
||||
MID_REPLY, MID_NOTE, CMD_ENROLL, CMD_ENROLL_ITG
|
||||
)
|
||||
|
||||
@ -829,8 +829,6 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
|
||||
self._face_verify_locked = False # 解锁
|
||||
if face_frame.face_verify_result:
|
||||
input = True
|
||||
inform_box = DialogInform()
|
||||
inform_box.information("提示", "人脸认证成功")
|
||||
self._after_face_verify(select_object, action_str)
|
||||
else:
|
||||
input = False
|
||||
@ -840,8 +838,6 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
|
||||
self._face_verify_timer.stop()
|
||||
self._face_verify_locked = False # 解锁
|
||||
input = False
|
||||
inform_box = DialogInform()
|
||||
inform_box.information("提示", "人脸认证超时")
|
||||
# 解绑旧槽,绑定新槽
|
||||
try:
|
||||
self._face_verify_timer.timeout.disconnect()
|
||||
@ -963,16 +959,17 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
|
||||
pd_val = 0
|
||||
timeout_val = system_parameter().get_verify_timeout()
|
||||
face_send = self.parent_window.P05_01_FaceCameraView
|
||||
face_send.verify_in_progress = True
|
||||
face_send.send(build_verify(pd_val, timeout_val))
|
||||
|
||||
|
||||
def do_enroll_itg_single(self):
|
||||
admin_val = 0
|
||||
uname = " "
|
||||
face_dir = 31
|
||||
timeout_val = system_parameter().get_verify_timeout()
|
||||
itg_val = 0
|
||||
self.send(build_enroll_itg_single(admin_val, uname, face_dir, timeout_val, itg_val))
|
||||
face_send = self.parent_window.P05_01_FaceCameraView
|
||||
face_send.verify_in_progress = True
|
||||
self.send(build_enroll_single(admin_val, uname, timeout_val))
|
||||
|
||||
def do_manage_users(self):
|
||||
UserManageDialog(self, self.send).exec_()
|
||||
@ -1046,7 +1043,7 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
|
||||
else:
|
||||
self.log("[WARN] 串口未连接,无法控制人脸框")
|
||||
|
||||
def delete_user_by_id(self, CSV_FILE = CSV_FILE):
|
||||
def delete_user_by_id(self, CSV_FILE=CSV_FILE):
|
||||
users = load_users()
|
||||
|
||||
# 弹出对话框选择用户ID
|
||||
@ -1064,22 +1061,27 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
|
||||
DialogInform(self).information("提示", "请输入有效数字ID")
|
||||
return
|
||||
|
||||
# 查找用户
|
||||
user = next((u for u in users if u["user_id"] == user_id), None)
|
||||
user_id_str = str(user_id)
|
||||
|
||||
# 查找用户(用字符串匹配,避免类型问题)
|
||||
user = next((u for u in users if str(u["user_id"]).strip() == user_id_str), None)
|
||||
if not user:
|
||||
DialogInform(self).information("提示", "用户不存在")
|
||||
return
|
||||
|
||||
try:
|
||||
# 1️⃣ 下发删除命令
|
||||
self.send(build_delete_user(user_id))
|
||||
# 1️⃣ 下发删除命令(串口模块)
|
||||
try:
|
||||
self.send(build_delete_user(user_id))
|
||||
except Exception as e:
|
||||
DialogInform(self).information("提示", f"警告:串口删除失败,但本地仍会删除\n{e}")
|
||||
|
||||
# 2️⃣ 删除 CSV 文件对应行
|
||||
if os.path.exists(CSV_FILE):
|
||||
with open(CSV_FILE, "r", encoding="utf-8", newline="") as f:
|
||||
reader = csv.DictReader(f)
|
||||
fieldnames = reader.fieldnames
|
||||
new_rows = [row for row in reader if str(row.get("user_id")) != str(user_id)]
|
||||
new_rows = [row for row in reader if str(row.get("user_id")).strip() != user_id_str]
|
||||
|
||||
with open(CSV_FILE, "w", encoding="utf-8", newline="") as f:
|
||||
writer = csv.DictWriter(f, fieldnames=fieldnames)
|
||||
@ -1091,12 +1093,12 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface):
|
||||
return
|
||||
|
||||
# 3️⃣ 更新内存用户列表
|
||||
users = [u for u in users if u["user_id"] != user_id]
|
||||
users = [u for u in users if str(u["user_id"]).strip() != user_id_str]
|
||||
save_users_list(users)
|
||||
|
||||
# 4️⃣ 提示删除成功
|
||||
DialogInform(self).information("提示", f"用户 {user.get('user_name', '')} (ID={user_id}) 已删除")
|
||||
|
||||
self.refresh()
|
||||
|
||||
def query_user_count(self):
|
||||
self.send(build_get_all_userid())
|
||||
|
||||
Reference in New Issue
Block a user