From e812d7f3e95b26f9e20b7196d6d3581ed222fce7 Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Tue, 3 Mar 2026 09:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A8=E9=80=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=A7=86=E9=A2=91id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/checkpoint/checkpoint_biz.py | 18 +++++++++++++++--- biz/prison/prison_biz.py | 2 +- biz/prison/supervision_room_biz.py | 18 +++++++++++++++--- biz/prison/trajectory02_biz.py | 18 +++++++++++++++--- hls_service_ws_kadian.py | 1 + 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/biz/checkpoint/checkpoint_biz.py b/biz/checkpoint/checkpoint_biz.py index 1d0e43c..d9619e9 100644 --- a/biz/checkpoint/checkpoint_biz.py +++ b/biz/checkpoint/checkpoint_biz.py @@ -6,6 +6,8 @@ from typing import Dict, Any import threading import time import queue +import requests +from common.contants import ALERT_PUSH_URL # -------------------------- Kadian 检测相关导入 -------------------------- from algorithm.common.npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机) @@ -897,7 +899,7 @@ class FrameProcessorWorker(threading.Thread): msg = { "msg_type": "frame", - "camera_id": 0, + "camera_id": item["camera_index"], "timestamp": ts, # "result_type": action_names, "result_type": push_actions, @@ -905,8 +907,18 @@ class FrameProcessorWorker(threading.Thread): } try: self.ws_queue.put(msg, timeout=1.0) - # if push_actions and len(push_actions) > 0: - # self.ws_queue_2.put(msg, timeout=1.0) + if push_actions and len(push_actions) > 0: + # 发送POST请求 + post_msg = msg.copy() + post_msg['type'] = 1 + try: + response = requests.post(ALERT_PUSH_URL, json=post_msg, timeout=5.0) + if response.status_code == 200: + print(f"[INFO] POST alert sent successfully for actions: {push_actions}") + else: + print(f"[WARN] POST alert failed with status: {response.status_code}") + except Exception as e: + print(f"[ERROR] POST alert request failed: {e}") except queue.Full: logger.warning("[WARN] ws_send_queue full, drop frame message") diff --git a/biz/prison/prison_biz.py b/biz/prison/prison_biz.py index 4c01b8f..8524c93 100644 --- a/biz/prison/prison_biz.py +++ b/biz/prison/prison_biz.py @@ -421,7 +421,7 @@ class FrameProcessorWorker(threading.Thread): msg = { "msg_type": "frame", - "camera_id": 1, + "camera_id": item["camera_index"], "timestamp": ts, #"result_type": action_names, "result_type": push_actions, diff --git a/biz/prison/supervision_room_biz.py b/biz/prison/supervision_room_biz.py index f5685aa..45629e2 100644 --- a/biz/prison/supervision_room_biz.py +++ b/biz/prison/supervision_room_biz.py @@ -14,6 +14,8 @@ import base64 from typing import Dict, Any, Tuple, List +from common.contants import ALERT_PUSH_URL +import requests # -------------------------- Kadian 检测相关导入 -------------------------- from algorithm.common.npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机) @@ -580,7 +582,7 @@ class FrameProcessorWorker(threading.Thread): msg = { "msg_type": "frame", - "camera_id": 0, + "camera_id": item["camera_index"], "timestamp": ts, # "result_type": action_names, "result_type": push_actions, @@ -588,8 +590,18 @@ class FrameProcessorWorker(threading.Thread): } try: self.ws_queue.put(msg, timeout=1.0) - # if push_actions and len(push_actions) > 0: - # self.ws_queue_2.put(msg, timeout=1.0) + if push_actions and len(push_actions) > 0: + # 发送POST请求 + post_msg = msg.copy() + post_msg['type'] = 2 + try: + response = requests.post(ALERT_PUSH_URL, json=post_msg, timeout=5.0) + if response.status_code == 200: + print(f"[INFO] POST alert sent successfully for actions: {push_actions}") + else: + print(f"[WARN] POST alert failed with status: {response.status_code}") + except Exception as e: + print(f"[ERROR] POST alert request failed: {e}") except queue.Full: logger.warning("[WARN] ws_send_queue full, drop frame message") diff --git a/biz/prison/trajectory02_biz.py b/biz/prison/trajectory02_biz.py index 15cf3d8..6762450 100644 --- a/biz/prison/trajectory02_biz.py +++ b/biz/prison/trajectory02_biz.py @@ -18,6 +18,8 @@ from dataclasses import dataclass from typing import Dict, Any, Tuple, List from datetime import datetime from common.contants import ALERT_PUSH_URL +import requests + # -------------------------- Kadian 检测相关导入 -------------------------- from algorithm.common.npu_yolo_onnx_person_car_phone import YOLOv8_ONNX # 主检测模型(人/车/后备箱/手机) @@ -564,15 +566,25 @@ class FrameProcessorWorker(threading.Thread): if img_b64 is not None: msg = { "msg_type": "frame", - "camera_id": 1, + "camera_id": item["camera_index"], "timestamp": ts, "result_type": push_actions, "image_base64": img_b64, } try: self.ws_queue.put(msg, timeout=1.0) - # if push_actions and len(push_actions) > 0: - # self.ws_queue_2.put(msg, timeout=1.0) + if push_actions and len(push_actions) > 0: + # 发送POST请求 + post_msg = msg.copy() + post_msg['type'] = 2 + try: + response = requests.post(ALERT_PUSH_URL, json=post_msg, timeout=5.0) + if response.status_code == 200: + print(f"[INFO] POST alert sent successfully for actions: {push_actions}") + else: + print(f"[WARN] POST alert failed with status: {response.status_code}") + except Exception as e: + print(f"[ERROR] POST alert request failed: {e}") except queue.Full: logger.warning("[WARN] ws_send_queue full, drop frame message") diff --git a/hls_service_ws_kadian.py b/hls_service_ws_kadian.py index 2dc42c5..44319fa 100644 --- a/hls_service_ws_kadian.py +++ b/hls_service_ws_kadian.py @@ -194,6 +194,7 @@ class HLSFrameProcessor(threading.Thread): "camera_id": self.camera_cfg.id, "camera_name": self.camera_cfg.name, "timestamp": current_time, + "camera_index": self.camera_cfg.index, "frame": frame_data, }