修改算法位置

This commit is contained in:
zqc
2026-02-02 11:32:59 +08:00
parent b3fbc1577d
commit 49f0c2c678
7 changed files with 33 additions and 24 deletions

View File

@@ -31,7 +31,7 @@ except Exception as e:
# -------------------------- Kadian 检测相关导入 --------------------------
from npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机)
from algorithm.checkpoint.npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机)
from yolox.tracker.byte_tracker import BYTETracker
@@ -46,7 +46,7 @@ FACE_RECOGNITION_ENABLED = True # 是否启用人脸识别
police_prisoner_input_size = 1280
# RTSP 服务配置
RTSP_TARGET_FPS = 30.0
RTSP_TARGET_FPS = 10.0
FRAMES_PER_SEGMENT = 300
VIDEO_OUTPUT_DIR = "./videos"
WS_HOST = "0.0.0.0"
@@ -607,11 +607,23 @@ class FrameProcessorWorker(threading.Thread):
if result['has_passed']:
logger.info(f"[INFO] 犯人带出: {result['passed_person_id']}")
# 记录当前帧人脸告警信息
current_face_alert = {
# # 记录当前帧人脸告警信息
# current_face_alert = {
# "person_name": result['passed_person_id'],
# "timestamp": ts
# }
# 发送take_out类型的WebSocket消息
take_out_msg = {
"msg_type": "take_out",
"person_name": result['passed_person_id'],
"timestamp": ts
"historical_alert_count": result.get('historical_alert_count', 0)
}
try:
logger.info(f"take_out {take_out_msg}")
self.ws_queue.put(take_out_msg, timeout=1.0)
except queue.Full:
logger.warning("[WARN] ws_send_queue full, drop take_out message")
except Exception as e:
logger.error(f"[WARN] 人脸识别处理失败: {e}")
@@ -622,6 +634,9 @@ class FrameProcessorWorker(threading.Thread):
result_img = result["image"]
result_type = result["alerts"]
result_img = frame
result_type = []
# 绘制人脸识别结果
if video_face_prison_biz is not None and face_results:
result_img = video_face_prison_biz.draw_detections(result_img, face_results)
@@ -632,10 +647,10 @@ class FrameProcessorWorker(threading.Thread):
cv2.putText(result_img, face_info_text, (10, result_img.shape[0] - 20),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 255), 2)
# 写视频
writer, video_path = self._get_writer(cam_id, frame)
writer.write(result_img)
self.video_counts[cam_id] = self.video_counts.get(cam_id, 0) + 1
# # 写视频
# writer, video_path = self._get_writer(cam_id, frame)
# writer.write(result_img)
# self.video_counts[cam_id] = self.video_counts.get(cam_id, 0) + 1
# 5) 通过 WebSocket 发送帧结果
try: