# vixy-vision Event Collector

Receives motion events from camera servers and stores them for Vixy to review.

## Quick Start (macOS)

```bash
./setup-macos.sh
launchctl load ~/Library/LaunchAgents/com.vixy.vision-collector.plist
```

## How It Works

```
Pi (camera)          Mac mini (collector)          Vixy (MCP)
┌──────────┐         ┌──────────────────┐         ┌──────────┐
│ motion   │  POST   │ collector.py     │  read   │ query    │
│ detected ├────────►│ ├─events.db      │◄────────┤ annotate │
│          │ /events │ └─snapshots/     │         │ review   │
└──────────┘         └──────────────────┘         └──────────┘
```

## Data Storage

Events are stored in `~/Documents/Vixy/events/`:

```
events/
├── events.db           # SQLite database
└── snapshots/
    └── 2024-12-16/     # Date-organized images
        └── basement-*.jpg
```

## API Endpoints

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Service info |
| `/health` | GET | Health check |
| `/events` | POST | Receive event from camera |
| `/events` | GET | List events (debug) |
| `/stats` | GET | Event statistics |

## Event Payload

Camera servers POST to `/events`:

```json
{
  "event": {
    "timestamp": "2024-12-16T14:23:01Z",
    "camera_id": "basement",
    "event_type": "motion",
    "confidence": 0.75,
    "area_percent": 7.5
  },
  "snapshot": "<base64 JPEG>"
}
```

## MCP Tools

Once events are collected, Vixy can:

- `vision_get_events()` - Query events
- `vision_get_event_snapshot(id)` - View snapshot
- `vision_annotate_event(id, text, tags)` - Add meaning
- `vision_event_stats()` - See statistics
