1.人脸验证执行操作成功
2.UI底图进行修改
This commit is contained in:
@ -19,7 +19,7 @@ import uart_group_config as group_config
|
||||
from mqtt_device import class_comm_mqtt_thread, class_comm_mqtt_interface
|
||||
from print_color import *
|
||||
from Shared_CODE.get_tip_prop import *
|
||||
from QT5_Project.Shared_CODE.DialogFaceVerify import VerifyDialog
|
||||
from QT5_Project.Shared_CODE.FaceRecognitionProtocol import *
|
||||
from QT5_Project.Shared_CODE.DialogFaceEnrollItgSingle import EnrollItgSingleDialog
|
||||
from QT5_Project.Shared_CODE.DialogFaceUserManage import UserManageDialog, save_user, load_users, save_users_list
|
||||
|
||||
@ -441,18 +441,6 @@ class QFaceCameraViewPage(PageTemplate):
|
||||
self.current_video_mode = 0
|
||||
self.current_face_box = 0
|
||||
|
||||
|
||||
#信号绑定
|
||||
self.btn_video.clicked.connect(self.toggle_video)
|
||||
self.btn_video_mode.clicked.connect(self.toggle_video_mode)
|
||||
self.chk_face_box.stateChanged.connect(self.toggle_face_box)
|
||||
self.btn_save.clicked.connect(self.save_log)
|
||||
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.t_port = QTimer(self)
|
||||
self.t_port.setInterval(1000)
|
||||
@ -464,6 +452,8 @@ class QFaceCameraViewPage(PageTemplate):
|
||||
self.t_video.timeout.connect(self._check_video)
|
||||
self.t_video.start()
|
||||
|
||||
self.face_verify_result = None # 用于存储人脸验证结果
|
||||
|
||||
self.auto_connect_serial()
|
||||
# 串口管理
|
||||
|
||||
@ -535,91 +525,6 @@ class QFaceCameraViewPage(PageTemplate):
|
||||
except Exception as e:
|
||||
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_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()
|
||||
if running:
|
||||
self.video_worker.stop()
|
||||
self.video_worker.wait(300)
|
||||
self.video_worker = None
|
||||
self.video_label.setText("未打开")
|
||||
self.video_label.setPixmap(QPixmap())
|
||||
self.btn_video.setText("打开视频")
|
||||
self.log("[INFO] 视频已关闭")
|
||||
inform_box : DialogInform = DialogInform()
|
||||
inform_box.information("提示", "视频已关闭")
|
||||
return
|
||||
|
||||
if self.video_label.width()<50 or self.video_label.height()<50:
|
||||
self.video_label.setMinimumSize(360,480)
|
||||
|
||||
self.video_worker = VideoWorker(cam_index=0, target_size=self.video_label.size())
|
||||
self.video_worker.pixmap_ready.connect(self.video_label.setPixmap)
|
||||
self.video_worker.log_message.connect(self.log)
|
||||
self.video_worker.start()
|
||||
self.btn_video.setText("关闭视频")
|
||||
self.log("[INFO] 正在打开视频")
|
||||
inform_box : DialogInform = DialogInform()
|
||||
inform_box.information("提示", "正在打开视频")
|
||||
|
||||
def toggle_video_mode(self):
|
||||
if self.current_video_mode==0:
|
||||
self.send_uvc(0)
|
||||
self.current_video_mode=1
|
||||
self.log("[INFO] 已切换到红外视频模式")
|
||||
inform_box : DialogInform = DialogInform()
|
||||
inform_box.information("提示", "已切换到红外视频模式")
|
||||
else:
|
||||
self.send_uvc(1)
|
||||
self.current_video_mode=0
|
||||
self.log("[INFO] 已切换到彩色视频模式")
|
||||
inform_box : DialogInform = DialogInform()
|
||||
inform_box.information("提示", "已切换到彩色视频模式")
|
||||
|
||||
def toggle_face_box(self, state):
|
||||
if state==Qt.Checked:
|
||||
self.face_box_enabled=True
|
||||
self.send_face_box(1)
|
||||
self.log("[INFO] 人脸框已开启")
|
||||
inform_box : DialogInform = DialogInform()
|
||||
inform_box.information("提示", "人脸框已开启")
|
||||
else:
|
||||
self.face_box_enabled=False
|
||||
self.send_face_box(0)
|
||||
self.log("[INFO] 人脸框已关闭")
|
||||
inform_box : DialogInform = DialogInform()
|
||||
inform_box.information("提示", "人脸框已关闭")
|
||||
|
||||
# ---------------- 发送指令 ----------------
|
||||
def send_uvc(self, mode):
|
||||
if self.ser and getattr(self.ser,"is_open",False):
|
||||
self.ser.write(build_uvc_view(mode))
|
||||
else:
|
||||
self.log("[WARN] 串口未连接,无法切换视频模式")
|
||||
|
||||
def send_face_box(self, state):
|
||||
if self.ser and getattr(self.ser,"is_open",False):
|
||||
self.ser.write(build_face_view(state))
|
||||
else:
|
||||
self.log("[WARN] 串口未连接,无法控制人脸框")
|
||||
|
||||
# ---------------- 定时器检测 ----------------
|
||||
def _check_video(self):
|
||||
if self.video_worker and not self.video_worker.isRunning():
|
||||
@ -644,6 +549,15 @@ class QFaceCameraViewPage(PageTemplate):
|
||||
self.log(f"[INFO] 用户 {user_name}(ID={user_id}) 已保存")
|
||||
else:
|
||||
QMessageBox.warning(self, "提示", f"用户ID {user_id} 已存在!")
|
||||
elif info.get("mid") == CMD_VERIFY :
|
||||
|
||||
if info.get("result") == 0x00:
|
||||
user_id = info.get("user_id")
|
||||
print(f"[INFO] 用户(ID={user_id}) 验证通过")
|
||||
self.face_verify_result = True
|
||||
else:
|
||||
self.face_verify_result = False
|
||||
|
||||
elif msg_id == MID_NOTE:
|
||||
info = parse_note(data)
|
||||
self.log(f"[NOTE] {info}")
|
||||
@ -847,17 +761,7 @@ class APPWindow(QMainWindow):
|
||||
#调试的时候用下面两行,全屏就注释
|
||||
# self.setGeometry(0, 0, 1024, 768)
|
||||
# self.stack.setGeometry(0, 0, 1024, 768)
|
||||
|
||||
self.ser = None
|
||||
self.worker = SerialWorker(lambda: self.ser)
|
||||
self.worker.frame_received.connect(self.on_frame)
|
||||
self.worker.log_message.connect(self.log)
|
||||
self.worker.start()
|
||||
self.video_worker = None
|
||||
self.last_port = None
|
||||
self.last_enroll_name = ""
|
||||
self.current_video_mode = 0
|
||||
self.current_face_box = 0
|
||||
|
||||
|
||||
self.showFullScreen()
|
||||
|
||||
@ -923,32 +827,6 @@ class APPWindow(QMainWindow):
|
||||
|
||||
test_init = system_parameter()
|
||||
set_screen_blanking_time(test_init.get_screen_blanking_time())
|
||||
###########################################################################
|
||||
def on_frame(self, fr: dict):
|
||||
self.log("< " + fr["raw"].hex(" "))
|
||||
msg_id = fr.get("msg_id")
|
||||
data = fr.get("data", b"")
|
||||
|
||||
if msg_id == MID_REPLY:
|
||||
info = parse_reply(data)
|
||||
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:
|
||||
if save_user(user_id, user_name):
|
||||
self.log(f"[INFO] 用户 {user_name}(ID={user_id}) 已保存")
|
||||
else:
|
||||
QMessageBox.warning(self, "提示", f"用户ID {user_id} 已存在!")
|
||||
elif msg_id == MID_NOTE:
|
||||
info = parse_note(data)
|
||||
self.log(f"[NOTE] {info}")
|
||||
|
||||
def log(self, s: str):
|
||||
ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
print(f"[{ts}] {s}") # 控制台打印日志
|
||||
|
||||
##########################################################################
|
||||
|
||||
def search_page_widget(self, page) :
|
||||
for list_item in self.allpages_list:
|
||||
|
||||
Reference in New Issue
Block a user