|
@@ -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:
|