功能:VLM提示词和告警级别支持车辆违停/拥堵算法

- vlm_service.py: 新增illegal_parking和vehicle_congestion VLM复核提示词模板
- alarm_event_service.py: 新增违停告警级别逻辑(按停留时长分级)和拥堵告警级别
- wechat_service.py: ALARM_TYPE_NAMES新增车辆违停/拥堵中文映射

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 16:54:48 +08:00
parent c2c272c298
commit ab338a509c
3 changed files with 38 additions and 1 deletions

View File

@@ -39,6 +39,17 @@ def _determine_alarm_level(alarm_type: str, confidence: float, duration_ms: Opti
elif duration_ms > 10 * 60 * 1000:
return 2 # 一般
return 1 # 提醒
elif alarm_type == "illegal_parking":
# 违停:根据停留时长判断级别
if duration_ms is None:
return 2 # 一般级别(刚触发)
if duration_ms > 60 * 60 * 1000:
return 3 # 严重超过1小时
elif duration_ms > 15 * 60 * 1000:
return 2 # 一般超过15分钟
return 1 # 提醒
elif alarm_type == "vehicle_congestion":
return 2 # 一般级别拥堵本身不分等级由持续时长在resolve时重算
elif confidence and confidence > 0.9:
return 3 # 严重
elif confidence and confidence > 0.7:

View File

@@ -17,6 +17,8 @@ from app.utils.logger import logger
ALARM_TYPE_NAMES = {
"leave_post": "离岗",
"intrusion": "周界入侵",
"illegal_parking": "车辆违停",
"vehicle_congestion": "车辆拥堵",
}
# 算法类型 → VLM Prompt 模板
@@ -38,6 +40,24 @@ description要求≤15字直接说结论。
告警成立示例:"有人员进入周界区域"
误报示例:"画面中无周界入侵情况"
仅输出JSON{{"confirmed":true,"description":"..."}}""",
"illegal_parking": """你是安防监控AI复核员。算法类型车辆违停检测监控区域{roi_name}
判断该区域是否有车辆违规停放。注意3米高度物业摄像头俯拍视角。
- confirmed=true有车辆违停告警成立
- confirmed=false无车辆违停误报如车辆正在行驶、无车辆、或属于合法停车位
description要求≤15字直接说结论注明车辆类型。
告警成立示例:"一辆轿车违停在消防通道"
误报示例:"该区域无违停车辆"
仅输出JSON{{"confirmed":true,"description":"..."}}""",
"vehicle_congestion": """你是安防监控AI复核员。算法类型车辆拥堵检测监控区域{roi_name}
判断该区域是否存在车辆拥堵。注意3米高度物业摄像头俯拍视角。
- confirmed=true存在车辆拥堵告警成立多辆车辆密集停留或缓行
- confirmed=false无拥堵误报如车辆正常通行、车辆数量少
description要求≤15字直接说结论注明大致车辆数。
告警成立示例:"约5辆车拥堵在路口"
误报示例:"车辆正常通行无拥堵"
仅输出JSON{{"confirmed":true,"description":"..."}}""",
}
# 通用降级 prompt未知算法类型时使用

View File

@@ -18,6 +18,8 @@ from app.utils.logger import logger
ALARM_TYPE_NAMES = {
"leave_post": "人员离岗",
"intrusion": "周界入侵",
"illegal_parking": "车辆违停",
"vehicle_congestion": "车辆拥堵",
}
# 告警级别映射
@@ -365,13 +367,17 @@ class WeChatService:
replace_text = action_text.get(action, "已处理")
body = {
"userids": user_ids,
"userids": user_ids if user_ids else [],
"agentid": self.agent_id_int,
"response_code": response_code,
"button": {
"replace_name": replace_text,
},
}
# 如果 user_ids 为空(如边缘自动结单),用 atall=1 更新全部接收人
if not user_ids:
body.pop("userids")
body["atall"] = 1
url = f"https://qyapi.weixin.qq.com/cgi-bin/message/update_template_card?access_token={access_token}"
async with httpx.AsyncClient(timeout=10) as client: