The Traffic Reducer dashboard is a single-page application served by Flask atDocumentation 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.
http://127.0.0.1:5000. Every section updates in real time — either driven by the YOLOv8 detection pipeline in live mode or by manual range-slider input in simulation mode — with no page reload required.
UI sections
Source selection modal
Source selection modal
On first load the server starts in
idle mode and a modal dialog appears immediately, prompting you to choose a video source before any processing begins. The modal offers two options:- Stream en vivo — connects to the YouTube live traffic camera via
yt-dlp. - Video local — loops the bundled drone-view MP4 file (
traffic_dron_view.mp4).
GET /source_status, and the frontend checks has_local in the response before rendering the button state.Once a source is selected the modal closes and stats polling begins automatically.Navigation bar
Navigation bar
Camera feed card
Camera feed card
The camera feed card streams MJPEG frames from
The card header also contains EN VIVO and VIDEO LOCAL source-switcher buttons that call
GET /video_feed directly into an <img> element. The server pushes frames as a multipart/x-mixed-replace boundary stream, so the browser updates the image continuously without JavaScript polling.The feed renders zone polygon overlays and bounding boxes drawn by the YOLOv8 pipeline on each frame. Alongside the video a sidebar panel shows:| Sidebar field | Description |
|---|---|
| Decisión IA | The current phase name determined by np.argmax on the four direction counts |
| N / S / E / O counts | Per-direction vehicle totals from GET /stats, refreshed every 1 500 ms |
| Peatones | Pedestrian count detected in the current frame |
| Emergencia | SÍ (highlighted in #b64400) when an emergency vehicle is detected, otherwise NO |
POST /set_source and update the badge text (● EN VIVO / ● VIDEO LOCAL / ● INACTIVO) without reloading the stream element.Status cards
Status cards
Three summary cards are displayed below the camera feed in a horizontal grid:
- Prioridad activa — the direction name (NORTE, SUR, ESTE, or OESTE) chosen by
np.argmax, overridden byEMERGENCIA(in#b64400) if an emergency vehicle is present, or byPEATONES(in#707070) if more than 5 pedestrians are detected. - Peatones detectados — pedestrian count returned in the
traffic_datafield of the last/predictresponse. - Vehículo de emergencia — displays
SÍ(in#b64400) orNObased on thetraffic_data.emergencyfield of the last/predictresponse.
POST /predict call — either the manual slider event in simulation mode or the 2-second live-mode loop. They are not driven by the /stats poll. The sidebar counts and Decisión IA label (inside the camera feed card) are separately updated by the 1 500 ms /stats interval.Intersection visualization
Intersection visualization
The intersection graphic is an animated road diagram rendered entirely in HTML and CSS. It shows four road arms (Norte, Sur, Este, Oeste) converging at a central junction. Each arm contains:
- A cars density bar (
#cars-north,#cars-south,#cars-east,#cars-west) whose CSSopacityis set proportionally to the vehicle count — ranging from0.05(empty) to0.65(maximum load) via the formula0.05 + (value / 100) * 0.6. - A stop line marking the edge of the junction.
.active class and its red bulb loses it; all other lights remain red. The active road arm also receives the .active-road class for a CSS highlight effect.Manual controls
Manual controls
The Manual Control section contains four range sliders — Norte, Sur, Este, and Oeste — each spanning
0 to 100 vehicles with a default value of 10. A numeric readout beneath each slider shows the current value in real time.When live mode is off (the default), adjusting any slider immediately fires a POST /predict request with all four current slider values. The response updates the intersection graphic and the priority status card. When live mode is on, sliders are disabled and their values reflect the counts reported by the YOLO camera pipeline.Continue reading
Video Sources
Switch between YouTube live and local MP4, understand reconnection logic, and control playback speed.
Live Mode
Enable YOLOv8-driven signal control and understand how the 2-second prediction loop works.
Manual Mode
Use the range sliders to test signal decisions with arbitrary vehicle counts.
API Endpoints
Full reference for every Flask route —
/predict, /stats, /set_source, and more.