From d64d058c8890994dc90d8c15e2ae602230560729 Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Fri, 27 Feb 2026 15:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=9B=91=E6=8E=A7=E5=AE=A4?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/prison/supervision_room_biz.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/biz/prison/supervision_room_biz.py b/biz/prison/supervision_room_biz.py index b6b8973..f5685aa 100644 --- a/biz/prison/supervision_room_biz.py +++ b/biz/prison/supervision_room_biz.py @@ -16,15 +16,15 @@ from typing import Dict, Any, Tuple, List # -------------------------- Kadian 检测相关导入 -------------------------- -from algorithm.checkpoint.npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机) +from algorithm.common.npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机) from yolox.tracker.byte_tracker import BYTETracker from utils.logger import get_logger logger = get_logger(__name__) # ========================= 配置区 ========================= -Person_Phone_Model = r'D:\Python_Save\PoliceProject\Yolo_Weight\person_phone_model.onnx' # 人和手机的检测模型 -Smoke_Model = r'D:\Python_Save\PoliceProject\Yolo_Weight\smoke_model.onnx' # 抽烟检测模型 +Person_Phone_Model = r'Yolo_Weight/person_phone_model.onnx' # 人和手机的检测模型 +Smoke_Model = r'Yolo_Weight/smoke_model.onnx' # 抽烟检测模型 person_phone_input_size = 1280 # 模型输入尺寸,与训练时的模型一致 smoke_input_size = 1280 # 模型输入尺寸,与训练时的模型一致 @@ -38,7 +38,7 @@ ALERT_PUSH_INTERVAL = 5.0 # 相同action 5秒内仅推送一次 class ZhihuishiDetector: - def __init__(self): + def __init__(self, params=None): # 模型加载 # 人和手机检测模型 @@ -495,11 +495,12 @@ class ZhihuishiDetector: # ========================= 帧处理线程 ========================= class FrameProcessorWorker(threading.Thread): - def __init__(self, raw_queue: queue.Queue, ws_queue: queue.Queue, stop_event: threading.Event): + def __init__(self, raw_queue: queue.Queue, ws_queue: queue.Queue, stop_event: threading.Event, cameras=None): super().__init__(daemon=True) self.raw_queue = raw_queue self.ws_queue = ws_queue self.stop_event = stop_event + self.cameras = {cam.id: cam for cam in cameras} if cameras is not None else {} self.last_ts: Dict[int, float] = {} @@ -533,7 +534,9 @@ class FrameProcessorWorker(threading.Thread): # 获取检测器实例 if cam_id not in self.kadian_detectors: - self.kadian_detectors[cam_id] = ZhihuishiDetector() + camera_config = self.cameras.get(cam_id) + params = camera_config.params if camera_config else None + self.kadian_detectors[cam_id] = ZhihuishiDetector(params) detector = self.kadian_detectors[cam_id] # 执行检测