From 1bc8d943126eb167fdcca361639e865a10c8cef2 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Mon, 12 Sep 2022 10:54:50 -0600 Subject: [PATCH] Fix edge of frame after region adjustments --- frigate/video.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frigate/video.py b/frigate/video.py index b8ca15600..313495221 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -440,7 +440,13 @@ def intersects_any(box_a, boxes): def detect( - object_detector, frame, model_shape, region, objects_to_track, object_filters + detect_config: DetectConfig, + object_detector, + frame, + model_shape, + region, + objects_to_track, + object_filters, ): tensor_input = create_tensor_input(frame, model_shape, region) @@ -449,10 +455,10 @@ def detect( for d in region_detections: box = d[2] size = region[2] - region[0] - x_min = int((box[1] * size) + region[0]) - y_min = int((box[0] * size) + region[1]) - x_max = int((box[3] * size) + region[0]) - y_max = int((box[2] * size) + region[1]) + x_min = int(max(0, (box[1] * size) + region[0])) + y_min = int(max(0, (box[0] * size) + region[1])) + x_max = int(min(detect_config.width, (box[3] * size) + region[0])) + y_max = int(min(detect_config.height, (box[2] * size) + region[1])) width = x_max - x_min height = y_max - y_min area = width * height @@ -620,6 +626,7 @@ def process_frames( for region in regions: detections.extend( detect( + detect_config, object_detector, frame, model_shape, @@ -679,6 +686,7 @@ def process_frames( selected_objects.extend( detect( + detect_config, object_detector, frame, model_shape,