user@gryczka.dev: ~/garden/video-detection
$ cat ~/garden/video-detection/README.md
Video Detection — Real-Time Workers AI Vision screenshot

Video Detection — Real-Time Workers AI Vision

June 22, 2026 | Patrick Gryczka with Brady Joslin

## Overview

A real-time computer-vision demo on the Cloudflare Developer Platform. The browser samples device-camera frames and sends compressed JPEGs to Astro API routes on Workers. DETR ResNet-50 finds people and objects; the PPE view crops each detected person and asks editable yes/no, choice, and score questions through Clef Flash, Clef, Clairic, or legacy vision LLMs, drawing a label above every person. Three structured views, contributed by Brady Joslin, go further: Decide scores typed questions in a single Clef Flash forward pass with calibrated probabilities, Extract reads typed values with confidence intervals through Clairic, and Extract + Decide chains both — Clef Flash gates and routes, Clairic measures, and the Worker finishes with deterministic maths for recipes like Drink Check and Watch Reader. Because it is an open, unauthenticated demo, every inference route shares production-grade guardrails: signed sessions, IP and session rate limits, streamed JPEG/PNG validation with Images metadata checks before any provider call, and per-UTC-day provider-call budgets enforced atomically by a Durable Object, all switchable with a single PUBLIC_DEMO_MODE flag. Every inference is recorded in Analytics Engine, and a scheduled Worker emails monthly usage summaries plus daily spike alerts through Cloudflare Email Service.

## Highlights

  • -> Live DETR (ResNet-50) object detection drawn over the camera feed at ~1 fps
  • -> Per-person PPE checks with editable typed questions through Clef Flash, Clef, Clairic, or legacy vision LLMs
  • -> Decide: typed noul, choice, and score questions answered in one Clef Flash pass with calibrated probabilities
  • -> Extract and Extract + Decide: Clairic field extraction with p10–p90 intervals, gated and routed by Clef Flash
  • -> Open-demo guardrails: signed sessions, IP + session rate limits, bounded image validation, and per-call daily budgets (Durable Object)
  • -> Per-inference Analytics Engine usage with monthly + spike-alert email reports

## Contributors

  • -> Brady Joslin: Decide, Extract, and Extract + Decide views with Clef Flash and Clairic

## Architecture

Video Detection architecture diagram
Browser (camera capture + canvas overlay)
    │   sampled JPEG frames over HTTPS
    ▼
Cloudflare Worker (Astro SSR + custom entrypoint)
    ├── /api/detect          → DETR ResNet-50 (Workers AI)
    ├── /api/ppe             → Clef Flash / Clef / Clairic / vision LLMs per person
    ├── /api/decide          → Clef Flash typed decisions
    ├── /api/extract         → Clairic typed extraction
    ├── /api/extract-decide  → Clef Flash gate → Clairic measure → Worker maths
    │       ├── signed session + IP/session rate limits (Rate Limiting)
    │       ├── JPEG/PNG bounds + Images.info before provider work
    │       ├── per-call daily caps (BudgetCounter Durable Object)
    │       └── usage data point → Analytics Engine
    └── scheduled() cron → Analytics Engine SQL → Email Service report

## Tech Stack

WorkersWorkers AIAstroDurable ObjectsAnalytics EngineRate LimitingTypeScript
$ _