Add label whitelist to filter detection types

DETECTION_LABELS env var accepts comma-separated list (e.g. "person,cat,dog").
Only matching detections are reported; others are ignored. Empty = report all.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex
2026-02-08 19:08:31 -06:00
parent b92c2064cd
commit 1bcf32889f
4 changed files with 17 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ DETECTION_MODEL_PATH = os.getenv("DETECTION_MODEL_PATH", "models/ssd_mobilenet_v
DETECTION_LABELS_PATH = os.getenv("DETECTION_LABELS_PATH", "models/coco_labels.txt")
DETECTION_CONFIDENCE = float(os.getenv("DETECTION_CONFIDENCE", "0.5"))
DETECTION_SUPPRESS_EMPTY = os.getenv("DETECTION_SUPPRESS_EMPTY", "true").lower() == "true"
DETECTION_LABELS = os.getenv("DETECTION_LABELS", "") # Comma-separated whitelist (empty = all)
if not API_KEY:
raise ValueError("API_KEY not set in .env file")
@@ -153,6 +154,7 @@ if MOTION_ENABLED:
detection_labels_path=DETECTION_LABELS_PATH,
detection_confidence=DETECTION_CONFIDENCE,
detection_suppress_empty=DETECTION_SUPPRESS_EMPTY,
detection_labels=DETECTION_LABELS if DETECTION_LABELS else None,
)
@@ -241,6 +243,7 @@ def enable_motion(api_key: str = Security(verify_api_key)):
detection_labels_path=DETECTION_LABELS_PATH,
detection_confidence=DETECTION_CONFIDENCE,
detection_suppress_empty=DETECTION_SUPPRESS_EMPTY,
detection_labels=DETECTION_LABELS if DETECTION_LABELS else None,
)
motion_detector.start(camera_manager.get_raw_frame)