From a26d2217d4e60c5bce6bac59aacfe3c6859f85a5 Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Wed, 27 Mar 2019 06:45:27 -0500 Subject: [PATCH] implement min person size again --- frigate/object_detection.py | 20 ++++++++++---------- frigate/objects.py | 25 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/frigate/object_detection.py b/frigate/object_detection.py index 0b8099247..00f1360a6 100644 --- a/frigate/object_detection.py +++ b/frigate/object_detection.py @@ -61,16 +61,16 @@ def detect_objects(prepped_frame_array, prepped_frame_time, 'xmax': int((box[2] * region_box[0]) + region_box[1]), 'ymax': int((box[3] * region_box[0]) + region_box[2]) }) - else: - object_queue.put({ - 'frame_time': frame_time, - 'name': 'dummy', - 'score': 0.99, - 'xmin': int(0 + region_box[1]), - 'ymin': int(0 + region_box[2]), - 'xmax': int(10 + region_box[1]), - 'ymax': int(10 + region_box[2]) - }) + # else: + # object_queue.put({ + # 'frame_time': frame_time, + # 'name': 'dummy', + # 'score': 0.99, + # 'xmin': int(0 + region_box[1]), + # 'ymin': int(0 + region_box[2]), + # 'xmax': int(10 + region_box[1]), + # 'ymax': int(10 + region_box[2]) + # }) class PreppedQueueProcessor(threading.Thread): def __init__(self, prepped_frame_array, diff --git a/frigate/objects.py b/frigate/objects.py index 605e7254d..17a340ab0 100644 --- a/frigate/objects.py +++ b/frigate/objects.py @@ -4,16 +4,39 @@ import threading import cv2 from object_detection.utils import visualization_utils as vis_util class ObjectParser(threading.Thread): - def __init__(self, object_queue, objects_parsed, detected_objects): + def __init__(self, object_queue, objects_parsed, detected_objects, regions): threading.Thread.__init__(self) self._object_queue = object_queue self._objects_parsed = objects_parsed self._detected_objects = detected_objects + self.regions = regions def run(self): # frame_times = {} while True: obj = self._object_queue.get() + # filter out persons + # [obj['score'] for obj in detected_objects if obj['name'] == 'person'] + if obj['name'] == 'person': + person_area = (obj['xmax']-obj['xmin'])*(obj['ymax']-obj['ymin']) + # find the matching region + region = None + for r in self.regions: + if ( + obj['xmin'] >= r['x_offset'] and + obj['ymin'] >= r['y_offset'] and + obj['xmax'] <= r['x_offset']+r['size'] and + obj['ymax'] <= r['y_offset']+r['size'] + ): + region = r + break + + # if the min person area is larger than the + # detected person, don't add it to detected objects + if region and region['min_person_area'] > person_area: + continue + + # frame_time = obj['frame_time'] # if frame_time in frame_times: # if frame_times[frame_time] == 7: