Add motion detection to camera server
🔍 New features: - motion.py: Frame differencing motion detector - Background thread compares frames continuously - Configurable threshold, cooldown, sensitivity - POSTs events + snapshot to collector 📡 New endpoints: - GET /motion/stats - Detection statistics - POST /motion/enable - Start detection - POST /motion/disable - Stop detection ⚙️ Configuration (in .env): - MOTION_ENABLED: true/false - MOTION_THRESHOLD: Pixel diff threshold - MOTION_COOLDOWN: Seconds between events - COLLECTOR_URL: Where to POST events Next: Event collector in vixy-mcp 🦊
This commit is contained in:
66
server/README.md
Normal file
66
server/README.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# vixy-vision Server
|
||||
|
||||
Camera snapshot server with motion detection for Raspberry Pi.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
./setup.sh
|
||||
sudo systemctl start vixy-vision
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- 📷 USB camera snapshots via HTTPS API
|
||||
- 🔐 API key authentication
|
||||
- 🔍 Motion detection with frame differencing
|
||||
- 📤 Event reporting to central collector
|
||||
- 🔄 Auto-reconnect on camera failure
|
||||
|
||||
## Configuration
|
||||
|
||||
Copy `env.example` to `.env` and customize:
|
||||
|
||||
```bash
|
||||
cp env.example .env
|
||||
nano .env
|
||||
```
|
||||
|
||||
Key settings:
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------|-------------|---------|
|
||||
| `API_KEY` | Auth key for API | (required) |
|
||||
| `CAMERA_ID` | Identifier for this camera | camera |
|
||||
| `MOTION_ENABLED` | Enable motion detection | false |
|
||||
| `MOTION_THRESHOLD` | Sensitivity (lower = more) | 25 |
|
||||
| `MOTION_COOLDOWN` | Seconds between events | 5.0 |
|
||||
| `COLLECTOR_URL` | Where to POST events | (optional) |
|
||||
|
||||
## API Endpoints
|
||||
|
||||
| Endpoint | Auth | Description |
|
||||
|----------|------|-------------|
|
||||
| `GET /` | No | Service info |
|
||||
| `GET /health` | No | Health check |
|
||||
| `GET /snapshot` | Yes | JPEG snapshot |
|
||||
| `GET /motion/stats` | Yes | Detection stats |
|
||||
| `POST /motion/enable` | Yes | Start detection |
|
||||
| `POST /motion/disable` | Yes | Stop detection |
|
||||
|
||||
## Motion Events
|
||||
|
||||
When motion is detected, the server POSTs to `COLLECTOR_URL`:
|
||||
|
||||
```json
|
||||
{
|
||||
"event": {
|
||||
"timestamp": "2024-12-16T14:23:01Z",
|
||||
"camera_id": "basement",
|
||||
"event_type": "motion",
|
||||
"confidence": 0.75,
|
||||
"area_percent": 7.5
|
||||
},
|
||||
"snapshot": "<base64 JPEG>"
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user