mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
add bas64 encoded thumbnail to the database
This commit is contained in:
parent
9a7fb96357
commit
2613e74f97
@ -180,7 +180,8 @@ class EventProcessor(threading.Thread):
|
|||||||
end_time=event_data['end_time'],
|
end_time=event_data['end_time'],
|
||||||
top_score=event_data['top_score'],
|
top_score=event_data['top_score'],
|
||||||
false_positive=event_data['false_positive'],
|
false_positive=event_data['false_positive'],
|
||||||
zones=list(event_data['entered_zones'])
|
zones=list(event_data['entered_zones']),
|
||||||
|
thumbnail=event_data['thumbnail']
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(self.cached_clips) > 0 and not event_data['false_positive']:
|
if len(self.cached_clips) > 0 and not event_data['false_positive']:
|
||||||
|
@ -11,3 +11,4 @@ class Event(Model):
|
|||||||
top_score = FloatField()
|
top_score = FloatField()
|
||||||
false_positive = BooleanField()
|
false_positive = BooleanField()
|
||||||
zones = JSONField()
|
zones = JSONField()
|
||||||
|
thumbnail = TextField()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import copy
|
import copy
|
||||||
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import itertools
|
import itertools
|
||||||
@ -138,7 +139,7 @@ class TrackedObject():
|
|||||||
|
|
||||||
self.current_zones = current_zones
|
self.current_zones = current_zones
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self, include_thumbnail: bool = False):
|
||||||
return {
|
return {
|
||||||
'id': self.obj_data['id'],
|
'id': self.obj_data['id'],
|
||||||
'camera': self.camera,
|
'camera': self.camera,
|
||||||
@ -153,7 +154,8 @@ class TrackedObject():
|
|||||||
'area': self.obj_data['area'],
|
'area': self.obj_data['area'],
|
||||||
'region': self.obj_data['region'],
|
'region': self.obj_data['region'],
|
||||||
'current_zones': self.current_zones.copy(),
|
'current_zones': self.current_zones.copy(),
|
||||||
'entered_zones': list(self.entered_zones).copy()
|
'entered_zones': list(self.entered_zones).copy(),
|
||||||
|
'thumbnail': base64.b64encode(self.get_jpg_bytes()).decode('utf-8') if include_thumbnail else None
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_jpg_bytes(self):
|
def get_jpg_bytes(self):
|
||||||
@ -405,7 +407,7 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
thumbnail_file_name = f"{camera}-{obj.obj_data['id']}.jpg"
|
thumbnail_file_name = f"{camera}-{obj.obj_data['id']}.jpg"
|
||||||
with open(os.path.join(self.config.save_clips.clips_dir, thumbnail_file_name), 'wb') as f:
|
with open(os.path.join(self.config.save_clips.clips_dir, thumbnail_file_name), 'wb') as f:
|
||||||
f.write(obj.get_jpg_bytes())
|
f.write(obj.get_jpg_bytes())
|
||||||
self.event_queue.put(('end', camera, obj.to_dict()))
|
self.event_queue.put(('end', camera, obj.to_dict(include_thumbnail=True)))
|
||||||
|
|
||||||
def snapshot(camera, obj: TrackedObject):
|
def snapshot(camera, obj: TrackedObject):
|
||||||
self.client.publish(f"{self.topic_prefix}/{camera}/{obj.obj_data['label']}/snapshot", obj.get_jpg_bytes(), retain=True)
|
self.client.publish(f"{self.topic_prefix}/{camera}/{obj.obj_data['label']}/snapshot", obj.get_jpg_bytes(), retain=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user