优化:车辆违停和拥堵算法防频繁告警

违停:
- confirm_clear 30→120秒(持续2分钟无车才确认离开)
- cooldown 600→1800秒(30分钟冷却)
- ALARMED 清除阈值 ratio<0.3→ratio<0.15(更严格)

拥堵:
- confirm_clear 120→180秒
- cooldown 600→1800秒
- 消散阈值从 < threshold 改为 < threshold*0.5(降到一半才开始确认)
This commit is contained in:
2026-03-19 15:19:27 +08:00
parent 8da4ef9e93
commit 648606fd0d

View File

@@ -747,8 +747,8 @@ class IllegalParkingAlgorithm:
self,
confirm_vehicle_sec: int = 15,
parking_countdown_sec: int = 300,
confirm_clear_sec: int = 30,
cooldown_sec: int = 600,
confirm_clear_sec: int = 120,
cooldown_sec: int = 1800,
target_classes: Optional[List[str]] = None,
alarm_level: Optional[int] = None,
):
@@ -905,10 +905,10 @@ class IllegalParkingAlgorithm:
logger.debug(f"ROI {roi_id}: PARKED_COUNTDOWN → IDLE (冷却期内)")
elif self.state == self.STATE_ALARMED:
if ratio < 0.3:
if ratio < 0.15:
self.state = self.STATE_CONFIRMING_CLEAR
self.state_start_time = current_time
logger.debug(f"ROI {roi_id}: ALARMED → CONFIRMING_CLEAR")
logger.debug(f"ROI {roi_id}: ALARMED → CONFIRMING_CLEAR (ratio={ratio:.2f}<0.15)")
elif self.state == self.STATE_CONFIRMING_CLEAR:
if self.state_start_time is None:
@@ -1002,8 +1002,8 @@ class VehicleCongestionAlgorithm:
self,
count_threshold: int = 5,
confirm_congestion_sec: int = 60,
confirm_clear_sec: int = 120,
cooldown_sec: int = 600,
confirm_clear_sec: int = 180,
cooldown_sec: int = 1800,
target_classes: Optional[List[str]] = None,
alarm_level: Optional[int] = None,
):
@@ -1140,10 +1140,11 @@ class VehicleCongestionAlgorithm:
logger.debug(f"ROI {roi_id}: CONFIRMING_CONGESTION → NORMAL (冷却期内)")
elif self.state == self.STATE_CONGESTED:
if avg_count < self.count_threshold:
# 车辆数降到阈值的一半以下才开始确认消散(避免抖动)
if avg_count < self.count_threshold * 0.5:
self.state = self.STATE_CONFIRMING_CLEAR
self.state_start_time = current_time
logger.debug(f"ROI {roi_id}: CONGESTED → CONFIRMING_CLEAR (avg={avg_count:.1f}<{self.count_threshold})")
logger.debug(f"ROI {roi_id}: CONGESTED → CONFIRMING_CLEAR (avg={avg_count:.1f}<{self.count_threshold * 0.5:.1f})")
elif self.state == self.STATE_CONFIRMING_CLEAR:
if self.state_start_time is None: