Refactor store dwell alert management API and dwell engine
- Updated argument parsing in manage_api.py to include new threshold parameters. - Enhanced _config_payload to include thresholds and webhook configurations. - Modified _build_summary to track queue metrics and adjust alert reporting. - Refactored DwellEngine to utilize queue thresholds for alerting and reporting. - Added queue metrics calculations and status change tracking in dwell_engine.py. - Updated notifier.py to support posting JSON events to webhooks. - Adjusted example configuration to reflect new threshold parameters. - Enhanced Docker entrypoint script for better process management. - Updated tests to cover new queue metrics and thresholds. - Improved ManagedServiceDetail and ManagedServices Vue components to display queue metrics.
This commit is contained in:
@@ -15,7 +15,7 @@ from app.config import (
|
||||
from app.modules.detector_tracker import YOLOTrackerAdapter
|
||||
from app.modules.dwell_engine import DwellEngine
|
||||
from app.modules.identity_resolver import IdentityResolver
|
||||
from app.modules.notifier import append_json_event
|
||||
from app.modules.notifier import dispatch_json_event
|
||||
from app.modules.staff_filter import StaffMatcher, load_staff_gallery
|
||||
from app.modules.stream_reader import RTSPFrameReader
|
||||
|
||||
@@ -46,12 +46,20 @@ def build_app(config_path: str | Path | None = None) -> dict:
|
||||
),
|
||||
"dwell_engine": DwellEngine(
|
||||
camera_id=config.camera_id,
|
||||
min_people=config.thresholds.min_people,
|
||||
min_dwell_seconds=config.thresholds.min_dwell_seconds,
|
||||
queue_time_threshold_seconds=config.thresholds.queue_time_threshold_seconds,
|
||||
crowded_count_threshold=config.thresholds.crowded_count_threshold,
|
||||
normal_count_threshold=config.thresholds.normal_count_threshold,
|
||||
pause_timeout_seconds=config.thresholds.pause_timeout_seconds,
|
||||
alert_cooldown_seconds=config.thresholds.alert_cooldown_seconds,
|
||||
),
|
||||
"notifier": append_json_event,
|
||||
"notifier": lambda path, event: dispatch_json_event(
|
||||
path,
|
||||
event,
|
||||
webhook_url=config.webhook.url
|
||||
or config.webhook.report_url
|
||||
or config.webhook.alert_url,
|
||||
timeout_seconds=config.webhook.timeout_seconds,
|
||||
),
|
||||
"event_sink_path": event_sink_path,
|
||||
}
|
||||
|
||||
@@ -102,14 +110,18 @@ def run_forever(app: dict, max_frames: int | None = None) -> int:
|
||||
def parse_args() -> ArgumentParser:
|
||||
parser = ArgumentParser(description="Store dwell alert service bootstrap")
|
||||
parser.add_argument("--config", help="Path to YAML config file")
|
||||
parser.add_argument("--once", action="store_true", help="Read and process one frame")
|
||||
parser.add_argument(
|
||||
"--once", action="store_true", help="Read and process one frame"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--manage-api",
|
||||
action="store_true",
|
||||
help="Start the management API instead of the RTSP worker loop",
|
||||
)
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Host for the management API")
|
||||
parser.add_argument("--port", type=int, default=18081, help="Port for the management API")
|
||||
parser.add_argument(
|
||||
"--port", type=int, default=18081, help="Port for the management API"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--max-frames",
|
||||
type=int,
|
||||
|
||||
Reference in New Issue
Block a user