Frame Buffer
Deprecation Notice
This page describes features that have been removed or replaced in Luxonis Hub. Functionality may be limited and only available to Hub Original customers. Please refer to the up-to-date guides to provision devices, manage fleets, and deploy applications.
Make sure to use the
add_frame() method on every h264 frame.Python
1import depthai as dai
2import robothub as rh
3
4frame_buffer: rh.FrameBuffer = FrameBuffer(maxlen=rh.CONFIGURATION["fps"] * 60 * 2)
5
6def process_h264(h264_frame: dai.ImgFrame) -> None:
7 frame_buffer.add_frame(packet=h264_frame)
8 if important_condition() is True:
9 frame_buffer.save_video_event(before_seconds=60,
10 after_seconds=60,
11 title="Interesting video",
12 fps=rh.CONFIGURATION["fps"],
13 frame_width=1920,
14 frame_height=1080)class
robothub.frame_buffer.FrameBuffer
method
__init__(self, maxlen: int = None)A buffer for storing frames. :param maxlen: The maximum number of frames to store in the buffer. If None, the buffer will be unbounded.
method
save_video_event(self, before_seconds: int, after_seconds: int, title: str, fps: int, frame_width: int, frame_height: int, on_complete: Optional
[
Callable
] = None, delete_after_complete: bool = False) -> threading.Thread: threading.ThreadSaves a video event to the frame buffer, then calls `on_complete` when the video is ready. When the video is ready, the `on_complete` function will be called with the path to the video file. Note: When app is stopped, it is not guaranteed that the video will be saved. :param before_seconds: Number of seconds to save before the event occurred. :param after_seconds: Number of seconds to save after the event occurred. :param title: Title of the video event. :param fps: The FPS of the video. :param frame_width: Video frame width. :param frame_height: Video frame height. :param on_complete: Callback function to call when the video is ready. Path to the video file will be passed as the first argument. :param delete_after_complete: If True, delete the video file after the callback function is called. Default: False. :return: The 'threading.Thread' where the video is processed.
method
add_frame(self, packet: Union
[
FramePacket
,
dai.ImgFrame
])Default callback for the frame buffer. It will append the packet to the buffer and put it in all temporary queues.
property