Aller au contenu 🚨7 overdue·Hunter, Sentinel, Violet...
lab

Frigate Config Templates

Frigate Config Templates — Lab Jungle Kabal

Configurations Frigate prêtes-à-l’emploi pour AI vision sur les espèces du Lab. Templates par catégorie + scenarios Frigate-triggered Home Assistant.

Frigate full config — base file

/config/frigate.yml sur Mac Mini M2 Docker.

mqtt:
  enabled: false  # ou true si tu veux Home Assistant integration via MQTT

detectors:
  cpu1:
    type: cpu
    num_threads: 4

# Object detection model — petit pour speed sur Mac Mini M2 (pas Coral USB requis)
model:
  width: 320
  height: 320

cameras:
  phidippus:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.100:8554/cam-phidippus
          roles: [detect, record]
      hwaccel_args: -c:v h264_videotoolbox
    detect:
      width: 1280
      height: 720
      fps: 5
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 30
          mode: active_objects
    objects:
      track: [insect, spider, motion]
      filters:
        spider:
          min_score: 0.45
          threshold: 0.7
    motion:
      threshold: 25
      contour_area: 10
      mask:
        # Mask out terra exterior (decoration), keep only inside zone
        - 0,0,1280,0,1280,80,0,80
    zones:
      hunting_area:
        coordinates: 320,200,960,200,960,600,320,600
        objects: [spider, insect]
      molting_zone:
        coordinates: 480,100,800,100,800,400,480,400

  hyllus:
    # ... identique structure phidippus
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.101:8554/cam-hyllus
          roles: [detect, record]
    # ... idem detect/record/objects/motion/zones

Templates par catégorie

Spider (jumping spider — Phidippus, Hyllus)

phidippus_template:
  detect:
    width: 1280
    height: 720
    fps: 8  # high fps pour capturer les bursts de chasse
  motion:
    threshold: 22
    contour_area: 8  # détecte mouvements fins (jumping spiders petits)
  objects:
    track: [spider, insect]
    filters:
      spider:
        min_score: 0.4  # baisser threshold (jumping spider rare in COCO model)
        threshold: 0.6
        min_area: 200
  events:
    snapshots:
      enabled: true
      bounding_box: true
  zones:
    hunting_area:  # arène centrale
      coordinates: 320,200,960,200,960,600,320,600
    molt_corner:  # zone tranquille où ils muent
      coordinates: 100,500,400,500,400,720,100,720

Mantis (Metallyticus, Hymenopus)

metallyticus_template:
  detect:
    width: 1280
    height: 720
    fps: 6
  motion:
    threshold: 25
    contour_area: 15
  objects:
    track: [insect, mantis]
    filters:
      insect:
        min_score: 0.5
        min_area: 500  # mantis plus gros que jumping spider
  zones:
    hunting_perch:  # branche centrale
      coordinates: 400,150,880,150,880,500,400,500

Scorpion (Heterometrus, Liocheles)

heterometrus_template:
  detect:
    width: 1280
    height: 720
    fps: 4  # scorpions lents, pas besoin haut fps
  motion:
    threshold: 30  # scorpion bouge fort quand il bouge
    contour_area: 50
  objects:
    track: [insect]  # COCO model n'a pas scorpion natif → motion-based
    filters:
      insect:
        min_score: 0.3  # low threshold (model pas trained scorpion)
        min_area: 1000
  zones:
    burrow_entrance:  # creusement
      coordinates: 200,500,500,500,500,720,200,720
    feeding_zone:  # surface centrale
      coordinates: 400,200,880,200,880,500,400,500
  # Scorpions nocturnes — UV detection
  motion_night:
    threshold: 18  # plus sensible la nuit (UV illuminated)

Ant colony (Mystrium, Diacamma, Odontomachus)

ant_colony_template:
  detect:
    width: 1280
    height: 720
    fps: 10  # high fps pour capter trap-jaw snap (Odontomachus 230 km/h)
  motion:
    threshold: 15  # ultra-sensible (fourmis tiny)
    contour_area: 3
  objects:
    track: []  # pas tracking d'objet, juste motion zones
  zones:
    foraging_area:  # outworld
      coordinates: 200,400,1080,400,1080,720,200,720
    nest_entrance:  # entrée formicarium
      coordinates: 600,300,800,300,800,500,600,500
    feeding_dish:  # zone d'alimentation
      coordinates: 100,100,300,100,300,300,100,300

Reptile/skink (Tribolonotus)

tribolonotus_template:
  detect:
    width: 1920  # 4K possible si caméra Pi Cam Module 3 Wide
    height: 1080
    fps: 8
  motion:
    threshold: 28
    contour_area: 100
  objects:
    track: [reptile, lizard, animal]
    filters:
      animal:
        min_score: 0.4
        min_area: 800
  zones:
    bask_spot:  # heat lamp area
      coordinates: 600,100,1300,100,1300,400,600,400
    burrow_zone:  # cachette
      coordinates: 100,500,500,500,500,1080,100,1080
    water_basin:  # vasque
      coordinates: 1400,800,1900,800,1900,1080,1400,1080

Snake (Aplopeltura, Pareas)

aplopeltura_template:
  detect:
    width: 1280
    height: 1920  # vertical setup arboréal
    fps: 6
  motion:
    threshold: 20  # serpents lents mais movements fluides
    contour_area: 80
  objects:
    track: [reptile, snake]
    filters:
      snake:
        min_score: 0.4
        min_area: 600
  zones:
    branch_high:  # zone perchoir haut
      coordinates: 200,200,1000,200,1000,500,200,500
    feeding_branch:  # branche alimentation
      coordinates: 300,800,900,800,900,1100,300,1100
    water_pool:  # vasque sol
      coordinates: 100,1700,1100,1700,1100,1900,100,1900

Custom event types (Frigate → webhook)

Pour des événements spécifiques au Lab, on définit des custom labels via post-processing :

Mue detection (script Python sur Mac Mini)

# /scripts/frigate-mue-detector.py
# Run: every minute via cron, scans Frigate snapshots/clips, detects mue patterns

import requests
import os
from datetime import datetime, timedelta

FRIGATE_API = "http://localhost:5000/api"
HA_WEBHOOK = "http://homeassistant.local/api/webhook/frigate_mue"

# Heuristic: mue = static spider + new ghost spider in adjacent area within 30min
def check_mue_pattern(camera="phidippus"):
    events = requests.get(f"{FRIGATE_API}/events?camera={camera}&limit=20").json()
    static_count = sum(1 for e in events if e["end_time"] - e["start_time"] > 1800)
    if static_count >= 2 and recent_motion_burst():
        # Likely mue
        snapshot = events[0]["thumbnail"]
        requests.post(HA_WEBHOOK, json={"camera": camera, "type": "mue", "snapshot": snapshot})

def recent_motion_burst():
    # Within last 5min, detect motion >threshold
    return True  # ... implementation

Storage config

# Frigate snapshots/recordings
record:
  enabled: true
  retain:
    days: 14  # garder 2 sem rolling
    mode: motion  # only motion events, not 24/7
  events:
    retain:
      default: 60  # garder 60 jours les events détectés
      mode: active_objects

# Storage path → Mac Mini disk externe USB-C 2TB conseillé
# /lab/frigate-storage/

Disk usage estimate :

  • 2 cams × 5fps × 1280×720 × motion-only ≈ ~5GB/jour
  • 14 jours rolling ≈ ~70GB
  • Events 60 days ≈ +20GB
  • Total Frigate storage : ~100GB pour 2 cams

Si tu scales 8 cams = ~400GB. Disque externe 2TB USB-C ~3000฿ Bangkok = couvre 5 ans.

Hardware acceleration Mac Mini M2

# Use VideoToolbox (Apple Silicon hardware decode)
ffmpeg_global_args:
  - -hwaccel
  - videotoolbox
  - -c:v
  - h264_videotoolbox

Performance : 2 cams 1080p30 décodage hardware = ~5% CPU usage Mac Mini M2. Très tranquille.

Liens

💡 Edit source: docs/lab/frigate-config-templates.md · sync: npm run docs:sync
Admin lock
Click to set token