mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
check avg wait before dropping frames
This commit is contained in:
parent
81c5b96ed7
commit
3e6f6edf7e
@ -164,13 +164,17 @@ def track_camera(name, config, ffmpeg_global_config, global_objects_config, dete
|
|||||||
|
|
||||||
plasma_client = plasma.connect("/tmp/plasma")
|
plasma_client = plasma.connect("/tmp/plasma")
|
||||||
frame_num = 0
|
frame_num = 0
|
||||||
|
avg_wait = 0.0
|
||||||
fps_tracker = EventsPerSecond()
|
fps_tracker = EventsPerSecond()
|
||||||
skipped_fps_tracker = EventsPerSecond()
|
skipped_fps_tracker = EventsPerSecond()
|
||||||
fps_tracker.start()
|
fps_tracker.start()
|
||||||
skipped_fps_tracker.start()
|
skipped_fps_tracker.start()
|
||||||
object_detector.fps.start()
|
object_detector.fps.start()
|
||||||
while True:
|
while True:
|
||||||
|
start = datetime.datetime.now().timestamp()
|
||||||
frame_bytes = ffmpeg_process.stdout.read(frame_size)
|
frame_bytes = ffmpeg_process.stdout.read(frame_size)
|
||||||
|
duration = datetime.datetime.now().timestamp()-start
|
||||||
|
avg_wait = (avg_wait*99+duration)/100
|
||||||
|
|
||||||
if not frame_bytes:
|
if not frame_bytes:
|
||||||
break
|
break
|
||||||
@ -194,9 +198,8 @@ def track_camera(name, config, ffmpeg_global_config, global_objects_config, dete
|
|||||||
# look for motion
|
# look for motion
|
||||||
motion_boxes = motion_detector.detect(frame)
|
motion_boxes = motion_detector.detect(frame)
|
||||||
|
|
||||||
# skip object detection if we are below the min_fps
|
# skip object detection if we are below the min_fps and wait time is less than half the average
|
||||||
# TODO: its about more than just the FPS. also look at avg wait or min wait
|
if frame_num > 100 and fps.value < expected_fps-1 and duration < 0.5*avg_wait:
|
||||||
if frame_num > 100 and fps.value < expected_fps-1:
|
|
||||||
skipped_fps_tracker.update()
|
skipped_fps_tracker.update()
|
||||||
skipped_fps.value = skipped_fps_tracker.eps()
|
skipped_fps.value = skipped_fps_tracker.eps()
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user