# API reference

> **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.

## Robothub framework

2.6.0

### robothub

Kind: Package

#### application

Kind: Module

##### logger

Kind: Variable

##### REPLAY_PATH

Kind: Constant

##### DEVICE_MXID: str

Kind: Constant

##### LOCAL_DEV

Kind: Constant

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

Kind: Class

###### __init__(self)

Kind: Method

###### config

Kind: Instance Variable

###### device_is_running

Kind: Property

###### on_start(self)

Kind: Method

###### start_execution(self)

Kind: Method

###### on_stop(self)

Kind: Method

Called when the application is stopped.

###### get_device(self) -> Optional[Union[OakCamera, depthai.Device]]: Optional[Union[OakCamera, depthai.Device]]

Kind: Method

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.

###### restart_device(self)

Kind: Method

Restart the device.

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

Kind: Class

###### pipeline

Kind: Instance Variable

###### setup_pipeline(self) -> depthai.Pipeline: depthai.Pipeline

Kind: Method

###### manage_device(self, device: depthai.Device)

Kind: Method

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

Kind: Class

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.

###### setup_pipeline(self, oak: OakCamera)

Kind: Method

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.

###### on_device_connected(self, oak: OakCamera)

Kind: Method

Called when a camera is connected.

:param oak: The camera that was connected.

###### on_device_disconnected(self)

Kind: Method

Called when a camera is disconnected. Opposite of on_device_connected.

#### decorators

Kind: Module

##### measure_performance(func: Callable [ ... , Any ]) -> Callable[..., Any]: Callable[..., Any]

Kind: Function

##### list_of_durations

Kind: Variable

##### maximum_duration: dict[Any, float]

Kind: Variable

##### minimum_duration: dict[Any, float]

Kind: Variable

##### last_report_at: dict[Any, float]

Kind: Variable

##### measure_average_performance(func: Callable [ ... , Any ] = None, report_every_minutes: float | int = 5) -> Callable[...,
Any]: Callable[..., Any]

Kind: Function

Report once every `report_every_minutes` minutes what the averages function duration is and what the max and min durations are.

##### robothub.decorators.FuncDetail

Kind: Class

###### report_every_seconds: int

Kind: Class Variable

###### last_call_at

Kind: Instance Variable

###### last_sum_at

Kind: Instance Variable

###### last_report_at

Kind: Instance Variable

###### call_frequency_memory: list

Kind: Class Variable

###### sub_sums: list

Kind: Class Variable

###### SUB_SUM_INTERVAL: int

Kind: Constant

###### update_and_try_report(self, start_time: float, func_name: str)

Kind: Method

##### func_detail

Kind: Variable

##### measure_call_frequency(func: Callable [ ... , Any ]) -> Callable[..., Any]: Callable[..., Any]

Kind: Function

Measure how often a given function is called.

##### with_sql_exception_handling(func: Callable [ ... , Any ]) -> Callable[..., Any]: Callable[..., Any]

Kind: Function

Try sql operation command, catch exception and finally close the cursor and the connection.

##### trace_memory(func: Callable [ ... , Any ]) -> Callable[..., Any]: Callable[..., Any]

Kind: Function

Trace RAM usage.

#### events

Kind: Module

##### logger

Kind: Variable

##### 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]

Kind: Function

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.

##### 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]

Kind: Function

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.

##### send_video_event(video: bytes | str, title: str, metadata: Optional [ dict ] = None) -> Optional[str]: Optional[str]

Kind: Function

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.

#### frame_buffer

Kind: Module

##### logger

Kind: Variable

##### robothub.frame_buffer.PacketType(enum.Enum)

Kind: Class

###### DEPTHAI: int

Kind: Constant

###### SDK: int

Kind: Constant

##### robothub.frame_buffer.FrameBuffer

Kind: Class

###### __init__(self, maxlen: int = None)

Kind: Method

A buffer for storing frames.

:param maxlen: The maximum number of frames to store in the buffer. If None, the buffer will be unbounded.

###### 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

Kind: Method

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.

###### add_frame(self, packet: Union [ FramePacket , dai.ImgFrame ])

Kind: Method

Default callback for the frame buffer. It will append the packet to the buffer and put it in all temporary queues.

###### maxlen

Kind: Property

#### live_view

Kind: Module

##### logger

Kind: Variable

##### robothub.live_view.LiveView(abc.ABC)

Kind: Class

###### __init__(self, name: str, unique_key: str, device_mxid)

Kind: Method

###### codec_r

Kind: Instance Variable

###### frame_width

Kind: Property

###### frame_height

Kind: Property

###### publish(self, h264_frame: Union [ np.array , List ])

Kind: Method

Publishes a frame to the RobotHub Live View.

:param h264_frame: H264 frame to publish.

###### add_rectangle(self, rectangle: BoundingBox, label: str)

Kind: Method

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.

###### 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)

Kind: Method

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.

###### add_line(self, pt1: Tuple [ int , int ], pt2: Tuple [ int , int ], color: Tuple [ int , int , int ] = None, thickness: int
= None)

Kind: Method

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.

###### get(unique_key: str = None, name: str = None) -> Optional[LiveView]: Optional[LiveView]

Kind: Static Method

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.

###### get_by_name(name: str) -> Optional[LiveView]: Optional[LiveView]

Kind: Static Method

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.

###### get_by_unique_key(unique_key: str) -> Optional[LiveView]: Optional[LiveView]

Kind: Static Method

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.

##### LIVE_VIEWS: Dict[str, LiveView]

Kind: Constant

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

Kind: Class

###### __init__(self, name: str, unique_key: str, width: int, height: int, device_mxid: str = 'My Device')

Kind: Method

###### frame_width

Kind: Property

###### frame_height

Kind: Property

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

Kind: Class

###### __init__(self, name: str, unique_key: str, device_mxid: str, fps: int, frame_width: int, frame_height: int,
max_buffer_size: int)

Kind: Method

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.

###### fps

Kind: Instance Variable

###### frame_buffer

Kind: Instance Variable

###### frame_width

Kind: Property

###### frame_height

Kind: Property

###### create_instance

Kind: Class Method

###### save_video_event(self, before_seconds: int, after_seconds: int, title: str)

Kind: Method

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.

#### live_view_utils

Kind: Module

##### logger

Kind: Variable

##### is_h264_frame(data)

Kind: Function

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.

##### create_stream_handle(camera_serial: str, unique_key: str, name: str)

Kind: Function

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.

#### replay

Kind: Package

##### capture_manager

Kind: Module

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

Kind: Class

###### VIDEO

Kind: Constant

###### IMAGE_DIRECTORY

Kind: Constant

###### IMAGE

Kind: Constant

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

Kind: Class

###### NORMAL

Kind: Constant

###### NEXT

Kind: Constant

###### PREV

Kind: Constant

###### JUMP

Kind: Constant

###### VideoSuffixes: list[str]

Kind: Variable

###### ImageSuffixes: list[str]

Kind: Variable

###### robothub.replay.capture_manager.CaptureManager

Kind: Class

###### __init__(self, src: List [ str ], run_in_loop = True, start: Optional [ int ] = None, end: Optional [ int ] = None)

Kind: Method

###### set_start(self, value: int)

Kind: Method

###### set_end(self, value: int)

Kind: Method

###### get_capture(self) -> Capture: Capture

Kind: Method

###### next_frame(self)

Kind: Method

###### prev_frame(self)

Kind: Method

###### jump_to_frame(self, index)

Kind: Method

###### toggle_pause(self)

Kind: Method

###### get_next_frame(self) -> Optional[np.ndarray]: Optional[np.ndarray]

Kind: Method

###### close(self)

Kind: Method

##### captures

Kind: Module

###### robothub.replay.captures.Capture(abc.ABC)

Kind: Class

###### read(self, index: Optional [ int ] = None) -> Tuple[bool, Optional[np.ndarray]]: Tuple[bool, Optional[np.ndarray]]

Kind: Method

###### reset(self, seek: Optional [ int ])

Kind: Method

###### is_opened(self) -> bool: bool

Kind: Method

###### close(self)

Kind: Method

###### length(self) -> int: int

Kind: Method

###### robothub.replay.captures.ImageDirectoryCapture(robothub.replay.captures.Capture)

Kind: Class

Used for sending images from directory to the replay node instead of a video.

###### __init__(self, path: pathlib.Path)

Kind: Method

###### image_files

Kind: Instance Variable

###### current_frame

Kind: Instance Variable

###### read(self, index: int | None = None) -> Tuple[bool, Optional[np.ndarray]]: Tuple[bool, Optional[np.ndarray]]

Kind: Method

###### reset(self, seek: Optional [ int ] = None)

Kind: Method

###### is_opened(self) -> bool: bool

Kind: Method

###### close(self)

Kind: Method

###### length(self) -> int: int

Kind: Method

###### robothub.replay.captures.VideoCapture(robothub.replay.captures.Capture)

Kind: Class

###### __init__(self, path: pathlib.Path)

Kind: Method

###### capture

Kind: Instance Variable

###### read(self, index: int | None = None) -> Tuple[bool, Optional[np.ndarray]]: Tuple[bool, Optional[np.ndarray]]

Kind: Method

###### reset(self, seek: Optional [ int ] = None)

Kind: Method

###### is_opened(self) -> bool: bool

Kind: Method

###### close(self)

Kind: Method

###### length(self) -> int: int

Kind: Method

##### replay_builder

Kind: Module

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

Kind: Class

###### COLOR

Kind: Constant

###### MONO

Kind: Constant

###### robothub.replay.replay_builder.ReplayBuilder

Kind: Class

###### __init__(self, pipeline: dai.Pipeline, fps: float = 5)

Kind: Method

###### frames_range(self, start: Optional [ int ] = None, end: Optional [ int ] = None)

Kind: Method

###### files(self, src: str)

Kind: Method

###### recursive_files(self, src: str)

Kind: Method

###### hidden_files(self, src: str)

Kind: Method

###### youtube_video(self, tmp_dir = None)

Kind: Method

###### sort_files(self)

Kind: Method

###### log_info(self)

Kind: Method

###### change_mp4_video_frame_rate(self, new_fps: float)

Kind: Method

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.

###### build_color_camera(self) -> ColorReplayCamera: ColorReplayCamera

Kind: Method

###### build_mono_camera(self) -> MonoReplayCamera: MonoReplayCamera

Kind: Method

##### replay_camera

Kind: Module

###### robothub.replay.replay_camera.StreamName

Kind: Class

###### suffix: str

Kind: Class Variable

###### INPUT_CONTROL

Kind: Instance Variable

###### INPUT_CONFIG

Kind: Instance Variable

###### GRAY

Kind: Instance Variable

###### RAW

Kind: Instance Variable

###### ISP

Kind: Instance Variable

###### VIDEO

Kind: Instance Variable

###### STILL

Kind: Instance Variable

###### PREVIEW

Kind: Instance Variable

###### __post_init__(self)

Kind: Method

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

Kind: Class

###### replay_camera_instances: list[ReplayCamera]

Kind: Class Variable

###### start_polling(self, device: dai.Device)

Kind: Method

###### stop_polling(self)

Kind: Method

###### replay_is_running

Kind: Property

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

Kind: Class

###### __init__(self, pipeline: dai.Pipeline, fps: float, src: str | List [ str ], run_in_loop: bool = True, start: Optional [ int
] = None, end: Optional [ int ] = None)

Kind: Method

###### get_capture_manager(self) -> CaptureManager: CaptureManager

Kind: Method

###### start_polling(self, device: dai.Device)

Kind: Method

###### stop_polling(self)

Kind: Method

###### replay_is_running

Kind: Property

###### getBoardSocket(self) -> dai.CameraBoardSocket|None: dai.CameraBoardSocket|None

Kind: Method

###### getCamId(self) -> int: int

Kind: Method

###### getCamera(self) -> str: str

Kind: Method

###### getColorOrder(self) -> dai.ColorCameraProperties.ColorOrder: dai.ColorCameraProperties.ColorOrder

Kind: Method

###### getFp16(self) -> bool: bool

Kind: Method

###### getFps(self) -> float: float

Kind: Method

###### getFrameEventFilter(self) -> List[dai.FrameEvent]: List[dai.FrameEvent]

Kind: Method

###### getImageOrientation(self) -> dai.CameraImageOrientation: dai.CameraImageOrientation

Kind: Method

###### getInterleaved(self) -> bool: bool

Kind: Method

###### getIspHeight(self) -> int: int

Kind: Method

###### getIspSize(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

###### getIspWidth(self) -> int: int

Kind: Method

###### getPreviewHeight(self) -> int: int

Kind: Method

###### getPreviewKeepAspectRatio(self) -> bool: bool

Kind: Method

###### getPreviewNumFramesPool(self) -> int: int

Kind: Method

###### getPreviewSize(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

###### getPreviewWidth(self) -> int: int

Kind: Method

###### getRawNumFramesPool(self) -> int: int

Kind: Method

###### getResolution(self) -> dai.ColorCameraProperties.SensorResolution: dai.ColorCameraProperties.SensorResolution

Kind: Method

###### getResolutionHeight(self) -> int: int

Kind: Method

###### getResolutionSize(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

###### getResolutionWidth(self) -> int: int

Kind: Method

###### getSensorCrop(self) -> Tuple[float, float]: Tuple[float, float]

Kind: Method

###### getSensorCropX(self) -> float: float

Kind: Method

###### getSensorCropY(self) -> float: float

Kind: Method

###### getStillHeight(self) -> int: int

Kind: Method

###### getStillNumFramesPool(self) -> int: int

Kind: Method

###### getStillSize(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

###### getStillWidth(self) -> int: int

Kind: Method

###### getVideoHeight(self) -> int: int

Kind: Method

###### getVideoNumFramesPool(self) -> int: int

Kind: Method

###### getVideoSize(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

###### getVideoWidth(self) -> int: int

Kind: Method

###### getWaitForConfigInput(self) -> bool: bool

Kind: Method

###### sensorCenterCrop(self)

Kind: Method

###### setBoardSocket(self, boardSocket: dai.CameraBoardSocket)

Kind: Method

###### setCamId(self, arg0: int)

Kind: Method

###### setCamera(self, name: str)

Kind: Method

###### setColorOrder(self, colorOrder: dai.ColorCameraProperties.ColorOrder)

Kind: Method

###### setFp16(self, fp16: bool)

Kind: Method

###### setFps(self, fps: float)

Kind: Method

###### setFrameEventFilter(self, events: List [ dai.FrameEvent ])

Kind: Method

###### setImageOrientation(self, imageOrientation: dai.CameraImageOrientation)

Kind: Method

###### setInterleaved(self, interleaved: bool)

Kind: Method

###### setIsp3aFps(self, arg0: int)

Kind: Method

###### setIspNumFramesPool(self, arg0: int)

Kind: Method

###### setIspScale(self, numerator: int, denominator: int)

Kind: Method

###### setNumFramesPool(self, raw: int, isp: int, preview: int, video: int, still: int)

Kind: Method

###### setPreviewKeepAspectRatio(self, keep: bool)

Kind: Method

###### setPreviewNumFramesPool(self, arg0: int)

Kind: Method

###### setPreviewSize(self, width: int, height: int)

Kind: Method

###### setRawNumFramesPool(self, arg0: int)

Kind: Method

###### setRawOutputPacked(self, packed: bool)

Kind: Method

###### setResolution(self, resolution: dai.ColorCameraProperties.SensorResolution)

Kind: Method

###### setSensorCrop(self, x: float, y: float)

Kind: Method

###### setStillNumFramesPool(self, arg0: int)

Kind: Method

###### setStillSize(self, width: int, height: int)

Kind: Method

###### setVideoNumFramesPool(self, arg0: int)

Kind: Method

###### setVideoSize(self, width: int, height: int)

Kind: Method

###### setWaitForConfigInput(self, wait: bool)

Kind: Method

###### frameEvent

Kind: Property

###### initialControl

Kind: Property

###### inputConfig

Kind: Property

###### inputControl

Kind: Property

###### isp

Kind: Property

###### preview

Kind: Property

###### raw

Kind: Property

###### still

Kind: Property

###### video

Kind: Property

###### robothub.replay.replay_camera.MonoReplayCamera(robothub.replay.replay_camera.ReplayCamera)

Kind: Class

###### __init__(self, pipeline: dai.Pipeline, fps: float, src: str | List [ str ], run_in_loop: bool = True, start: Optional [ int
] = None, end: Optional [ int ] = None)

Kind: Method

###### start_polling(self, device: dai.Device)

Kind: Method

###### stop_polling(self)

Kind: Method

###### replay_is_running

Kind: Property

###### getBoardSocket(self) -> dai.CameraBoardSocket|None: dai.CameraBoardSocket|None

Kind: Method

###### getCamId(self) -> int: int

Kind: Method

###### getCamera(self) -> str: str

Kind: Method

###### getFps(self) -> float: float

Kind: Method

###### getFrameEventFilter(self) -> List[dai.FrameEvent]: List[dai.FrameEvent]

Kind: Method

###### getImageOrientation(self) -> dai.CameraImageOrientation: dai.CameraImageOrientation

Kind: Method

###### getNumFramesPool(self) -> int: int

Kind: Method

###### getRawNumFramesPool(self) -> int: int

Kind: Method

###### getResolution(self) -> dai.MonoCameraProperties.SensorResolution: dai.MonoCameraProperties.SensorResolution

Kind: Method

###### getResolutionHeight(self) -> int: int

Kind: Method

###### getResolutionSize(self) -> Tuple[int, int]: Tuple[int, int]

Kind: Method

###### getResolutionWidth(self) -> int: int

Kind: Method

###### setBoardSocket(self, boardSocket: dai.CameraBoardSocket)

Kind: Method

###### setCamId(self, arg0: int)

Kind: Method

###### setCamera(self, name: str)

Kind: Method

###### setFps(self, fps: float)

Kind: Method

###### setFrameEventFilter(self, events: List [ dai.FrameEvent ])

Kind: Method

###### setImageOrientation(self, imageOrientation: dai.CameraImageOrientation)

Kind: Method

###### setIsp3aFps(self, arg0: int)

Kind: Method

###### setNumFramesPool(self, arg0: int)

Kind: Method

###### setRawNumFramesPool(self, arg0: int)

Kind: Method

###### setRawOutputPacked(self, packed: bool)

Kind: Method

###### setResolution(self, resolution: dai.MonoCameraProperties.SensorResolution)

Kind: Method

###### frameEvent

Kind: Property

###### initialControl

Kind: Property

###### inputControl

Kind: Property

###### out

Kind: Property

###### raw

Kind: Property

##### utils

Kind: Module

###### BGR2YUV_NV12(src)

Kind: Function

###### to_planar(arr: np.ndarray, shape: tuple) -> np.ndarray: np.ndarray

Kind: Function

###### create_img_frame(data: np.ndarray, width: int, height: int, type: dai.RawImgFrame.Type, sequence_number: int, timestamp:
timedelta, camera_socket: dai.CameraBoardSocket | None = None)

Kind: Function

#### robothub_core_wrapper

Kind: Package

Low-level python API to interact with RobotHub Agent.

Accessible only when running as a Perception App.

##### app

Kind: Module

Contains the base class for your application.

###### robothub.robothub_core_wrapper.app.RobotHubApplication(abc.ABC)

Kind: Class

Base class for your RobotHub App.

###### __init__(self)

Kind: Method

Constructor

###### stop_event

Kind: Instance Variable

Deprecated, will be removed. Use C{app_is_running} or C{wait} functions instead.

###### warn_timeout

Kind: Instance Variable

###### kill_timeout

Kind: Instance Variable

###### running

Kind: Property

Deprecated, will be removed. Use C{app_is_running} instead.

Set to C{True} at startup. Is set to C{False} when either App is stopped by Agent or it excepts.

@return: True if App is running, False otherwise.

###### wait(self, time: float | int | None = None)

Kind: Method

Deprecated, will be removed. Use C{wait} instead.

Invoking this function will sleep current thread for B{time} seconds.

If C{self.running -> False}, returns immediately. If App is stopped midway through C{self.wait}, likewise returns immediately.

Should be preferred over C{time.sleep} in all use cases, as C{time.sleep} will not be interrupted if App is stopped, often causing
unexpected behaviour.

@param time: Time to sleep for, given in seconds. Negative values are interpreted as 0.
@type time: float | int

###### on_start(self)

Kind: Method

Entrypoint of the App. Must be defined by the user.

###### start_execution(self)

Kind: Method

Optional method, is executed after L{on_start()} returns.

Can be used as a second entrypoint to the App.

###### on_stop(self)

Kind: Method

Method for cleanup of threads/processes, is called when:
- App is stopped by Agent (e.g. due to a request to Stop from the Cloud)
- App stops on its own - for example by calling C{exit()}
- App throws an uncaught exception

Should be used to quickly and gracefully stop all execution. Not defining this method properly, such as not joining all threads
that were started in C{self.on_start()} often results in undefined behaviour.
Not called when C{os._exit()} is called.

###### on_event_uploaded(self, event: UploadedEvent)

Kind: Method

Optional. Is called when an Event is uploaded to cloud. UploadedEvent argument contains information about the uploaded Event.

Is not called if Event is rejected by Agent

@param event: Object containing information about the uploaded event.
@type event: L{UploadedEvent}

###### on_configuration_changed(self, configuration_changes: dict)

Kind: Method

Is called when the Agent receives a new configuration. New configuration is loaded into the CONFIGURATION variable.
A dictionary containing configuration changes [:param: configuration_changes] is provided so that user can decide proper behavior
when this
method is overriden.
Default behavior is app restart. Override this method if you want to change the behavior.

@param configuration_changes: Dictionary containing configuration changes.
@type configuration_changes: dict

###### on_assigned_devices_changed(self)

Kind: Method

Is called when Devices assigned to the app have changed.

###### stop(self)

Kind: Method

Stops the App.

###### restart(self)

Kind: Method

Restarts the App. This blocks execution until Agent stops the App. App is then started.

###### restart_host(self)

Kind: Method

Requests the Agent to restart Host. Blocks execution until request is resolved.

###### shutdown_host(self)

Kind: Method

Requests the Agent to shutdown Host. Blocks execution until request is resolved.

###### run(self)

Kind: Method

Launch script uses this method to start the App.

##### client

Kind: Module

Mediates communication between App and Agent. Contains mainly internal methods.

###### robothub.robothub_core_wrapper.client.AgentClient

Kind: Class

Internally used to communicate with agent, send / receive messages over (FIFO) / STDIN (JSON serialized objects)

###### __init__(self)

Kind: Method

###### classify_event(self, event_id: str, classification: str, blocking: bool = False)

Kind: Method

Sends a classification for an Event with id equal to {event_id}.

###### publish_device_info(self, device_info: dict)

Kind: Method

Publishes device info. C{device_info} needs to be a properly formatted dictionary.

@param device_info: Dictionary containing device info
@type device_info: dict

###### publish_device_stats(self, device_stats: dict)

Kind: Method

Publishes device stats. C{device_stats} needs to be a properly formatted dictionary.

@param device_stats: Dictionary containing device stats
@type device_stats: dict

###### AGENT

Kind: Constant

##### communicator

Kind: Module

Handles communication with App's frontend server

###### robothub.robothub_core_wrapper.communicator.CommunicatorResponse

Kind: Class

Responses to requests from App are instances of this class

###### sessionId: str|None

Kind: Class Variable

ID of specific session, can be None

###### payload: Any

Kind: Class Variable

Response payload, structure defined by user

###### robothub.robothub_core_wrapper.communicator.Communicator(abc.ABC)

Kind: Class

Handles communication with App's frontend server

###### __init__(self)

Kind: Method

###### notify(self, key: str, payload: str | list | dict | None, target: str | None = None)

Kind: Method

Sends a notification to the FE server.

@param key: Used to define different types of notifications
@type key: str
@param payload: Content of the notification
@type payload: str | list | dict | None
@param target: If target is a valid session ID, notification is sent to the specific session. If None, notification is broadcast.
@type target: str | None

###### request(self, key: str, payload: str | list | dict | None, target: str | None = None, timeoutSeconds: float | int = 30) ->
CommunicatorResponse|bool: CommunicatorResponse|bool

Kind: Method

Sends a request to the FE server and blocks until a response is received or until timeout.

@param key: Used to define different types of requests
@type key: str
@param payload: Content of the request
@type payload: str | list | dict | None
@param target: If target is a valid session ID, request is sent to the specific session. If None, request is broadcast.
@type target: str | None
@param timeoutSeconds: Timeout length in seconds.
@type timeoutSeconds: float | int

###### requestAsync(self, key: str, payload: Any, target: str | None = None, timeoutSeconds = 30, on_response: Callable [ [ Any ]
, None ] | None = None)

Kind: Method

Sends an asynchronous request to the FE server, calls a callback on the response if a response is received before timeout.

@param key: Used to define different types of requests
@type key: str
@param payload: Content of the request
@type payload: str | list | dict | None
@param target: If target is a valid session ID, request is sent to the specific session. If None, request is broadcast.
@type target: str | None
@param timeoutSeconds: Timeout length in seconds.
@type timeoutSeconds: float | int
@param on_response: Callback to be invoked on the response.
@type on_response: Callable[[Any], None]

###### on_frontend(self, session_start: Callable | None = None, session_end: Callable | None = None, notification: Callable | None
= None, request: Callable | None = None)

Kind: Method

Sets callbacks for session start & end, notifications and requests from the FE server.

@param session_start: Callback for "session started" messages from FE
@type session_start: Callable
@param session_end: Callback for "session ended" messages from FE
@type session_end: Callable
@param notification: Callback for notifications from FE
@type notification: Callable
@param request: Callback for requests from FE
@type request: Callable

###### set_devices_changed_cb(self, devices_changed_cb: Callable)

Kind: Method

Sets the device change callback.

This function will be called each time configuration of any assigned device changes.
@param devices_changed_cb: Callback for requests from FE
@type devices_changed_cb: Callable

###### COMMUNICATOR

Kind: Constant

Instance of Communicator class initialized at startup.

##### device

Kind: Module

Defines base classes for handling of devices and their states.

###### robothub.robothub_core_wrapper.device.RobotHubDevice(abc.ABC)

Kind: Class

RobotHub device base class.

###### type: str

Kind: Class Variable

String denoting type of the device, allowed values: ["oak"]

###### oak: Dict[str, Any]

Kind: Class Variable

Dictionary containing various information about the device

###### robothub.robothub_core_wrapper.device.DeviceState(enum.Enum)

Kind: Class

Possible states of a device connected to the Agent.

###### CONNECTED: str

Kind: Constant

Agent is actively communicating with the device. In the case of DepthAI devices, this means a pipeline is running on the device.

###### DISCONNECTED: str

Kind: Constant

Agent is not actively communicating with the device. Either device is disconnected or no App is running on it.

###### CONNECTING: str

Kind: Constant

Agent is connecting to the device. Occurs when an App is initializing on the device, but full communication is not yet going on.

###### UNKNOWN: str

Kind: Constant

Agent is trying to obtain info about device state. Occurs when Agent is starting up.

##### events

Kind: Module

Defines methods for sending Events to the cloud.

###### robothub.robothub_core_wrapper.events.Events

Kind: Class

Used to prepare Events for agent to consume and inform agent via AgentClient

###### __init__(self)

Kind: Method

###### prepare(self) -> FutureEvent: FutureEvent

Kind: Method

Creates a new empty Event.

@return: An empty Event of type L{FutureEvent}

###### upload(self, event: FutureEvent)

Kind: Method

Uploads an Event.

@param event: Event to be uploaded.
@type event: L{FutureEvent}

###### send_frame_event(self, imagedata: bytes | bytearray, camera_serial: str, title: str | None = None, frame_name: str | None =
None, frame_metadata: dict | None = None)

Kind: Method

Creates and immediately uploads an Event with a single frame. Does not allow for full customization of the Event.

@param imagedata: The encoded frame bytes
@type imagedata: bytes | bytearray
@param camera_serial: Serial number (MxID) of camera that took the picture
@type camera_serial: str
@param title: Optional title for the Event
@type title: str | NoneType
@param frame_name: Optional name for the frame, does not define the filename
@type frame_name: str | NoneType
@param frame_metadata: metadata of valid format will be visualized over the frame in the cloud. Optional.
@type frame_metadata: dict | NoneType

###### send_video_event(self, video: bytes | bytearray, title: str | None = None, video_name: str | None = None, video_metadata:
dict | None = None)

Kind: Method

Creates and immediately uploads an Event with a single video. Does not allow for full customization of the Event.

@param video: The encoded video bytes. Encoding must be H264.
@type video: bytes | bytearray
@param title: Optional title for the Event
@type title: str | NoneType
@param video_name: Optional name for the video, does not define the filename
@type video_name: str | NoneType
@param video_metadata: Metadata of valid format will be visualized over the video in the cloud. Optional.
@type video_metadata: dict | NoneType

###### send_binary_file_event(self, binary_data: bytes | bytearray, title: str | None = None, file_name: str | None = None)

Kind: Method

Creates and immediately uploads an Event with a file of arbitrary type. Does not allow for full customization of the Event.

@param binary_data: The file in bytes
@type binary_data: bytes | bytearray
@param title: Optional title for the Event
@type title: str | NoneType
@param file_name: Optional name for the file, does not define the filename
@type file_name: str | NoneType

###### send_text_file_event(self, text: str, title: str | None = None, text_name: str | None = None)

Kind: Method

Creates and immediately uploads an Event with a single string. Does not allow for full customization of the Event.

@param text: The text in string form
@type text: str
@param text: The text in string form
@type text: str
@param title: Optional title for the Event
@type title: str | NoneType
@param text_name: Optional name for the text
@type text_name: str | NoneType

###### robothub.robothub_core_wrapper.events.FutureEvent

Kind: Class

Object describing an Event

###### id

Kind: Instance Variable

ID of the Event

###### folder_path

Kind: Instance Variable

Path to the folder of the Event in the App's container. Added frames, files & videos are stored in this folder.

###### __init__(self, _id: str, folder_path: Union [ str , Path ])

Kind: Method

###### title

Kind: Instance Variable

Title of the Event in the Cloud. Set to "Event" + UUID by default.

###### add_video(self, _bytes: bytes | bytearray, name: str | None = None, metadata: dict | None = None, filename: str | None =
None, camera_serial: str | None = None)

Kind: Method

Adds a video to the Event.

@param _bytes: Bytes of the encoded video. Must be H264 format.
@type _bytes: bytes | bytearray
@param name: Optional - Name of the video
@type name: str | NoneType
@param metadata: Optional - Metadata to be overlayed over the video. List length must be equal to number of frames in the video.
@type metadata: list
@param filename: Optional - can define name of the video file on Host.
@type filename: str | NoneType
@param camera_serial: Optional - Serial number (MxID) of camera that took the video
@type camera_serial: str

###### add_frame(self, _bytes, camera_serial: str | None = None, name: str | None = None, metadata: dict | None = None, filename:
str | None = None)

Kind: Method

Adds a frame to the Event.

@param _bytes: Bytes of the encoded frame
@type _bytes: bytes | bytearray
@param camera_serial: Optional - Serial number (MxID) of camera that took the frame
@type camera_serial: str
@param name: Optional - Name of the frame
@type name: str | NoneType
@param metadata: Optional - Metadata to be overlayed over the frame
@type metadata: list
@param filename: Optional - can define name of the frame file on Host.
@type filename: str | NoneType

###### add_file(self, _bytes, name: str | None = None, filename: str | None = None)

Kind: Method

Adds a file to the Event.

@param _bytes: Bytes of the file.
@type _bytes: bytes | bytearray
@param name: Optional - Name of the file in the cloud
@type name: str | NoneType
@param filename: Optional - can define name of the file saved on Host.
@type filename: str | NoneType

###### add_existing_file(self, filename: Path | str, copy: bool = True, name: str | None = None)

Kind: Method

Adds an existing file to the Event.

@param filename: Path to the file to be added.
@type filename: Path | str
@param copy: If True, the file will be copied to the Event folder. If False, the file will be moved to the Event folder.
@type copy: bool
@param name: Optional - Name of the file in the cloud
@type name: str | NoneType

###### set_title(self, title)

Kind: Method

Sets the title of the Event.

@param title: Title for the Event
@type title: str | NoneType

###### set_metadata(self, metadata: dict)

Kind: Method

Sets the metadata of the Event.

@param metadata: Dictionary containing the metadata
@type metadata: dict

###### add_tag(self, tag: str)

Kind: Method

Adds a tag to the Event.

Cannot add more than 10 tags to one Event.

@param tag: The tag string
@type tag: str

###### add_tags(self, tags: List [ str ])

Kind: Method

Adds multiple tags to the Event.

Cannot add more than 10 tags to one Event.

@param tags: A list of tags
@type tags: List[str]

###### set_tags(self, tags: List [ str ])

Kind: Method

Sets the tags of the Event.

An Event cannot have more than 10 tags.

@param tags: A list of tags
@type tags: List[str]

###### keep_after_upload

Kind: Property

Decides whether Event should be kept after upload, C{False} by default.

Example usage:

>>> self.keep_after_upload
True

return: bool

###### keep_after_upload.setter(self, value: bool)

Kind: Method

Sets the keep after upload property.

Example usage:

>>> self.keep_after_upload = True

###### no_upload_by_default

Kind: Property

If set to True, Event will not be uploaded. C{False} by default.

Example usage:

>>> self.no_upload_by_default
True

return: bool

###### no_upload_by_default.setter(self, value: bool)

Kind: Method

Sets the keep after upload property.

Example usage:

>>> self.keep_after_upload = True

###### keep_when_space_low

Kind: Property

Decides whether Event should be kept when storage space is low, C{False} by default.

Example usage:

>>> self.keep_after_upload
True

return: bool

###### keep_when_space_low.setter(self, value: bool)

Kind: Method

Sets the keep when space low property.

Example usage:

>>> self.keep_when_space_low = True

###### robothub.robothub_core_wrapper.events.UploadedEventPublicAccess(typing.TypedDict)

Kind: Class

Object that describes public access (without credentials) to an uploaded Event.

###### domain: str

Kind: Class Variable

Domain of the robot

###### token: str

Kind: Class Variable

Token which allows limited time access to the Event

###### robothub.robothub_core_wrapper.events.UploadedEvent

Kind: Class

Contains information about an uploaded Event, has no methods. Automatically sent as input to App's "on_event_uploaded" method.

###### event_id: str

Kind: Class Variable

ID of the Event

###### robothub_url: str

Kind: Class Variable

URL of the Event, accessible only with credentials

###### public_access: Union[UploadedEventPublicAccess, None]

Kind: Class Variable

Object allowing public access

###### tags: List[str]

Kind: Class Variable

List of tags of the Event

###### EVENTS

Kind: Constant

##### globals

Kind: Module

Defines various global variables.

###### TEAM_ID

Kind: Constant

ID of RobotHub team Robot running the App belongs to.

###### APP_VERSION

Kind: Constant

Version of the source the App was installed with.

###### APP_INSTANCE_ID

Kind: Constant

ID of instance of the App on current Robot. Not the ID of the App.

###### ROBOT_ID

Kind: Constant

ID of Robot running the App.

###### ROBOTHUB_CONFIG_PATH

Kind: Constant

###### LOCAL_CONFIG_PATH

Kind: Constant

###### STORAGE_DIR: str

Kind: Constant

Storage directory for Events and other files, can be used by the user

###### PUBLIC_FILES_DIR: str

Kind: Constant

Storage directory intended for public assets

###### CONFIGURATION: dict

Kind: Constant

###### DEVICES: list

Kind: Constant

###### available_devices

Kind: Variable

###### device_info: dai.DeviceInfo

Kind: Variable

###### device_info_as_dict

Kind: Variable

##### streams

Kind: Module

Contains classes and methods for streaming to App's Frontend server and the Cloud.

###### robothub.robothub_core_wrapper.streams.Streams

Kind: Class

Handles video streams

###### streams

Kind: Instance Variable

###### __init__(self)

Kind: Method

###### create_video(self, camera_serial: str, unique_key: str, description: str) -> StreamHandle: StreamHandle

Kind: Method

Creates a stream and returns its L{StreamHandle}

@param camera_serial: Serial number (MxID) of camera requesting the stream
@type camera_serial: str
@param unique_key: Key identifying the stream. Must be unique for each created stream, else an exception is thrown.
@type unique_key: str
@param description: Name of the stream in the cloud. Does not have to be unique.
@type description: str

###### destroy(self, stream: StreamHandle)

Kind: Method

Deletes a stream and its L{StreamHandle}.

@param stream: key of stream to be destroyed
@type stream: L{StreamHandle}

###### destroy_streams_by_id(self, stream_ids: list)

Kind: Method

Destroys streams corresponding to {stream_ids}, throws if any of the corresponding streams does not exist.

@param stream_ids: Keys of streams to be destroyed
@type stream_ids: List[str]

###### destroy_all_streams(self)

Kind: Method

Destroys all streams.

###### robothub.robothub_core_wrapper.streams.StreamHandle

Kind: Class

Used for handling an open stream

@param camera_serial: Serial number (MxID) of camera the stream is registered for
@type camera_serial: str
@param unique_key: Unique Key identifying the stream
@type unique_key: str
@param description: Name of the stream in the cloud
@type description: str

###### __init__(self, agent_client: AgentClient, unique_key: str, camera_serial: str, description: str, fifo_path)

Kind: Method

###### unique_key

Kind: Instance Variable

Unique Key identifying the stream

###### camera_serial

Kind: Instance Variable

Serial number (MxID) of camera the stream is registered for

###### description

Kind: Instance Variable

Name of the stream in the cloud

###### publish_video_data(self, video_data: bytes | bytearray, timestamp: int, metadata: dict | None = None)

Kind: Method

Used to send a frame with a corresponding timestamp. Optionally, metadata to be rendered over the frame can be included.

@param video_data: Bytes of the encoded frame. Encoding must be H264.
@type video_data: bytes | bytearray
@param timestamp: Timestamp of the frame. Does not have to correspond to when frame was taken on device, but must be increasing
with each subsequent frame.
@type timestamp: int

###### STREAMS

Kind: Constant

Instance of B{Streams} class, initialized at App startup.

#### types

Kind: Module

##### BoundingBox

Kind: Type Alias

##### Line

Kind: Type Alias

#### utils

Kind: Module

##### setup_logger(name: str, level: int = logging.INFO)

Kind: Function

Initializes a logger with the given name and level.

:param name: Logger name.
:param level: Either a string or an integer. If a string, it must be one of the following: 'DEBUG', 'INFO',
'WARNING', 'ERROR', 'CRITICAL'. If an integer, it must be one of the following: log.DEBUG, log.INFO, log.WARNING,
log.ERROR, log.CRITICAL.

##### get_device_performance_metrics(device: depthai.Device) -> Dict[str, Any]: Dict[str, Any]

Kind: Function

Returns a dictionary with statistics about the device.

##### get_device_details(device: depthai.Device, state: robothub_core.DeviceState) -> Dict[str, Any]: Dict[str, Any]

Kind: Function

Returns a dictionary with information about the device.

##### try_or_default(func, default = None)

Kind: Function

Tries to call the given function and returns its result. If an exception is raised, returns the default value.

#### __version__: str

Kind: Variable
