Live mode connects the YOLOv8 detection pipeline directly to the signal decision logic, updating the green-light assignment every 2 seconds based on real vehicle counts read from the active video source. No manual slider input is needed — the camera does the counting.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Xander44-4/traffic_reducer/llms.txt
Use this file to discover all available pages before exploring further.
Activating live mode
Select a video source
Ensure a video source is active. If the dashboard shows
● INACTIVO, click EN VIVO or VIDEO LOCAL in the camera feed card header, or make a selection in the source modal. The stats polling interval will start automatically once a source is chosen.Enable the toggle or click the navbar button
Toggle the Simulación en vivo switch in the hero section to the ON position, or click the Activar Control button in the navigation bar. Both controls are synchronized — either one flips the same internal
cvModeActive flag.What happens during live mode
Once live mode is active, the frontend runs two independent polling loops:Prediction loop — every 2 000 ms
The frontend callsPOST /predict with { "live_mode": true } every 2 seconds:
0 = NORTE, 1 = SUR, 2 = ESTE, 3 = OESTE) is returned in the prediction field. The dashboard updates the intersection graphic: the winning direction’s green bulb activates, all others revert to red, and the Prioridad activa card shows the direction name.
A typical live-mode prediction response:
Stats loop — every 1 500 ms
An independent interval pollsGET /stats every 1 500 ms throughout the session (not just in live mode). It updates the sidebar counts (N, S, E, O), pedestrian count, emergency status, and the AI Decision phase label:
/stats response:
Emergency override
If the camera detects an emergency vehicle,camera.get_counts() sets emergency: true. When this reaches the dashboard through either the /predict or /stats response:
- The Prioridad activa card displays EMERGENCIA in
#b64400(amber-red). - The sidebar Emergencia field changes from
NOtoSÍin the same colour. - The manual sliders remain locked (they were already disabled in live mode).
Deactivating live mode
Toggle Simulación en vivo back to OFF, or click Desactivar Control in the navbar. The frontend:- Clears the 2 000 ms prediction interval (
clearInterval(liveInterval)). - Re-enables all four range sliders.
- Fires one immediate
POST /predictcall with the current slider values so the intersection graphic reflects manual state instantly.
/stats continues running independently — it is not tied to the live-mode toggle.
Live mode works fully with the local video source — no internet connection is required. This makes it useful for offline development and integration testing. Set
LOCAL_VIDEO_SPEED to 1.0 in app.py for real-time simulation, or a higher value such as 2.0 for accelerated scenario testing.