The problem

Cars routinely blow past the 25 mph limit on a residential street where kids play. The highway district ran its own traffic study and concluded the issue was enforcement, not engineering, so it added no traffic calming. The police haven't responded to speeding complaints. With the official channels at a standstill, I wanted my own evidence, and not another anecdote: continuous, timestamped speed events, direction of travel, time-of-day patterns, and how often cars actually break the limit.

One complaint is an anecdote. Continuous, timestamped speed data is a pattern, and a pattern is a lot harder to dismiss.

What I built

So I built the dataset. A Raspberry Pi Zero 2 W with a NoIR camera sits in a weatherproof enclosure on a solar-powered shed about 15 feet off the street, aimed square at traffic. A Python script uses OpenCV background subtraction to pick moving vehicles out of the static scene, tracks each one's centroid across frames, and calculates speed from how far it travels against the known geometry of the shot. Every vehicle over 15 mph is logged with a timestamp, its speed, and its direction. The whole thing runs around the clock as a systemd service that restarts itself on boot.

Each event posts in real time to a FastAPI server running in Docker on my Synology NAS, where it lands in SQLite and shows up on a live dashboard. One click exports the full record to a CSV formatted to hand straight to the highway district. Total hardware cost was about $80, and the build took roughly three days.

~$80
Total hardware cost
~3 days
Design to deployed
24/7
Continuous logging

The dashboard

traffic-logger.local · live events
247
Total events
178
Over 25 mph
29.6
Avg mph
43.6
Top mph
TimeSpeedDirectionStatus
14:22:1132.4W to EOVER
14:19:4428.7E to WOVER
14:17:0327.4W to EOVER
14:14:5824.3E to Wok

Illustrative dashboard with sample figures. The live version runs on my local network and isn't public; raw event data and CSV exports are available on request.

The stack

Raspberry Pi Zero 2 W
Edge compute node. Runs the detection loop continuously and posts events over WiFi.
Pi Camera Module V2 NoIR
8MP camera with infrared capability, so it detects day and night.
OpenCV (MOG2)
Background subtraction and contour detection to isolate moving vehicles from the static scene.
Python / picamera2
Custom centroid tracking and geometry-based speed math. Runs as a systemd service on boot.
Docker on Synology NAS
Containerized FastAPI server that receives events and serves the dashboard.
SQLite + CSV export
Persistent storage with one-click export formatted for submission to the district.

What it shows about how I work

Why it's here

This project isn't really about traffic, or cameras, or hardware. It's about how I work. I find a problem that's stuck, scope the smallest system that actually solves it, and build and ship the whole thing myself. Here the problem happened to live on a residential street. Elsewhere it's an accounting close that drags, a report nobody can pull, or something I haven't run into yet. The domain and the tools change every time; the approach doesn't. Go where the work is, understand it well enough to build the right thing, and deliver something that runs. I'd rather be the person who solves the problem in front of me than the one with a single narrow specialty.

← Back to all work