From 862aa2d3f03a6ccdf1687f74e0e3ad97f1ddc243 Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Sun, 17 Mar 2019 20:12:31 -0500 Subject: [PATCH] only resize when needed --- frigate/object_detection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frigate/object_detection.py b/frigate/object_detection.py index dfc3d81b5..8791e33c1 100644 --- a/frigate/object_detection.py +++ b/frigate/object_detection.py @@ -24,8 +24,9 @@ def ReadLabelFile(file_path): # do the actual object detection def tf_detect_objects(cropped_frame, engine, labels, region_size, region_x_offset, region_y_offset, debug): - # Resize to 300x300 - cropped_frame = cv2.resize(cropped_frame, dsize=(300, 300), interpolation=cv2.INTER_LINEAR) + # Resize to 300x300 if needed + if cropped_frame.shape != (300, 300, 3): + cropped_frame = cv2.resize(cropped_frame, dsize=(300, 300), interpolation=cv2.INTER_LINEAR) # Expand dimensions since the model expects images to have shape: [1, None, None, 3] image_np_expanded = np.expand_dims(cropped_frame, axis=0)