implement min person size again

This commit is contained in:
blakeblackshear 2019-03-27 06:45:27 -05:00
parent 200d769003
commit a26d2217d4
2 changed files with 34 additions and 11 deletions

View File

@ -61,16 +61,16 @@ def detect_objects(prepped_frame_array, prepped_frame_time,
'xmax': int((box[2] * region_box[0]) + region_box[1]), 'xmax': int((box[2] * region_box[0]) + region_box[1]),
'ymax': int((box[3] * region_box[0]) + region_box[2]) 'ymax': int((box[3] * region_box[0]) + region_box[2])
}) })
else: # else:
object_queue.put({ # object_queue.put({
'frame_time': frame_time, # 'frame_time': frame_time,
'name': 'dummy', # 'name': 'dummy',
'score': 0.99, # 'score': 0.99,
'xmin': int(0 + region_box[1]), # 'xmin': int(0 + region_box[1]),
'ymin': int(0 + region_box[2]), # 'ymin': int(0 + region_box[2]),
'xmax': int(10 + region_box[1]), # 'xmax': int(10 + region_box[1]),
'ymax': int(10 + region_box[2]) # 'ymax': int(10 + region_box[2])
}) # })
class PreppedQueueProcessor(threading.Thread): class PreppedQueueProcessor(threading.Thread):
def __init__(self, prepped_frame_array, def __init__(self, prepped_frame_array,

View File

@ -4,16 +4,39 @@ import threading
import cv2 import cv2
from object_detection.utils import visualization_utils as vis_util from object_detection.utils import visualization_utils as vis_util
class ObjectParser(threading.Thread): 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) threading.Thread.__init__(self)
self._object_queue = object_queue self._object_queue = object_queue
self._objects_parsed = objects_parsed self._objects_parsed = objects_parsed
self._detected_objects = detected_objects self._detected_objects = detected_objects
self.regions = regions
def run(self): def run(self):
# frame_times = {} # frame_times = {}
while True: while True:
obj = self._object_queue.get() 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'] # frame_time = obj['frame_time']
# if frame_time in frame_times: # if frame_time in frame_times:
# if frame_times[frame_time] == 7: # if frame_times[frame_time] == 7: