How sridesiyan/monitor-v3 works
Purpose and Entry Points
This is a Python computer-vision analytics system for restaurant table monitoring. It derives table occupancy, dining/session state, serving events, and post-meal cleanliness from video frames, then persists and exports operational metrics. Primary execution surfaces are inference.py, analytics/pipeline.py, and deployment bootstrap deploy.py.
Pipeline Orchestration
analytics/pipeline.py is the central control boundary: it coordinates frame-level detection/tracking, table association, state updates, event logging, visualization, and reporting. Runtime behavior is configured through configs/pipeline_config.yaml, configs/app_config.yaml, and table/ROI definitions such as configs/tables.json.
Table Geometry and ROI Mapping
Tables are represented as configured regions of interest and managed independently from person tracking. analytics/roi/table_manager.py and analytics/roi/roi_config.py load/manage table geometry; analytics/roi/auto_roi.py and analytics/roi/dwell_cluster.py support deriving or refining regions from observations. Per-environment table layouts are stored under analytics/config/tables*.json.
Person Tracking and Staff/Event Recognition
The tracking layer maintains identities across frames and distinguishes relevant staff behavior. analytics/tracking/person_tracker.py provides person tracking, while analytics/tracking/session_manager.py maintains longer-lived tracking/session context. Serving-event inference is isolated in analytics/tracking/serving_detector.py and analytics/tracking/serving_detector_pose.py; appearance embedding support is represented by analytics/tracking/osnet.py and model assets in embedding/osnet_x1_0_msmt17.pth.
Occupancy, Table FSM, and Cleanliness
Table lifecycle interpretation is split into specialized domain engines. analytics/occupancy/occupancy_engine.py converts tracked people/table relationships into occupancy signals. analytics/fsm/table_fsm.py, governed by analytics/config/fsm_config.py, transitions tables through operational states. analytics/cleanliness/cleanliness_engine.py and analytics/cleanliness/plate_detector.py assess post-use cleanliness, including plate evidence.
Persistence and Outputs
Database access and event persistence are centralized in analytics/database/database_manager.py, analytics/database/db.py, and analytics/database/models.py; serving events have a dedicated writer in analytics/database/serving_event_logger.py. SQLite database artifacts include restaurant_analytics.db, serving_logs.db, and waiter_logs.db. Batch/report outputs are materialized as CSV and JSON under outputs/reports/, including outputs/reports/serving_events.csv and outputs/reports/summary.json.
Visualization and Runtime Diagnostics
Visualization is a downstream consumer of pipeline state rather than the primary control path: analytics/visualization/renderer.py and analytics/visualization/debug_visualizer.py render/debug detections, tracks, and table status. Profiling is available through analytics/profiler.py; existing validation and benchmark artifacts in outputs/baseline/ indicate the system supports offline video-analysis evaluation as well as inference runs.
Main entry points: pipeline.py Analytics pipeline · person_tracker.py Person tracker · database_manager.py Database manager · table_manager.py Table manager
Components 20
Execution
- Inference entry
inference.py - Deployment bootstrap
deploy.py - Analytics pipeline · Central runtime control boundary.
analytics/pipeline.py - Pipeline config · Controls pipeline behavior and table definitions.
configs/pipeline_config.yaml
Vision & Geometry
- Table manager
analytics/roi/table_manager.py - ROI configuration
analytics/roi/roi_config.py - ROI refinement
analytics/roi/auto_roi.py - Person tracker
analytics/tracking/person_tracker.py - Tracking sessions
analytics/tracking/session_manager.py - Serving detector
analytics/tracking/serving_detector.py
Table Intelligence
- Occupancy engine
analytics/occupancy/occupancy_engine.py - Table lifecycle FSM
analytics/fsm/table_fsm.py - Cleanliness engine
analytics/cleanliness/cleanliness_engine.py - Plate detector
analytics/cleanliness/plate_detector.py
Persistence & Outputs
- Database manager · Centralizes database and event persistence.
analytics/database/database_manager.py - Serving event logger
analytics/database/serving_event_logger.py - SQLite analytics stores · Stores restaurant, serving, and waiter records.
restaurant_analytics.db - Renderer · Renders detections, tracks, and table status.
analytics/visualization/renderer.py - Reports
outputs/reports/summary.json - Profiler
analytics/profiler.py
Connections 22
- Inference entry → Analytics pipeline: runs
- Deployment bootstrap → Analytics pipeline: bootstraps
- Pipeline config → Analytics pipeline: configures
- Analytics pipeline → Table manager: manages table ROIs
- ROI configuration → Table manager: loads geometry
- ROI refinement → Table manager: refines ROIs
- Analytics pipeline → Person tracker: processes frames
- Person tracker → Tracking sessions: updates identities
- Person tracker → Serving detector: supplies tracks
- Table manager → Occupancy engine: supplies table regions
- Person tracker → Occupancy engine: supplies people
- Occupancy engine → Table lifecycle FSM: drives state transitions
- Serving detector → Table lifecycle FSM: supplies serving events
- Plate detector → Cleanliness engine: supplies plate evidence
- Table lifecycle FSM → Cleanliness engine: triggers post-meal checks
- Analytics pipeline → Database manager: persists state and events
- Serving detector → Serving event logger: logs serving events
- Serving event logger → Database manager: writes through
- Database manager → SQLite analytics stores: stores records
- Database manager → Reports: exports metrics
- Analytics pipeline → Renderer: renders pipeline state
- Analytics pipeline → Profiler: profiles runtime