2.9 KiB
2.9 KiB
NVR Face Recognition Pipeline
Status: ✅ Working (debug mode active, 2026-06-22)
Components
| Service | Container | Port | Notes |
|---|---|---|---|
| Frigate | frigate | 5000 | v0.17.1, MQTT events |
| face-api | face-api | 5001 | Node.js face-api.js, recognition |
| face-trainer | face-trainer | 5002 | Python Flask, Telegram |
| n8n workflow | n8n | 5678 | Kr8L5Cedgd1iOQEj |
| MQTT | mosquitto | 1883 | frigate/events |
All on Docker host 192.168.170.30.
Source: /Users/post/VScode/network/nvr/
Pipeline Flow
Camera (192.168.170.96) → Frigate MQTT → n8n workflow
→ GET Frigate snapshot (crop=1)
→ POST face-api /analyze (base64 image)
→ POST face-trainer /notify {event_id, has_unknown, known_names}
→ Telegram (@BACKROOMS29Bot → chat 81571680)
face-trainer /notify Logic
if has_unknown:
# send alert with [Name/Stranger] inline keyboard buttons
send_alert(event_id, snapshot)
else:
# send photo with "✅ Name1, Name2" caption
send_known_photo(event_id, snapshot, known_names)
n8n Workflow (Kr8L5Cedgd1iOQEj)
Nodes:
- MQTT Trigger — subscribe to
frigate/events, filternewevents withpersonlabel - Filter — pass only
type=new+label=person - GET: Frigate Snapshot —
GET /api/events/{id}/snapshot.jpg?crop=1, stores binary - face-api —
POST http://192.168.170.30:5001/recognizewith base64 image - POST: face-trainer /notify — sends to face-trainer with event_id + has_unknown + known_names
Known n8n bug (v4.2): HTTP Request node raw body with object expression ={{ {...} }} sends {"":""}.
Fix: use specifyBody: "keypair" + bodyParameters array instead of raw JSON body.
API Keys
- n8n REST API:
X-N8N-API-KEY: claude-api(expires 2026-07-22, in Settings → API)
Debug Mode
All person detections sent to Telegram:
- Known face:
sendPhotowith caption✅ Name - Unknown face:
sendPhoto+ inline keyboard with [Name] / [Stranger] buttons
To train a face: press [Name] button → face-trainer saves to training set.
Camera
- IP: 192.168.170.96 (RTSP)
- MAC locked in Keenetic DHCP
- Frigate config:
/opt/frigate/config/config.ymlon Docker host
Telegram Bot
- Bot: @BACKROOMS29Bot
- Token: менеджер паролей (раздел NVR/Telegram)
- Chat ID: 81571680
Troubleshooting
Pipeline not firing:
- Check
docker logs face-trainer --tail=50for /notify errors - Check n8n executions: http://192.168.170.30:5678/workflow/Kr8L5Cedgd1iOQEj
- Verify MQTT:
mosquitto_sub -h 192.168.170.30 -t frigate/events
End-to-end test:
# trigger manually with real event_id from Frigate
EVENT_ID=$(curl -s http://192.168.170.30:5000/api/events?limit=1 | jq -r '.[0].id')
curl -s -X POST http://192.168.170.30:5002/notify \
-H "Content-Type: application/json" \
-d "{\"event_id\":\"$EVENT_ID\",\"has_unknown\":true}"