# COG — offline surveillance-art app

Runs fully offline. Face, body, hand-sign, and badge (ArUco) detection all work
with no internet — every library and model is vendored under `assets/lib/`.

## Run it

**Mac:** double-click `START-MAC.command`
**Windows:** double-click `START-WINDOWS.bat`

Either one starts a local server and opens the app in your browser. Allow the
camera when prompted. Close the terminal/console window to stop.

If double-clicking is blocked (Gatekeeper / SmartScreen), open a terminal in
this folder and run `python3 serve.py` (Mac) or `python serve.py` (Windows).

Use **Chrome or Edge** — they have the best WebGPU / WASM support.

## Put it on a flash drive

1. On your Mac, double-click `build-usb.command`. It creates a trimmed
   `COG-USB/` folder (~65 MB) with only what the app needs — it leaves out the
   1.2 GB `.venv` and the model-training files.
2. Drag `COG-USB` onto the flash drive.
3. On any computer: open the folder and double-click the launcher for that OS.

A FAT32 or exFAT drive is fine (no file is over 4 GB).

## The one requirement on the target computer: Python 3

The app must be served over `http://localhost` — browsers block the camera and
module loading from `file://`, so you can't just open `index.html` directly.
`serve.py` provides that server, and it needs **Python 3**:

- **Mac:** usually already present (the first run may prompt to install Apple's
  Command Line Tools — accept it).
- **Windows:** usually NOT preinstalled. Install from python.org and check
  *"Add python.exe to PATH"*, or install "Python 3" from the Microsoft Store.

If you need it to run on machines where you can't install Python, ask for the
standalone server build (a single ~5 MB executable per OS, no Python needed).

## Why serve.py instead of `python3 -m http.server`

`serve.py` does two things the stock server doesn't:
1. Sends correct MIME types for `.mjs` / `.wasm` (stock server mislabels them,
   which breaks MediaPipe's module import and ONNX Runtime's WASM loading).
2. Sends `Cross-Origin-Opener-Policy` + `Cross-Origin-Embedder-Policy` headers,
   which enable multi-threaded WASM — much faster model inference.

## What's vendored (all under `assets/lib/`)

- `ort/` — ONNX Runtime Web (WASM build) — runs the face + body YOLO models
- `mediapipe/` — MediaPipe tasks-vision + `hand_landmarker.task` — hand signs
- `aruco/` — js-aruco (`cv.js`, `aruco.js`) — badge markers
- `fonts/` — Share Tech Mono + Inter (Google Fonts, self-hosted)

The detection models themselves are `assets/yolov8n.onnx` (body) and
`assets/yolov8n-face.onnx` (face).
