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

New Project: CoI

I’ve posted the code for a project that I’ve been thinking about for a while; CoI.

This project is, at this point, a draft or an early work in progress but I wanted to get it actually started and work on some code; something I haven’t done enough of lately.

The goal with CoI is to have a single place to record and track incident post-mortems. I’ve worked quite a few places and most had terrible post-mortem practices that left things unresolved, untracked, and unfixed and it’s driven me crazy.

If you know that something can cause a production outage because it has and you’ve identified the fix should you really accept that being thrown into a team’s backlog and just.. left there? It’s not a new and exciting feature. It’s not something that is going to move the needle for customer adoption. It’s probably just not all that interesting. That fix can go ignored by the engineering team and project managers for months and while it waits to be addressed your site is still vulnerable.

The intent with CoI is to surface those action items and clear ownership over the original incident and who needs to do the work identified to prevent it from happening again. While there are solutions that people have come up with to do this using other issue tracking systems I’ve seen those attempts fail.

In any case; the draft is up and I plan on working on it occasionally to build it into something more ready to use.

-Nathan

Project release: AWS Okta Keyman

Available today; AWS Okta Keyman. This package is a fork of previous work by Nextdoor, Inc. that adds Duo Auth support and has other features already on the roadmap.

This package allows the user, who uses Okta with AWS today, to authenticate with Okta, use that to authenticate to AWS, and then pulls down temporary credentials (access key and secret key) for interacting with the AWS APIs. This allows for users to have access to AWS APIs without long-lived API keys stored on their dev systems. This helps protect the AWS resources as the keys are only valid for at most an hour so an unintended disclosure or leak has a very short window of risk before the keys become invalid. It also helps by enforcing the idea of continually rotating keys; not so different from what the on-box EC2 experience is like when using IAM Roles for EC2.

If you are using Okta to log in to AWS give it a try today; pip install aws-okta-keyman

The source is available under the Apache 2.0 license.

For more information: https://github.com/nathan-v/aws_okta_keyman