新增推送新增视频id

This commit is contained in:
zqc
2026-03-03 09:42:26 +08:00
parent 2f649f5e2d
commit e812d7f3e9
5 changed files with 47 additions and 10 deletions

View File

@@ -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")

View File

@@ -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,

View File

@@ -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")

View File

@@ -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")

View File

@@ -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,
}