Skip to content

Commit

Permalink
make timestamp on snapshots configurable (fixes #88)
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Feb 22, 2020
1 parent 1198c29 commit af24727
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ cameras:
################
# watchdog_timeout: 300

################
# Configuration for the snapshot sent over mqtt
################
snapshots:
show_timestamp: True

################
# Camera level object config. This config is merged with the global config above.
################
Expand Down
14 changes: 12 additions & 2 deletions frigate/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ def run(self):
obj['clipped'] = True

# Compute the area
# TODO: +1 right?
obj['area'] = (obj['box']['xmax']-obj['box']['xmin'])*(obj['box']['ymax']-obj['box']['ymin'])

self.camera.detected_objects[frame['frame_time']].append(obj)

# TODO: use in_process and processed counts instead to avoid lock
with self.camera.regions_in_process_lock:
if frame['frame_time'] in self.camera.regions_in_process:
self.camera.regions_in_process[frame['frame_time']] -= 1
Expand All @@ -106,6 +108,10 @@ def run(self):

# Thread that checks finished frames for clipped objects and sends back
# for processing if needed
# TODO: evaluate whether or not i really need separate threads/queues for each step
# given that only 1 thread will really be able to run at a time. you need a
# separate process to actually do things in parallel for when you are CPU bound.
# threads are good when you are waiting and could be processing while you wait
class RegionRefiner(threading.Thread):
def __init__(self, camera):
threading.Thread.__init__(self)
Expand Down Expand Up @@ -363,6 +369,9 @@ def match_and_update(self, new_objects):
# than the number of existing object centroids we need to
# register each new input centroid as a trackable object
# if D.shape[0] < D.shape[1]:
# TODO: rather than assuming these are new objects, we could
# look to see if any of the remaining boxes have a large amount
# of overlap...
for col in unusedCols:
self.register(col, group[col])

Expand Down Expand Up @@ -402,7 +411,8 @@ def run(self):
obj['box']['xmax'], obj['box']['ymax'], obj['name'], "{}% {}".format(int(obj['score']*100), obj['area']))

# print a timestamp
time_to_show = datetime.datetime.fromtimestamp(obj['frame_time']).strftime("%m/%d/%Y %H:%M:%S")
cv2.putText(best_frame, time_to_show, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, fontScale=.8, color=(255, 255, 255), thickness=2)
if self.camera.snapshot_config['show_timestamp']:
time_to_show = datetime.datetime.fromtimestamp(obj['frame_time']).strftime("%m/%d/%Y %H:%M:%S")
cv2.putText(best_frame, time_to_show, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, fontScale=.8, color=(255, 255, 255), thickness=2)

self.best_frames[name] = best_frame
3 changes: 3 additions & 0 deletions frigate/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def __init__(self, name, ffmpeg_config, global_objects_config, config, prepped_f

self.take_frame = self.config.get('take_frame', 1)
self.watchdog_timeout = self.config.get('watchdog_timeout', 300)
self.snapshot_config = {
'show_timestamp': self.config.get('snapshots', {}).get('show_timestamp', True)
}
self.regions = self.config['regions']
self.frame_shape = get_frame_shape(self.ffmpeg_input)
self.frame_size = self.frame_shape[0] * self.frame_shape[1] * self.frame_shape[2]
Expand Down

0 comments on commit af24727

Please sign in to comment.