mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
cleanup the plasma store when finished with a frame
This commit is contained in:
parent
9340a74371
commit
2e8c7ec225
@ -34,7 +34,9 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
'best_objects': {},
|
||||
'object_status': defaultdict(lambda: defaultdict(lambda: 'OFF')),
|
||||
'tracked_objects': {},
|
||||
'current_frame_time': None
|
||||
'current_frame_time': None,
|
||||
'current_frame': np.zeros((720,1280,3), np.uint8),
|
||||
'object_id': None
|
||||
})
|
||||
|
||||
def get_best(self, camera, label):
|
||||
@ -64,8 +66,9 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
object_id_hash = hashlib.sha1(str.encode(f"{camera}{frame_time}"))
|
||||
object_id_bytes = object_id_hash.digest()
|
||||
object_id = plasma.ObjectID(object_id_bytes)
|
||||
current_frame = self.plasma_client.get(object_id)
|
||||
current_frame = self.plasma_client.get(object_id, timeout_ms=0)
|
||||
|
||||
if not current_frame is plasma.ObjectNotAvailable:
|
||||
# draw the bounding boxes on the frame
|
||||
for obj in tracked_objects.values():
|
||||
thickness = 2
|
||||
@ -92,6 +95,12 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
self.camera_data[camera]['current_frame'] = current_frame
|
||||
self.camera_data[camera]['current_frame_time'] = frame_time
|
||||
|
||||
# store the object id, so you can delete it at the next loop
|
||||
previous_object_id = self.camera_data[camera]['object_id']
|
||||
if not previous_object_id is None:
|
||||
self.plasma_client.delete([previous_object_id])
|
||||
self.camera_data[camera]['object_id'] = object_id
|
||||
|
||||
###
|
||||
# Maintain the highest scoring recent object and frame for each label
|
||||
###
|
||||
@ -104,10 +113,10 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
# if the object is a higher score than the current best score
|
||||
# or the current object is more than 1 minute old, use the new object
|
||||
if obj['score'] > best_objects[obj['label']]['score'] or (now - best_objects[obj['label']]['frame_time']) > 60:
|
||||
obj['frame'] = np.copy(current_frame)
|
||||
obj['frame'] = np.copy(self.camera_data[camera]['current_frame'])
|
||||
best_objects[obj['label']] = obj
|
||||
else:
|
||||
obj['frame'] = np.copy(current_frame)
|
||||
obj['frame'] = np.copy(self.camera_data[camera]['current_frame'])
|
||||
best_objects[obj['label']] = obj
|
||||
|
||||
###
|
||||
|
Loading…
Reference in New Issue
Block a user