mydocker/camera-llm/README.md

2.3 KiB

Camera LLM - AI Camera Memory

LLM-powered camera memory system. Captures frames from Frigate cameras, describes them with a vision model, stores embeddings in ChromaDB, and answers natural language questions about camera activity.

Architecture

[Frigate /api/<camera>/latest.jpg]
        |
        v
[camera-memory] -- moondream (frame description) --> nomic-embed-text (embedding) --> ChromaDB "camera_frames"
        |
        v
[camera-api] <-- user asks question --> ChromaDB (semantic search) --> mistral (answer) --> result

Components

camera-memory

  • Fetches the latest frame from each camera every INTERVAL seconds via Frigate API
  • Sends to moondream vision model with prompt: "Describe briefly: people (gender, clothing, action), vehicles (color, type), animals, packages, unusual activity."
  • Creates embedding via nomic-embed-text and stores in camera_frames collection
  • Every 3600 iterations, removes entries older than RETENTION_HOURS (default: 72h)

camera-api

  • FastAPI + built-in HTML frontend (dark mode, Polish language)
Endpoint Description
GET / Web interface for asking questions (Polish)
GET /ask?q=... RAG answer via ChromaDB + mistral, returns answer + sources
GET /recent?camera=&hours=1 Recent observations
GET /stats Number of stored frames
GET /health Health check

Environment Variables

Variable Default Description
FRIGATE_URL http://frigate:5000 Frigate API URL
OLLAMA_URL http://ollama:11434 Ollama URL
CHROMA_URL http://chromadb:8000 ChromaDB URL
CAMERAS front_door Comma-separated camera list
INTERVAL 1 Frame capture interval (seconds)
RETENTION_HOURS 72 Data retention in ChromaDB

Useful Commands

# Follow logs
docker compose logs -f camera-memory
docker compose logs -f camera-api

# Check how many frames are stored
curl http://localhost:<port>/stats

# Ask a question via API
curl "http://localhost:<port>/ask?q=was+there+a+red+car+today"

# Recent observations from a specific camera (last hour)
curl "http://localhost:<port>/recent?camera=reolink_1&hours=1"

# Rebuild
docker compose build camera-memory camera-api && docker compose up -d camera-memory camera-api