API reference

Robothub framework

2.6.0
package

robothub

module
module
module
module
module
module
package
package
robothub_core_wrapper
Low-level python API to interact with RobotHub Agent.  Accessible only when running as a Perception App.
module
module
variable
module

robothub.application

variable
constant
constant
constant
class
class
class
BaseSDKApplication
This class acts as the main entry point for the SDK user, managing a single device, creating pipelines, and polling the device for new data. Derived classes must implement the `setup_pipeline` method.
class

robothub.application.BaseApplication(robothub_core.RobotHubApplication, abc.ABC)

method
variable
property
method
method
method
on_stop(self)
Called when the application is stopped.
method
get_device(self) -> Optional[Union[OakCamera, depthai.Device]]: Optional[Union[OakCamera, depthai.Device]]
Get a device by its mxid. If the device is not running, this method returns None.  :return: The device or None if the device is not running.
method
restart_device(self)
Restart the device.
class

robothub.application.BaseDepthAIApplication(robothub.application.BaseApplication)

class

robothub.application.BaseSDKApplication(robothub.application.BaseApplication)

method
setup_pipeline(self, oak: OakCamera)
The entry point for the application. This method is called when a device is connected and ready to be used.  :param oak: The device that is ready to be used.
method
on_device_connected(self, oak: OakCamera)
Called when a camera is connected.  :param oak: The camera that was connected.
method
on_device_disconnected(self)
Called when a camera is disconnected. Opposite of on_device_connected.
module

robothub.events

variable
function
send_image_event(image: Union [ np.ndarray , bytes ], title: str, device_id: str = None, metadata: Optional [ dict ] = None, tags: List [ str ] = None, mjpeg_quality = 98, encode = False) -> Optional[str]: Optional[str]
Send a single image frame event to RH.  :param image: The image to send. :param title: The title of the event. :param device_id: The device ID to associate with the event. :param metadata: A dictionary of metadata to associate with the event. :param tags: A list of tags to associate with the event. :param mjpeg_quality: The JPEG quality to use when encoding. :param encode: Whether to encode the image as a JPEG before sending. :return: The event ID. None if the event failed to send.
function
send_frame_event_with_zipped_images(cv_frame: np.ndarray, files: list, title: str, device_id: str, tags: List [ str ] = None, metadata: Optional [ dict ] = None, encode: bool = False, mjpeg_quality = 98) -> Optional[str]: Optional[str]
Send a collection of images as a single event to RH.  :param cv_frame: The main image frame to send. :param files: A list of images to zip and send. :param title: The title of the event. :param device_id: The device ID to associate with the event. :param tags: A list of tags to associate with the event. :param metadata: A dictionary of metadata to associate with the event. :param encode: Whether to encode the images as JPEGs before sending. :param mjpeg_quality: The JPEG quality to use when encoding. :return: The event ID. None if the event failed to send.
function
send_video_event(video: bytes | str, title: str, metadata: Optional [ dict ] = None) -> Optional[str]: Optional[str]
Send a video event to RH. The video can be a path to a video file or a bytes object.  :param video: Path to a video file or a bytes object. :param title: Title of the video event. :param metadata: Overlay metadata to be displayed on the video. :return: The event ID. None if the event failed to send.
module

robothub.frame_buffer

variable
class
class
class

robothub.frame_buffer.PacketType(enum.Enum)

constant
constant
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.Thread
Saves 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
module

robothub.live_view

class

robothub.live_view.LiveView(abc.ABC)

method
variable
property
property
method
publish(self, h264_frame: Union [ np.array , List ])
Publishes a frame to the RobotHub Live View.  :param h264_frame: H264 frame to publish.
method
add_rectangle(self, rectangle: BoundingBox, label: str)
Adds a rectangle (bounding box) to the live view.  :param rectangle: Tuple (x1, y1, x2, y2) where (x1, y1) is the top left corner and (x2, y2) is the bottom right corner. :param label: Label to display on the rectangle.
method
add_text(self, text: str, coords: Tuple [ int , int ], size: int = None, color: Tuple [ int , int , int ] = None, thickness: int = None, outline: bool = True, background_color: Tuple [ int , int , int ] = None, background_transparency: float = 0.5)
Adds text to the live view.  :param text: Text to display. :param coords: Tuple (x, y) where (x, y) is the top left corner of the text. :param size: Size of the text. :param color: Color of the text. E.g., (255, 0, 0) for red. :param thickness: Thickness of the text. :param outline: True to display an outline around the text, False otherwise. :param background_color: Color of the background. E.g., (0, 0, 0) for black. :param background_transparency: Transparency of the background. 0.0 is fully transparent, 1.0 is fully opaque.
method
add_line(self, pt1: Tuple [ int , int ], pt2: Tuple [ int , int ], color: Tuple [ int , int , int ] = None, thickness: int = None)
Adds a line to the live view.  :param pt1: (x, y) coordinates of the start point of the line. :param pt2: (x, y) coordinates of the end point of the line. :param color: Color of the line. E.g., (255, 0, 0) for red. :param thickness: Thickness of the line.
static method
LiveView.get(unique_key: str = None, name: str = None) -> Optional[LiveView]: Optional[LiveView]
Gets a Live View by its unique key or name. Name takes precedence over unique key.  :param unique_key: Unique key of the Live View. :param name: Name of the Live View. :return: Live View with the given unique key or name. :raises ValueError: If neither name nor unique_key is specified.
static method
LiveView.get_by_name(name: str) -> Optional[LiveView]: Optional[LiveView]
Gets a Live View by its name.  :param name: Name of the Live View. :return: Live View with the given name. None if a Live View with the given name does not exist.
static method
LiveView.get_by_unique_key(unique_key: str) -> Optional[LiveView]: Optional[LiveView]
Gets a Live View by its unique key.  :param unique_key: Unique key of the Live View. :return: Live View with the given unique key. :raises ValueError: If a Live View with the given unique key does not exist.
class

robothub.live_view.DepthaiLiveView(robothub.live_view.LiveView)

class

robothub.live_view.SdkLiveView(robothub.live_view.LiveView)

method
__init__(self, name: str, unique_key: str, device_mxid: str, fps: int, frame_width: int, frame_height: int, max_buffer_size: int)
Class for creating and publishing Live Views.  :param name: Name of the Live View. :param unique_key: Live View identifier. :param device_mxid: MXID of the device that is streaming the Live View. :param frame_width: Frame width. :param frame_height: Frame height. :param max_buffer_size: Maximum number of seconds to buffer.
variable
variable
property
property
CLASS_METHOD
method
save_video_event(self, before_seconds: int, after_seconds: int, title: str)
Saves 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.
module

robothub.live_view_utils

variable
function
is_h264_frame(data)
Check if the given data (numpy array) starts with an H.264 NAL unit. This function checks for the presence of H.264 start codes and NAL types.
function
create_stream_handle(camera_serial: str, unique_key: str, name: str)
Create or get existing stream handle.  :param camera_serial: Device MXID. :param unique_key: Unique key for the stream. :param name: Name of the stream. :return: robothub_core.StreamHandle object.
package

robothub.replay

module

robothub.replay.capture_manager

class

robothub.replay.capture_manager.PathType(enum.Enum)

constant
constant
constant
class

robothub.replay.capture_manager.ReadFrameType(enum.Enum)

constant
constant
constant
constant
module

robothub.replay.replay_builder

class

robothub.replay.replay_builder.CameraType(enum.Enum)

constant
constant
class

robothub.replay.replay_builder.ReplayBuilder

method
method
method
method
method
method
method
method
method
change_mp4_video_frame_rate(self, new_fps: float)
Replay FPS is usually capped between 5 - 15 FPS depending on Replay configuration. When the source .mp4 file(s) are at much higher FPS then that, this allows to convert them to lower FPS. Videos are converted and stored at the same location as the source video.
method
method
module

robothub.replay.replay_camera

class

robothub.replay.replay_camera.StreamName

variable
variable
variable
variable
variable
variable
variable
variable
variable
method
__post_init__(self)
class

robothub.replay.replay_camera.ReplayCamera(abc.ABC)

class

robothub.replay.replay_camera.ColorReplayCamera(robothub.replay.replay_camera.ReplayCamera)

method
method
method
method
property
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
method
property
property
property