Turn old smartphones into a traffic-counting CCTV network
A homebrew computer-vision pipeline that runs YOLO v4 + Deep SORT on multiple IP camera streams, built by someone who wanted to count people in rooms using spare phones.

What it does This repo is a Flask-based dashboard for multi-camera object detection and tracking. It ingests live video over the network via ImageZMQ, runs YOLO v4 for detection and Deep SORT for tracking, then counts objects crossing virtual lines or tallies how many are currently in frame. Two main modes: traffic counting (directional, with per-hour logs) and general object counting. The author originally built it to monitor multiple rooms using smartphones as cheap IP cameras.
The interesting bit The traffic-counting logic is more careful than a naive frame-by-frame tally. It tracks the path of each object and only increments the count when that path intersects a counting line, using the same tracking ID to avoid double-counting even if detection drops out briefly. The author also trained custom models on 244,617 images from the DETRAC dataset, though converting Darknet weights to Keras and wrangling the dataset annotations looks like it was half the battle.
Key highlights
- Multi-camera input via ImageZMQ, including emulated or smartphone streams
- Directional traffic counts with configurable angle thresholds
- Per-interval logging (total and class-based counts, intersection time/coordinate/angle)
- Optional detection overlay; low-confidence track filtering to reduce false positives
- Includes DETRAC-to-training-format conversion scripts for rolling your own vehicle models
Caveats
- The bundled Deep SORT model (
mars-small128.pb) was trained on people, not vehicles; vehicle tracking will likely underperform unless you retrain - DETRAC contains only Chinese traffic data, so the model ignores motorcycles and misclassifies some Western vehicle types (hatchbacks as SUVs, missed taxis)
- Dependencies are pinned to older versions: TensorFlow-GPU 1.14, Keras 2.3.1, Python 3.6
- Author reports ~10 FPS for two concurrent traffic streams on a GTX 1070; your mileage will vary with resolution and frame-skip settings
Verdict Worth a look if you need a quick, hackable multi-camera counting setup and don’t mind wrestling with legacy dependency stacks. Skip it if you need production-grade accuracy on diverse vehicle types or modern hardware acceleration out of the box.