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

New Project: CoralAPI

Available now; CoralAPI. Point it at a Google Coral Edge TPU, POST an image, get JSON back.

Coral’s little accelerators are great hardware. Real object detection on a few watts, on a Raspberry Pi or a mini PC, no GPU and no cloud bill. The software stack around them has aged badly, though. The official Python library, pycoral, is stuck on Python 3.9. The projects that put a Coral behind an API, mostly CodeProject.AI’s Coral path, are heavy and half-maintained… when they run at all.

I built CoralAPI because nothing out there was current. Getting a newer model running, a recent YOLO export for example, meant fighting the toolchain or forking someone’s stale wrapper, and in a few cases standing up the existing options was more work than writing a clean one. So I wrote the clean one.

CoralAPI is a small FastAPI service. It runs on current Python and ships a matched libedgetpu and tflite runtime, built on feranick’s community packages, that actually work together; getting that pairing right is harder than it has any right to be. There are build profiles for modern CPUs, older no-AVX2 boxes, and the Raspberry Pi. Models download on demand. What it does:

  • Classification
  • Object detection (SSD and YOLO)
  • Semantic segmentation
  • Pose estimation
  • Image embeddings
  • Raw tensor output for anything it doesn’t recognize

No CPU fallback; if there’s no Coral attached it exits at startup and tells you why. That’s on purpose. A running instance always means real acceleration.

Put a Coral behind a URL and get on with your day. MIT licensed. PRs and feedback welcome.

-Nathan