NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Nms optimize for stationary cars (#9684)
Nicolas Mowen50563eef8dfd
diff --git a/frigate/const.py b/frigate/const.pyindex ebb680333d..0fb547e002 100644--- a/frigate/const.py+++ b/frigate/const.py@@ -26,6 +26,10 @@ LABEL_CONSOLIDATION_MAP = {"face": 0.5,}LABEL_CONSOLIDATION_DEFAULT = 0.9+LABEL_NMS_MAP = {+ "car": 0.6,+}+LABEL_NMS_DEFAULT = 0.4# Audio Constsdiff --git a/frigate/test/test_video.py b/frigate/test/test_video.pyindex cba63c950f..2cc5b482f7 100644--- a/frigate/test/test_video.py+++ b/frigate/test/test_video.py@@ -287,6 +287,15 @@ class TestObjectBoundingBoxes(unittest.TestCase):consolidated_detections = reduce_detections(frame_shape, detections)assert len(consolidated_detections) == len(detections)+ def test_vert_stacked_cars_not_reduced(self):+ detections = [+ ("car", 0.8, (954, 312, 1247, 475), 498512, 1.48, (800, 200, 1400, 600)),+ ("car", 0.85, (970, 380, 1273, 610), 698752, 1.56, (800, 200, 1400, 700)),+ ]+ frame_shape = (720, 1280)+ consolidated_detections = reduce_detections(frame_shape, detections)+ assert len(consolidated_detections) == len(detections)+class TestRegionGrid(unittest.TestCase):def setUp(self) -> None:diff --git a/frigate/util/object.py b/frigate/util/object.pyindex 0bf7ea1799..43ec017bbe 100644--- a/frigate/util/object.py+++ b/frigate/util/object.py@@ -10,7 +10,12 @@ import numpy as npfrom peewee import DoesNotExistfrom frigate.config import DetectConfig, ModelConfig-from frigate.const import LABEL_CONSOLIDATION_DEFAULT, LABEL_CONSOLIDATION_MAP+from frigate.const import (+ LABEL_CONSOLIDATION_DEFAULT,+ LABEL_CONSOLIDATION_MAP,+ LABEL_NMS_DEFAULT,+ LABEL_NMS_MAP,+)from frigate.detectors.detector_config import PixelFormatEnumfrom frigate.models import Event, Regions, Timelinefrom frigate.util.image import (@@ -466,6 +471,7 @@ def reduce_detections(selected_objects = []for group in detected_object_groups.values():+ label = group[0][0]# o[2] is the box of the object: xmin, ymin, xmax, ymax# apply max/min to ensure values do not exceed the known frame sizeboxes = [@@ -483,7 +489,9 @@ def reduce_detections(# due to min score requirement of NMSBoxesconfidences = [0.6 if clipped(o, frame_shape) else o[1] for o in group]- idxs = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)+ idxs = cv2.dnn.NMSBoxes(+ boxes, confidences, 0.5, LABEL_NMS_MAP.get(label, LABEL_NMS_DEFAULT)+ )# add objectsfor index in idxs: