New Project: Clockd

Available today; Clockd. It’s an HTTP API that estimates vehicle speeds from video and the source is up now on GitHub.

The motivation is a street near my home with a speeding problem. The city can act on data. Anecdotes… not so much. The data cities usually buy comes from radar studies that are expensive and run rarely, but there were already cameras with a view of the street and the speeds are sitting right there in the video.

Clockd pulls them out. Give it a clip, or let it watch your NVR and process vehicle events on its own. Event sources are modular; UniFi Protect support ships today, and adding another NVR or camera system means implementing one small polling class. It detects vehicles in each frame, tracks them across the clip, projects pixel positions onto real-world road coordinates using a per-camera calibration, and computes speed from displacement over time. Results come back as JSON, and per-vehicle metrics can go straight to InfluxDB so Grafana can draw the charts a traffic engineer will actually read.

Key features:

  • Modular NVR event sources (UniFi Protect included)
  • Per-camera perspective calibration
  • Sync and async processing
  • Multiple detection backends
  • Automatic local CPU fallback
  • InfluxDB and Prometheus metrics
  • Speed range and track quality filtering
  • Config via file or environment variables
  • Kubernetes-ready deployment

Detection runs where you want it. Local CPU inference works out of the box, and it can also call a Roboflow Inference server on a GPU, CodeProject.AI, LocalAI, or a Google Coral TPU through coralapi, which I also published this week. If a remote backend goes down, Clockd falls back to local CPU inference instead of dropping data, and every result records which backend produced it.

One lesson from running it: calibration matters more than model choice. A nano model with accurate source points beats a large model with sloppy ones; the README covers this in detail.

Clockd produces estimates and a calibrated camera is no radar gun. It doesn’t need to be. A few hundred vehicles a day with an 85th percentile of 12 over the limit is a strong argument at a council meeting.

On privacy: Clockd tracks bounding boxes. It does not read plates and it does not identify anyone. Clips are deleted after processing and what remains is anonymous speed statistics.

Under the hood it’s Python, FastAPI, Ultralytics YOLO, and ByteTrack, deployable as a container, and the repo includes a hardened Kubernetes manifest. My instance processes a few hundred clips a day from one camera and the dashboard already tells a clear story.

If you have a camera pointed at a road, give it a try; the README will get you from clip to speed report in an afternoon. If your NVR isn’t supported yet, the event source interface is small and PRs are welcome. Constructive feedback too.

-Nathan

Leave a Reply

Your email address will not be published. Required fields are marked *