An experimental traffic-control system that watches an intersection, counts what is actually there, and adjusts signal timing instead of running a fixed cycle. Vehicle detection comes from YOLOv8, the road network is a SUMO microscopic simulation driven through TraCI, and a Streamlit dashboard shows the live state. A separate track trains a PPO reinforcement-learning agent.
Fixed-time signals cannot respond to real demand. The objective was a system that observes an intersection, estimates how much traffic is waiting, and makes signal decisions from that estimate - then presents the whole loop in a live dashboard so the behaviour is visible step by step.
The repository holds two implementations. The Pro version wires YOLO detection, the SUMO/TraCI runtime, and a Streamlit UI together. The Basic version is a focused reinforcement-learning evaluation built on a custom environment and Stable-Baselines3 PPO.
Scope note
The currently verified runtime does not rely on live quantum hardware. The repository contains Qiskit-based circuit definitions for research, but during simulation the runtime uses classical NumPy logic to compute traffic pressure. CARLA is an optional, separate experimental track and is not required for the main workflow.
System architecture
Detection, simulation, and control are separate concerns joined by a small state file so the dashboard can run as an independent process.
Component map. The Pro runtime writes a state file that the Streamlit process reads, so the simulation and the dashboard are decoupled. The RL track uses a custom Gymnasium environment rather than the live SUMO loop.
How data moves through the system
Detect vehicles
YOLOv8 Nano processes camera frames and counts cars, buses, trucks, and motorcycles, mapped onto a 3x3 zone grid to estimate lane density.
Implemented
Step the simulation
SUMO runs the microscopic traffic simulation and TraCI reads per-traffic-light queue lengths each step, producing the state the controller consumes.
Implemented
Decide the signal phase
The runtime computes a pressure score across junction queues with a NumPy softmax and sets the signal phases accordingly. The repo notes this is classical heuristic logic, not hardware quantum execution.
Implemented
Persist live state
Each step writes status to a JSON file used for inter-process communication between the simulation and the UI.
Implemented
Visualise
Streamlit reads the state file and renders live analytics plus the camera feed with detections drawn on top.
Implemented
Train an RL agent
In the Basic version, a custom Gymnasium environment (18-value observation, discrete phase actions) is used to train a PPO policy that rewards lower cumulative waiting time and higher throughput.
Research
Verified technology stack
DetectionUltralytics YOLOv8 Nano (yolov8n.pt)
SimulationEclipse SUMO 1.26.0 with the TraCI control interface
Reinforcement learningStable-Baselines3 PPO over a custom Gymnasium environment
Control mathNumPy softmax over per-junction queue lengths
Optional / experimentalCARLA (separate track, not required) and Qiskit circuit definitions (not executed at runtime)
Key technical decisions and trade-offs
A file-based state bridge
The simulation writes JSON that the dashboard reads. This keeps the two processes independent and easy to restart, but the repository notes that file communication may add latency at scale and would need an API or service layer for a city-wide deployment.
SUMO as the verified simulator
SUMO is scriptable, reproducible, and confirmed working end to end. CARLA offers richer 3D visuals but is heavier and is kept as an optional, separate experimental track rather than a dependency.
Classical heuristic in the live loop
The runtime uses a NumPy pressure calculation rather than an RL or quantum policy. That keeps the running system predictable and fast; the RL and quantum work is evaluated alongside it, not shipped into the live loop.
Portability through explicit paths
The code resolves its own directory and falls back sensibly when SUMO_HOME is unset, so the same scripts run across machines without hardcoded absolute paths.
Challenges and limitations
Webcam-only input. The CCTV workflow uses a local camera (cv2.VideoCapture(0)) rather than network video.
State-file latency. JSON file communication may introduce latency at scale.
Separate experimental track. CARLA integration is not part of the primary runtime.
No live quantum hardware. The quantum logic does not execute on quantum hardware.
Not deployed. Cloud deployment and containerization have not been implemented.
No comparative benchmark. The repository contains raw simulation artifacts (trip info, per-step status, analytics), but no documented baseline-versus-optimized comparison, so no performance improvement is claimed here.
Reproducing and exploring it
Install SUMO 1.26.0 and make sure it is on PATH or set SUMO_HOME, then install the Python packages with pip install streamlit pandas ultralytics traci opencv-python. The Pro version needs two terminals - one for the simulation, one for the dashboard:
cd 01_Pro_Version/environment
python main.py
cd 01_Pro_Version/ui
python -m streamlit run app.py
The Basic reinforcement-learning evaluation is self-contained:
cd 02_Basic_Version
pip install -r requirements.txt
python main.py
It loads the trained PPO policy and runs a short smoke test in the custom environment, printing rewards and traffic states.
Future engineering work
Future work - not implemented
Improve video input beyond the local webcam.
Replace the file-based state communication with an API or service layer.
Improve deployment portability, including containerization and cloud hosting.
Further evaluate the quantum-classical optimization research.
Related case studies
This is the most systems-heavy build here; it shares its applied-vision and simulation character with the microplastic and QBioForge projects.