From 1823bd03050fb58ef70b42fc6130bb9f2a35a336 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Mon, 9 Aug 2021 07:46:28 -0500 Subject: [PATCH] fix scaling --- frigate/video.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frigate/video.py b/frigate/video.py index c5e6b41ce..729649a37 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -398,16 +398,17 @@ def detect( object_detector, frame, model_shape, region, objects_to_track, object_filters ): tensor_input = create_tensor_input(frame, model_shape, region) + scale = float(region[2] - region[0]) / model_shape[0] detections = [] region_detections = object_detector.detect(tensor_input) for d in region_detections: box = d[2] size = region[2] - region[0] - x_min = int((box[1]) + region[0]) - y_min = int((box[0]) + region[1]) - x_max = int((box[3]) + region[0]) - y_max = int((box[2]) + region[1]) + x_min = int(max(0, box[1]) * scale + region[0]) + y_min = int(max(0, box[0]) * scale + region[1]) + x_max = int(min(frame.shape[1], box[3]) * scale + region[0]) + y_max = int(min(frame.shape[0], box[2]) * scale + region[1]) det = ( d[0], d[1],