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 21, 2026 | Patrick Gryczka

## 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, which run Meta's DETR ResNet-50 for object detection and a selectable multimodal model (Llama 3.2 Vision, LLaVA, or Gemma) for PPE headwear compliance; results are drawn back over the live video. Because it is hosted as an open, unauthenticated demo, it ships production-grade cost controls: per-session rate limits via the Workers Rate Limiting binding and a global per-UTC-day budget cap enforced 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
  • -> Three views from one pipeline: live detection, virtual-zone monitor, and PPE compliance
  • -> Selectable vision LLMs (Llama 3.2 Vision / LLaVA / Gemma) for on-demand PPE checks
  • -> Open-demo cost guardrails: per-session rate limits + a global daily budget cap (Durable Object)
  • -> Per-inference Analytics Engine usage with monthly + spike-alert email reports

## Architecture

Video Detection architecture diagram
Browser (camera capture + canvas overlay)
    │   ~1 fps compressed JPEG over HTTPS
    ▼
Cloudflare Worker (Astro SSR + custom entrypoint)
    ├── /api/detect → DETR ResNet-50 (Workers AI)
    ├── /api/ppe    → Llama Vision / LLaVA / Gemma (Workers AI)
    │       ├── per-session rate limit (Rate Limiting binding)
    │       ├── global daily cap (BudgetCounter Durable Object)
    │       └── usage data point → Analytics Engine
    └── scheduled() cron → Analytics Engine SQL → Email Service report

## Tech Stack

WorkersWorkers AIAstroDurable ObjectsAnalytics EngineRate LimitingTypeScript
$ _