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

@@ -61,6 +61,7 @@ class MotionDetector:
detection_labels_path: Optional[str] = None,
detection_confidence: float = 0.5,
detection_suppress_empty: bool = True,
detection_labels: Optional[str] = None,
):
self.camera_id = camera_id
self.collector_url = collector_url
@@ -82,10 +83,14 @@ class MotionDetector:
if detection_enabled and detection_model_path:
try:
from detector import ObjectDetector
label_whitelist = None
if detection_labels:
label_whitelist = set(l.strip() for l in detection_labels.split(","))
self._detector = ObjectDetector(
model_path=detection_model_path,
labels_path=detection_labels_path or "",
confidence_threshold=detection_confidence,
label_whitelist=label_whitelist,
)
logger.info(f"Object detection enabled (model: {detection_model_path})")
except ImportError as e: