diff --git a/config/config.yml b/config/config.yml index a0d38c33d..87245307f 100644 --- a/config/config.yml +++ b/config/config.yml @@ -19,11 +19,14 @@ cameras: x_offset: 0 y_offset: 300 min_person_area: 5000 + threshold: 0.5 - size: 400 x_offset: 350 y_offset: 250 min_person_area: 2000 + threshold: 0.5 - size: 400 x_offset: 750 y_offset: 250 min_person_area: 2000 + threshold: 0.5 diff --git a/frigate/object_detection.py b/frigate/object_detection.py index 76050f1ec..965e1b608 100644 --- a/frigate/object_detection.py +++ b/frigate/object_detection.py @@ -38,7 +38,7 @@ class PreppedQueueProcessor(threading.Thread): frame = self.prepped_frame_queue.get() # Actual detection. - objects = self.engine.DetectWithInputTensor(frame['frame'], threshold=0.5, top_k=3) + objects = self.engine.DetectWithInputTensor(frame['frame'], threshold=frame['region_threshold'], top_k=3) # parse and pass detected objects back to the camera parsed_objects = [] for obj in objects: @@ -59,7 +59,7 @@ class PreppedQueueProcessor(threading.Thread): class FramePrepper(threading.Thread): def __init__(self, camera_name, shared_frame, frame_time, frame_ready, frame_lock, - region_size, region_x_offset, region_y_offset, + region_size, region_x_offset, region_y_offset, region_threshold, prepped_frame_queue): threading.Thread.__init__(self) @@ -71,6 +71,7 @@ class FramePrepper(threading.Thread): self.region_size = region_size self.region_x_offset = region_x_offset self.region_y_offset = region_y_offset + self.region_threshold = region_threshold self.prepped_frame_queue = prepped_frame_queue def run(self): @@ -103,6 +104,7 @@ class FramePrepper(threading.Thread): 'frame_time': frame_time, 'frame': frame_expanded.flatten().copy(), 'region_size': self.region_size, + 'region_threshold': self.region_threshold, 'region_x_offset': self.region_x_offset, 'region_y_offset': self.region_y_offset }) diff --git a/frigate/video.py b/frigate/video.py index 371e6b8c1..63e2b09bc 100644 --- a/frigate/video.py +++ b/frigate/video.py @@ -159,13 +159,19 @@ class Camera: # for each region, create a separate thread to resize the region and prep for detection self.detection_prep_threads = [] for region in self.config['regions']: + # set a default threshold of 0.5 if not defined + if not 'threshold' in region: + region['threshold'] = 0.5 + if not isinstance(region['threshold'], float): + print('Threshold is not a float. Setting to 0.5 default.') + region['threshold'] = 0.5 self.detection_prep_threads.append(FramePrepper( self.name, self.shared_frame_np, self.shared_frame_time, self.frame_ready, self.frame_lock, - region['size'], region['x_offset'], region['y_offset'], + region['size'], region['x_offset'], region['y_offset'], region['threshold'], prepped_frame_queue ))