修改indoor警报
This commit is contained in:
@@ -96,31 +96,31 @@ class PrisonerDoorDetector:
|
|||||||
return (True, roi_name)
|
return (True, roi_name)
|
||||||
return (False, "outside")
|
return (False, "outside")
|
||||||
|
|
||||||
def push_alert(self, camera_id, track_id, lost_roi, last_cxcy, timestamp):
|
# def push_alert(self, camera_id, track_id, lost_roi, last_cxcy, timestamp):
|
||||||
"""报警推送:带频率限制,携带消失ROI、最后中心点坐标"""
|
# """报警推送:带频率限制,携带消失ROI、最后中心点坐标"""
|
||||||
current_time = time.time()
|
# current_time = time.time()
|
||||||
if current_time - self.last_alert_time < ALERT_PUSH_INTERVAL:
|
# if current_time - self.last_alert_time < ALERT_PUSH_INTERVAL:
|
||||||
return False
|
# return False
|
||||||
# 构造报警信息(可根据平台要求扩展字段)
|
# # 构造报警信息(可根据平台要求扩展字段)
|
||||||
alert_info = {
|
# alert_info = {
|
||||||
"camera_id": camera_id,
|
# "camera_id": camera_id,
|
||||||
"alert_type": "prisoner_cx_disappear_in_roi",
|
# "alert_type": "prisoner_cx_disappear_in_roi",
|
||||||
"prisoner_track_id": track_id,
|
# "prisoner_track_id": track_id,
|
||||||
"disappear_roi": lost_roi,
|
# "disappear_roi": lost_roi,
|
||||||
"last_cx": round(last_cxcy[0], 2),
|
# "last_cx": round(last_cxcy[0], 2),
|
||||||
"last_cy": round(last_cxcy[1], 2),
|
# "last_cy": round(last_cxcy[1], 2),
|
||||||
"timestamp": timestamp,
|
# "timestamp": timestamp,
|
||||||
"details": f"犯人框中心点在{lost_roi}区域内消失,触发报警"
|
# "details": f"犯人框中心点在{lost_roi}区域内消失,触发报警"
|
||||||
}
|
# }
|
||||||
# 推送报警请求
|
# # 推送报警请求
|
||||||
try:
|
# try:
|
||||||
requests.post(ALERT_PUSH_URL, json=alert_info, timeout=3)
|
# requests.post(ALERT_PUSH_URL, json=alert_info, timeout=3)
|
||||||
print(f"[报警成功] {alert_info}")
|
# print(f"[报警成功] {alert_info}")
|
||||||
self.last_alert_time = current_time
|
# self.last_alert_time = current_time
|
||||||
return True
|
# return True
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
print(f"[报警失败] 原因:{str(e)}")
|
# print(f"[报警失败] 原因:{str(e)}")
|
||||||
return False
|
# return False
|
||||||
|
|
||||||
def process_frame(self, frame, camera_id: int, timestamp: float) -> dict:
|
def process_frame(self, frame, camera_id: int, timestamp: float) -> dict:
|
||||||
"""
|
"""
|
||||||
@@ -207,18 +207,18 @@ class PrisonerDoorDetector:
|
|||||||
track_info["lost_frames"] += 1 # 累计消失帧数
|
track_info["lost_frames"] += 1 # 累计消失帧数
|
||||||
# 消失帧数达到阈值,触发报警
|
# 消失帧数达到阈值,触发报警
|
||||||
if track_info["lost_frames"] >= ROI_LOST_FRAMES_THRESH:
|
if track_info["lost_frames"] >= ROI_LOST_FRAMES_THRESH:
|
||||||
self.push_alert(
|
# self.push_alert(
|
||||||
camera_id=camera_id,
|
# camera_id=camera_id,
|
||||||
track_id=track_id,
|
# track_id=track_id,
|
||||||
lost_roi=track_info["lost_roi"],
|
# lost_roi=track_info["lost_roi"],
|
||||||
last_cxcy=track_info["last_cxcy"],
|
# last_cxcy=track_info["last_cxcy"],
|
||||||
timestamp=timestamp
|
# timestamp=timestamp
|
||||||
)
|
# )
|
||||||
# 记录本帧报警信息
|
# 记录本帧报警信息
|
||||||
current_frame_alerts.append({
|
current_frame_alerts.append({
|
||||||
"time": timestamp,
|
"time": timestamp,
|
||||||
"camera_id": camera_id,
|
"camera_id": camera_id,
|
||||||
"action": "prisoner_cx_disappear_in_door",
|
"action": "Indoor Violation",
|
||||||
"prisoner_track_id": track_id,
|
"prisoner_track_id": track_id,
|
||||||
"disappear_roi": track_info["lost_roi"],
|
"disappear_roi": track_info["lost_roi"],
|
||||||
"last_cx": round(track_info["last_cxcy"][0], 2),
|
"last_cx": round(track_info["last_cxcy"][0], 2),
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ alert_types:
|
|||||||
# 监狱检测 (prison)
|
# 监狱检测 (prison)
|
||||||
"prisoner": "带出犯人"
|
"prisoner": "带出犯人"
|
||||||
"violation": "路线违规"
|
"violation": "路线违规"
|
||||||
|
"Indoor Violation": "违规进入区域"
|
||||||
|
|
||||||
|
|
||||||
# 监控室检测 (supervision_room)
|
# 监控室检测 (supervision_room)
|
||||||
"Playing Phone": "玩手机"
|
"Playing Phone": "玩手机"
|
||||||
|
|||||||
@@ -321,7 +321,8 @@
|
|||||||
'Playing Phone': '玩手机',
|
'Playing Phone': '玩手机',
|
||||||
'Unvaild Uniform!!': '违规着装',
|
'Unvaild Uniform!!': '违规着装',
|
||||||
'Unchecked Trunk': '未检查后备箱',
|
'Unchecked Trunk': '未检查后备箱',
|
||||||
'Ignore': '漏检'
|
'Ignore': '漏检',
|
||||||
|
'Indoor Violation': '违规进入区域'
|
||||||
};
|
};
|
||||||
tag.textContent = actionMap[action] || action;
|
tag.textContent = actionMap[action] || action;
|
||||||
title.appendChild(tag);
|
title.appendChild(tag);
|
||||||
|
|||||||
Reference in New Issue
Block a user