完成监控室测试
This commit is contained in:
@@ -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]
|
||||
|
||||
# 执行检测
|
||||
|
||||
Reference in New Issue
Block a user