Adaptive Traffic Signal Management (ATSM)

YOLOv8 + SORT — Vehicle counting, line crossing, and adaptive timing
GPLv3 CC BY-SA 4.0 Python YOLOv8

Demo

ATSM demo — YOLOv8 vehicle counting and adaptive timing

Quickstart

py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python car_counter.py
Download ZIP

How it works

  • YOLOv8 detects vehicles in the ROI.
  • SORT (Kalman + IOU) maintains stable IDs across frames.
  • Line crossing increments a unique vehicle count.
  • Red timer reduces when congestion exceeds a threshold.

Configuration and CLI

Use config.yaml for defaults and override via CLI:

# Default
python car_counter.py

# Custom config
python car_counter.py --config my_config.yaml

# Override key params
python car_counter.py --video Media/cars3.mp4 --weights Weights/yolov8l.pt \
  --line 150 360 1200 360 --threshold 15 --normal 70 --reduced 40 --cooldown 15 --conf 0.4

Detailed explanation

Detection

Ultralytics YOLOv8 runs on the masked region-of-interest to reduce false positives and compute cost.

Tracking (SORT)

Kalman filter predicts positions; IOU-based matching assigns detections to tracks with unique IDs.

Counting

When a tracked center crosses the configured line window, the ID is marked counted once per cycle.

Adaptive timing

If the unique count exceeds the threshold, the red timer reduces for the current cycle with a simple cooldown to prevent oscillation.

Tips & troubleshooting

Cite this work

Please cite the repository if you use or build upon it.

DOI: 10.5281/zenodo.16903140

@software{jambhale_atsm_2025,
  author  = {Jambhale, Anuj},
  title   = {Adaptive Traffic Signal Management (ATSM): Vehicle Counting with YOLOv8 + SORT},
  year    = {2025},
  url     = {https://github.com/jambhaleAnuj/Traffic_signal_counter_using_car_count_python},
  doi     = {10.5281/zenodo.16903140}
}