API Reference¶
Classes:
|
If NN input frame is in different aspect ratio than what the model expect, we have 3 different modes of operation. |
|
OakCamera improves ease of use when developing apps for OAK devices. |
|
How do we want to draw bounding box. |
|
Configuration for drawing circles. |
|
Configuration for drawing bounding boxes. |
|
Contains only dai.ImgFrame message and cv2 frame, which is used by visualization logic. |
|
|
|
Enum where members are also (and must be) ints |
Class that allows to track the click events on preview windows and show pixel value of a frame in coordinates pointed by the user. |
|
|
Configuration for output of the visualizer. |
|
PurePath subclass that can make system calls. |
|
Enum class, assigning preview name with decode function. |
|
Create a queue object with a given maximum size. |
|
This class records depthai streams from OAK cameras into different formats. |
|
An enumeration. |
|
|
|
|
|
Configuration for drawing segmentation masks. |
|
An enumeration. |
|
|
|
Configuration for drawing labels. |
|
Where on frame do we want to print text. |
|
A class that represents a thread of control. |
|
Configuration for drawing tracking bounding boxes. |
|
A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image. |
|
Configuration for visualizer. |
|
|
|
Stream of frames. |
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
Functions:
|
Set the logging level for the DepthAI SDK logger. |
|
Get sentry status from config file. |
|
Calculates cosine distance - https://en.wikipedia.org/wiki/Cosine_similarity |
|
Create new image(numpy array) filled with certain color in RGB |
|
Crop the frame to desired aspect ratio and then scales it down to desired size :param frame: Source frame that will be cropped :type frame: numpy.ndarray :param size: Desired frame size (width, height) :type size: tuple |
|
Returns the same class as was passed in, with dunder methods added based on the fields defined in the class. |
|
|
|
|
|
Downloads a video from YouTube and returns the path to video. |
|
Return an object to identify dataclass fields. |
|
Mapps bounding box coordinates (0..1) to pixel values on frame |
Get available (online) depthai-recordings. |
|
|
Find a correct |
|
|
|
|
|
|
|
Loads module from specified path. |
|
Utility function to merge two dictionaries |
Monotonic clock, cannot go backward. |
|
|
Report crash dump to Sentry if sentry is enabled and crash dump is available. |
|
Transforms the frame to meet the desired size, preserving the aspect ratio and adding black borders (letterboxing) :param frame: Source frame that will be resized :type frame: numpy.ndarray :param size: Desired frame size (width, height) :type size: tuple |
|
Set sentry status in config file. |
|
Print progressbar to stdout. |
|
Converts interleaved frame into planar |
|
Converts NN packet to dict, with each key being output tensor name and each value being correctly reshaped and converted results array |
Exceptions:
-
class
depthai_sdk.
ArgsParser
¶ Bases:
object
Methods:
parseArgs
([parser])Creates Argument parser for common OAK device configuration
-
static
parseArgs
(parser=None)¶ Creates Argument parser for common OAK device configuration
- Parameters
parser (argparse.ArgumentParser, optional) – Use an existing parser. By default it creates a new ArgumentParser.
- Return type
Dict[str, Any]
-
static
-
class
depthai_sdk.
ResizeMode
(value)¶ Bases:
enum.IntEnum
If NN input frame is in different aspect ratio than what the model expect, we have 3 different modes of operation. Full documentation: https://docs.luxonis.com/projects/api/en/latest/tutorials/maximize_fov/
Attributes:
Methods:
parse
(mode)-
LETTERBOX
= 0¶
-
STRETCH
= 1¶
-
CROP
= 2¶
-
FULL_CROP
= 3¶
-
-
depthai_sdk.
set_logging_level
(level)¶ Set the logging level for the DepthAI SDK logger.
-
class
depthai_sdk.
OakCamera
(device=None, usb_speed=None, replay=None, rotation=0, config=None, args=True)¶ Bases:
object
OakCamera improves ease of use when developing apps for OAK devices.
It abstracts DepthAI API pipeline building, different camera permutations, stream recording/replaying, it adds debugging features, does AI model handling, message syncing & visualization, and much more.
It was designed with interoperability with depthai API in mind.
Methods:
__init__
([device, usb_speed, replay, …])Initializes OakCamera
camera
(source[, resolution, fps, encode])Creates Camera component.
create_camera
(source[, resolution, fps, encode])Deprecated, use camera() instead.
all_cameras
([resolution, fps, encode])Creates Camera component for each camera sensors on the OAK camera.
create_all_cameras
([resolution, fps, encode])Deprecated, use all_cameras() instead.
create_nn
(model, input[, nn_type, tracker, …])Creates Neural Network component.
stereo
([resolution, fps, left, right, encode])Create Stereo camera component.
create_stereo
([resolution, fps, left, …])Deprecated, use stereo() instead.
Create IMU component
create_pointcloud
([stereo, colorize])config_pipeline
([xlink_chunk, calib, …])Configures DepthAI pipeline.
close
()start
([blocking])Start the application - upload the pipeline to the OAK device.
running
()Check if camera is running.
poll
()Poll events; cv2.waitKey, send controls to OAK (if controls are enabled), update, check syncs.
sync
(outputs, callback[, visualize])record
(outputs, path[, record_type])Record component outputs.
Shows DepthAI Pipeline graph, which can be useful when debugging.
visualize
(output[, record_path, scale, fps, …])Visualize component output(s).
queue
(output[, max_size])Create a queue for the component output(s).
callback
(output, callback[, main_thread])Create a callback for the component output(s).
ros_stream
(output)Publish component output(s) to ROS streams.
trigger_action
(trigger, action)Attributes:
Returns list of all sensors added to the pipeline.
-
__init__
(device=None, usb_speed=None, replay=None, rotation=0, config=None, args=True)¶ Initializes OakCamera
- Parameters
device (str, optional) – OAK device we want to connect to, either MxId, IP, or USB port
usb_speed (str, optional) – USB speed we want to use. Defaults to ‘auto’.
replay (str, optional) – Replay a depthai-recording - either local path, or from depthai-recordings repo
rotation (int, optional) – Rotate the camera output by this amount of degrees, 0 by default, 90, 180, 270 are supported.
args (None, bool, Dict) – Use user defined arguments when constructing the pipeline
config (Optional[depthai.Device.Config]) –
-
camera
(source, resolution=None, fps=None, encode=None)¶ Creates Camera component. This abstracts ColorCamera/MonoCamera nodes and supports mocking the camera when recording is passed during OakCamera initialization. Mocking the camera will send frames from the host to the OAK device (via XLinkIn node).
- Parameters
source (str / dai.CameraBoardSocket) – Camera source
resolution (str/SensorResolution) – Sensor resolution of the camera.
fps (float) – Sensor FPS
encode (bool/str/Profile) – Whether we want to enable video encoding (accessible via cameraComponent.out_encoded). If True, it will use MJPEG
- Return type
depthai_sdk.components.camera_component.CameraComponent
-
create_camera
(source, resolution=None, fps=None, encode=None)¶ Deprecated, use camera() instead.
Creates Camera component. This abstracts ColorCamera/MonoCamera nodes and supports mocking the camera when recording is passed during OakCamera initialization. Mocking the camera will send frames from the host to the OAK device (via XLinkIn node).
- Parameters
source (str / dai.CameraBoardSocket) – Camera source
resolution (str/SensorResolution) – Sensor resolution of the camera.
fps (float) – Sensor FPS
encode (bool/str/Profile) – Whether we want to enable video encoding (accessible via cameraComponent.out_encoded). If True, it will use MJPEG
- Return type
depthai_sdk.components.camera_component.CameraComponent
-
all_cameras
(resolution=None, fps=None, encode=None)¶ Creates Camera component for each camera sensors on the OAK camera.
- Parameters
resolution (str/SensorResolution) – Sensor resolution of the camera.
fps (float) – Sensor FPS
encode (bool/str/Profile) – Whether we want to enable video encoding (accessible via cameraComponent.out_encoded). If True, it will use MJPEG
- Return type
List[depthai_sdk.components.camera_component.CameraComponent]
-
create_all_cameras
(resolution=None, fps=None, encode=None)¶ Deprecated, use all_cameras() instead.
Creates Camera component for each camera sensors on the OAK camera.
- Parameters
resolution (str/SensorResolution) – Sensor resolution of the camera.
fps (float) – Sensor FPS
encode (bool/str/Profile) – Whether we want to enable video encoding (accessible via cameraComponent.out_encoded). If True, it will use MJPEG
- Return type
List[depthai_sdk.components.camera_component.CameraComponent]
-
create_nn
(model, input, nn_type=None, tracker=False, spatial=None, decode_fn=None)¶ Creates Neural Network component.
- Parameters
model (str / Path) – str for SDK supported model or Path to custom model’s json/blob
input (CameraComponent/NNComponent) – Input to the model. If NNComponent (detector), it creates 2-stage NN
nn_type (str) – Type of the network (yolo/mobilenet) for on-device NN result decoding (only needed if blob path was specified)
tracker (bool) – Enable object tracker, if model is object detector (yolo/mobilenet)
spatial (Union[None, bool, depthai_sdk.components.stereo_component.StereoComponent]) – Calculate 3D spatial coordinates, if model is object detector (yolo/mobilenet) and depth stream is available
decode_fn (Optional[Callable]) – Custom decoding function for the model’s output
- Return type
depthai_sdk.components.nn_component.NNComponent
-
stereo
(resolution=None, fps=None, left=None, right=None, encode=None)¶ Create Stereo camera component. If left/right cameras/component aren’t specified they will get created internally.
- Parameters
resolution (str/SensorResolution) – If monochrome cameras aren’t already passed, create them and set specified resolution
fps (float) – If monochrome cameras aren’t already passed, create them and set specified FPS
left (CameraComponent/dai.node.MonoCamera) – Pass the camera object (component/node) that will be used for stereo camera.
right (CameraComponent/dai.node.MonoCamera) – Pass the camera object (component/node) that will be used for stereo camera.
encode (bool/str/Profile) – Whether we want to enable video encoding (accessible via StereoComponent.out.encoded). If True, it will use h264 codec.
- Return type
depthai_sdk.components.stereo_component.StereoComponent
-
create_stereo
(resolution=None, fps=None, left=None, right=None, name=None, encode=None)¶ Deprecated, use stereo() instead.
Create Stereo camera component. If left/right cameras/component aren’t specified they will get created internally.
- Parameters
resolution (str/SensorResolution) – If monochrome cameras aren’t already passed, create them and set specified resolution
fps (float) – If monochrome cameras aren’t already passed, create them and set specified FPS
left (CameraComponent/dai.node.MonoCamera) – Pass the camera object (component/node) that will be used for stereo camera.
right (CameraComponent/dai.node.MonoCamera) – Pass the camera object (component/node) that will be used for stereo camera.
encode (bool/str/Profile) – Whether we want to enable video encoding (accessible via StereoComponent.out.encoded). If True, it will use h264 codec.
name (Optional[str]) –
- Return type
depthai_sdk.components.stereo_component.StereoComponent
-
create_imu
()¶ Create IMU component
- Return type
depthai_sdk.components.imu_component.IMUComponent
-
create_pointcloud
(stereo=None, colorize=None)¶ - Parameters
stereo (Union[None, depthai_sdk.components.stereo_component.StereoComponent, depthai.node.StereoDepth, depthai.Node.Output]) –
colorize (Union[None, depthai_sdk.components.camera_component.CameraComponent, depthai.node.MonoCamera, depthai.node.ColorCamera, depthai.Node.Output, bool]) –
- Return type
depthai_sdk.components.pointcloud_component.PointcloudComponent
-
config_pipeline
(xlink_chunk=None, calib=None, tuning_blob=None, openvino_version=None)¶ Configures DepthAI pipeline. @param xlink_chunk: Chunk size of XLink messages. 0 can result in lower latency @param calib: Calibration data to be uploaded to OAK @param tuning_blob: Camera tuning blob @param openvino_version: Force specific OpenVINO version
- Parameters
xlink_chunk (Optional[int]) –
calib (Optional[depthai.CalibrationHandler]) –
tuning_blob (Optional[str]) –
openvino_version (Union[None, str, depthai.OpenVINO.Version]) –
-
close
()¶
-
start
(blocking=False)¶ Start the application - upload the pipeline to the OAK device. :param blocking: Continuously loop and call oak.poll() until program exits :type blocking: bool
-
running
()¶ Check if camera is running. :returns: True if camera is running, False otherwise.
- Return type
-
poll
()¶ Poll events; cv2.waitKey, send controls to OAK (if controls are enabled), update, check syncs.
Returns: key pressed from cv2.waitKey, or None if
- Return type
Optional[int]
-
sync
(outputs, callback, visualize=False)¶ - Parameters
outputs (Union[depthai_sdk.components.component.ComponentOutput, List[depthai_sdk.components.component.ComponentOutput]]) –
callback (Callable) –
-
record
(outputs, path, record_type=<RecordType.VIDEO: 1>)¶ Record component outputs. This handles syncing multiple streams (eg. left, right, color, depth) and saving them to the computer in desired format (raw, mp4, mcap, bag..).
- Parameters
outputs (Component/Component output) – Component output(s) to be recorded.
path (str) – Folder path where to save these streams.
record_type (depthai_sdk.record.RecordType) – Record type.
- Return type
depthai_sdk.classes.packet_handlers.RecordPacketHandler
-
show_graph
()¶ Shows DepthAI Pipeline graph, which can be useful when debugging. You must call this BEFORE calling the oak.start()!
-
visualize
(output, record_path=None, scale=None, fps=False, callback=None, visualizer='opencv')¶ Visualize component output(s). This handles output streaming (OAK->host), message syncing, and visualizing.
- Parameters
output (Component/Component output) – Component output(s) to be visualized. If component is passed, SDK will visualize its default output (out()).
record_path (Optional[str]) – Path where to store the recording (visualization window name gets appended to that path), supported formats: mp4, avi.
scale (Optional[float]) – Scale the output window by this factor.
fps – Whether to show FPS on the output window.
callback (Optional[Callable]) – Instead of showing the frame, pass the Packet to the callback function, where it can be displayed.
visualizer (str) – Which visualizer to use. Options: ‘opencv’, ‘depthai-viewer’, ‘robothub’.
- Return type
-
queue
(output, max_size=30)¶ Create a queue for the component output(s). This handles output streaming (OAK->Host) and message syncing.
- Parameters
output (Union[depthai_sdk.components.component.ComponentOutput, depthai_sdk.components.component.Component, List]) – Component output(s) to be visualized. If component is passed, SDK will visualize its default output.
max_size (int) – Maximum queue size for this output.
- Return type
depthai_sdk.classes.packet_handlers.QueuePacketHandler
-
callback
(output, callback, main_thread=False)¶ Create a callback for the component output(s). This handles output streaming (OAK->Host) and message syncing.
- Parameters
output (Union[List, Callable, depthai_sdk.components.component.Component]) – Component output(s) to be visualized. If component is passed, SDK will visualize its default output.
callback (Callable) – Handler function to which the Packet will be sent.
main_thread – Whether to run the callback in the main thread. If False, it will call the callback in a separate thread, so some functions (eg. cv2.imshow) won’t work.
- Return type
depthai_sdk.classes.packet_handlers.CallbackPacketHandler
-
ros_stream
(output)¶ Publish component output(s) to ROS streams.
- Parameters
output (Union[List, depthai_sdk.components.component.ComponentOutput, depthai_sdk.components.component.Component]) –
- Return type
depthai_sdk.classes.packet_handlers.RosPacketHandler
-
trigger_action
(trigger, action)¶ - Parameters
trigger (depthai_sdk.trigger_action.triggers.abstract_trigger.Trigger) –
action (Union[depthai_sdk.trigger_action.actions.abstract_action.Action, Callable]) –
- Return type
-
property
sensors
¶ Returns list of all sensors added to the pipeline.
-
-
depthai_sdk.
get_config_field
(key)¶ Get sentry status from config file.
-
class
depthai_sdk.
AbstractReader
¶ Bases:
abc.ABC
Methods:
read
()Read a frame (or multiple frames) from the reader.
getShape
(name)Returns (width, height)
get_socket
(name)Returns socket
get_message_size
(name)@param name: Stream name @return: Number of bytes for that this message contains
close
()disableStream
(name)@param name: Name of the stream to be disabled
-
abstract
read
()¶ Read a frame (or multiple frames) from the reader. @return: Single np.ndarray, or dict of frames and their names. None if frames weren’t read or there was an error.
- Return type
Dict[str, numpy.ndarray]
-
abstract
getShape
(name)¶ Returns (width, height)
-
abstract
get_message_size
(name)¶ @param name: Stream name @return: Number of bytes for that this message contains
-
abstract
close
()¶
-
abstract
-
class
depthai_sdk.
BboxStyle
(value)¶ Bases:
enum.IntEnum
How do we want to draw bounding box.
Attributes:
-
RECTANGLE
= 0¶
-
CORNERS
= 1¶
-
ROUNDED_RECTANGLE
= 10¶
-
ROUNDED_CORNERS
= 11¶
-
-
class
depthai_sdk.
CircleConfig
(thickness=1, color=(255, 255, 255), line_type=16)¶ Bases:
object
Configuration for drawing circles.
Attributes:
Methods:
__init__
([thickness, color, line_type])Initialize self.
-
class
depthai_sdk.
DetectionConfig
(thickness=1, fill_transparency=0.15, box_roundness=0, color=(0, 255, 0), bbox_style=<BboxStyle.RECTANGLE: 0>, line_width=0.5, line_height=0.5, hide_label=False, label_position=<TextPosition.TOP_LEFT: 0>, label_padding=10)¶ Bases:
object
Configuration for drawing bounding boxes.
Attributes:
Methods:
__init__
([thickness, fill_transparency, …])Initialize self.
-
bbox_style
: depthai_sdk.visualize.configs.BboxStyle = 0¶
-
label_position
: depthai_sdk.visualize.configs.TextPosition = 0¶
-
__init__
(thickness=1, fill_transparency=0.15, box_roundness=0, color=(0, 255, 0), bbox_style=<BboxStyle.RECTANGLE: 0>, line_width=0.5, line_height=0.5, hide_label=False, label_position=<TextPosition.TOP_LEFT: 0>, label_padding=10)¶ Initialize self. See help(type(self)) for accurate signature.
- Parameters
thickness (int) –
fill_transparency (float) –
box_roundness (int) –
bbox_style (depthai_sdk.visualize.configs.BboxStyle) –
line_width (float) –
line_height (float) –
hide_label (bool) –
label_position (depthai_sdk.visualize.configs.TextPosition) –
label_padding (int) –
- Return type
-
-
class
depthai_sdk.
FramePacket
(name, msg)¶ Bases:
depthai_sdk.classes.packets.BasePacket
Contains only dai.ImgFrame message and cv2 frame, which is used by visualization logic.
Methods:
__init__
(name, msg)Initialize self.
set_decode_codec
(get_codec)decode
()get_size
()Attributes:
-
__init__
(name, msg)¶ Initialize self. See help(type(self)) for accurate signature.
- Parameters
name (str) –
msg (depthai.ImgFrame) –
-
property
frame
¶
-
get_timestamp
()¶ - Return type
-
set_decode_codec
(get_codec)¶ - Parameters
get_codec (Callable) –
-
decode
()¶ - Return type
Optional[numpy.ndarray]
-
-
class
depthai_sdk.
IMUPacket
(name, packet, rotation=None)¶ Bases:
depthai_sdk.classes.packets.BasePacket
Methods:
__init__
(name, packet[, rotation])Initialize self.
Returns imu values in a tuple.
-
__init__
(name, packet, rotation=None)¶ Initialize self. See help(type(self)) for accurate signature.
- Parameters
packet (depthai.IMUPacket) –
-
get_imu_vals
()¶ Returns imu values in a tuple. Returns in format (accelerometer_values, gyroscope_values, quaternion, magnetometer_values)
- Return type
Tuple[Sequence, Sequence, Sequence, Sequence]
-
get_timestamp
()¶ - Return type
-
-
class
depthai_sdk.
IntEnum
(value)¶ -
Enum where members are also (and must be) ints
-
class
depthai_sdk.
MouseClickTracker
¶ Bases:
object
Class that allows to track the click events on preview windows and show pixel value of a frame in coordinates pointed by the user.
Used internally by
depthai_sdk.managers.PreviewManager
Attributes:
Stores selected point position per frame
Stores values assigned to specific point per frame
Methods:
selectPoint
(name)Returns callback function for
cv2.setMouseCallback
that will update the selected point on mouse click event from frame.extractValue
(name, frame)Extracts value from frame for a specific point
-
selectPoint
(name)¶ Returns callback function for
cv2.setMouseCallback
that will update the selected point on mouse click event from frame.Usually used as
mct = MouseClickTracker() # create preview window cv2.setMouseCallback(window_name, mct.select_point(window_name))
- Parameters
name (str) – Name of the frame
- Returns
Callback function for
cv2.setMouseCallback
-
extractValue
(name, frame)¶ Extracts value from frame for a specific point
- Parameters
name (str) – Name of the frame
frame (numpy.ndarray) –
-
-
class
depthai_sdk.
OutputConfig
(img_scale=1.0, show_fps=False, clickable=True)¶ Bases:
object
Configuration for output of the visualizer.
Attributes:
Methods:
__init__
([img_scale, show_fps, clickable])Initialize self.
-
class
depthai_sdk.
Path
(*args, **kwargs)¶ Bases:
pathlib.PurePath
PurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
Methods:
cwd
()Return a new path pointing to the current working directory (as returned by os.getcwd()).
home
()Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).
samefile
(other_path)Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
iterdir
()Iterate over the files in this directory.
glob
(pattern)Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
rglob
(pattern)Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
absolute
()Return an absolute version of this path.
resolve
([strict])Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).
stat
()Return the result of the stat() system call on this path, like os.stat() does.
owner
()Return the login name of the file owner.
group
()Return the group name of the file gid.
open
([mode, buffering, encoding, errors, …])Open the file pointed by this path and return a file object, as the built-in open() function does.
Open the file in bytes mode, read it, and close the file.
read_text
([encoding, errors])Open the file in text mode, read it, and close the file.
write_bytes
(data)Open the file in bytes mode, write to it, and close the file.
write_text
(data[, encoding, errors])Open the file in text mode, write to it, and close the file.
touch
([mode, exist_ok])Create this file with the given access mode, if it doesn’t exist.
mkdir
([mode, parents, exist_ok])Create a new directory at this given path.
chmod
(mode)Change the permissions of the path, like os.chmod().
lchmod
(mode)Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
unlink
([missing_ok])Remove this file or link.
rmdir
()Remove this directory.
lstat
()Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
rename
(target)Rename this path to the target path.
replace
(target)Rename this path to the target path, overwriting if that path exists.
symlink_to
(target[, target_is_directory])Make this path a symlink pointing to the target path.
link_to
(target)Make the target path a hard link pointing to this path.
exists
()Whether this path exists.
is_dir
()Whether this path is a directory.
is_file
()Whether this path is a regular file (also True for symlinks pointing to regular files).
is_mount
()Check if this path is a POSIX mount point
Whether this path is a symbolic link.
Whether this path is a block device.
Whether this path is a character device.
is_fifo
()Whether this path is a FIFO.
Whether this path is a socket.
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
-
classmethod
cwd
()¶ Return a new path pointing to the current working directory (as returned by os.getcwd()).
-
classmethod
home
()¶ Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).
-
samefile
(other_path)¶ Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
-
iterdir
()¶ Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.
-
glob
(pattern)¶ Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
-
rglob
(pattern)¶ Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
-
absolute
()¶ Return an absolute version of this path. This function works even if the path doesn’t point to anything.
No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file.
-
resolve
(strict=False)¶ Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).
-
stat
()¶ Return the result of the stat() system call on this path, like os.stat() does.
-
owner
()¶ Return the login name of the file owner.
-
group
()¶ Return the group name of the file gid.
-
open
(mode='r', buffering=- 1, encoding=None, errors=None, newline=None)¶ Open the file pointed by this path and return a file object, as the built-in open() function does.
-
read_bytes
()¶ Open the file in bytes mode, read it, and close the file.
-
read_text
(encoding=None, errors=None)¶ Open the file in text mode, read it, and close the file.
-
write_bytes
(data)¶ Open the file in bytes mode, write to it, and close the file.
-
write_text
(data, encoding=None, errors=None)¶ Open the file in text mode, write to it, and close the file.
-
touch
(mode=438, exist_ok=True)¶ Create this file with the given access mode, if it doesn’t exist.
-
mkdir
(mode=511, parents=False, exist_ok=False)¶ Create a new directory at this given path.
-
chmod
(mode)¶ Change the permissions of the path, like os.chmod().
-
lchmod
(mode)¶ Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
-
unlink
(missing_ok=False)¶ Remove this file or link. If the path is a directory, use rmdir() instead.
-
rmdir
()¶ Remove this directory. The directory must be empty.
-
lstat
()¶ Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
-
rename
(target)¶ Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
-
replace
(target)¶ Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
-
symlink_to
(target, target_is_directory=False)¶ Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
-
link_to
(target)¶ Make the target path a hard link pointing to this path.
Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.
-
exists
()¶ Whether this path exists.
-
is_dir
()¶ Whether this path is a directory.
-
is_file
()¶ Whether this path is a regular file (also True for symlinks pointing to regular files).
-
is_mount
()¶ Check if this path is a POSIX mount point
-
is_symlink
()¶ Whether this path is a symbolic link.
-
is_block_device
()¶ Whether this path is a block device.
-
is_char_device
()¶ Whether this path is a character device.
-
is_fifo
()¶ Whether this path is a FIFO.
-
is_socket
()¶ Whether this path is a socket.
-
expanduser
()¶ Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
-
classmethod
-
class
depthai_sdk.
PreviewDecoder
¶ Bases:
object
Methods:
jpegDecode
(data, type)nnInput
(packet[, manager])Produces NN passthough frame from raw data packet
color
(packet[, manager])Produces color camera frame from raw data packet
left
(packet[, manager])Produces left camera frame from raw data packet
right
(packet[, manager])Produces right camera frame from raw data packet
rectifiedLeft
(packet[, manager])Produces rectified left frame (
depthai.node.StereoDepth.rectifiedLeft
) from raw data packetrectifiedRight
(packet[, manager])Produces rectified right frame (
depthai.node.StereoDepth.rectifiedRight
) from raw data packetdepthRaw
(packet[, manager])Produces raw depth frame (
depthai.node.StereoDepth.depth
) from raw data packetdepth
(depthRaw[, manager])Produces depth frame from raw depth frame (converts to disparity and applies color map)
disparity
(packet[, manager])Produces disparity frame (
depthai.node.StereoDepth.disparity
) from raw data packetdisparityColor
(disparity[, manager])Applies color map to disparity frame
-
static
jpegDecode
(data, type)¶
-
static
nnInput
(packet, manager=None)¶ Produces NN passthough frame from raw data packet
- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
color
(packet, manager=None)¶ Produces color camera frame from raw data packet
- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
left
(packet, manager=None)¶ Produces left camera frame from raw data packet
- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
right
(packet, manager=None)¶ Produces right camera frame from raw data packet
- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
rectifiedLeft
(packet, manager=None)¶ Produces rectified left frame (
depthai.node.StereoDepth.rectifiedLeft
) from raw data packet- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
rectifiedRight
(packet, manager=None)¶ Produces rectified right frame (
depthai.node.StereoDepth.rectifiedRight
) from raw data packet- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
depthRaw
(packet, manager=None)¶ Produces raw depth frame (
depthai.node.StereoDepth.depth
) from raw data packet- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
depth
(depthRaw, manager=None)¶ Produces depth frame from raw depth frame (converts to disparity and applies color map)
- Parameters
depthRaw (numpy.ndarray) – OpenCV frame containing raw depth frame
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
disparity
(packet, manager=None)¶ Produces disparity frame (
depthai.node.StereoDepth.disparity
) from raw data packet- Parameters
packet (depthai.ImgFrame) – Packet received from output queue
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
disparityColor
(disparity, manager=None)¶ Applies color map to disparity frame
- Parameters
disparity (numpy.ndarray) – OpenCV frame containing disparity frame
manager (depthai_sdk.managers.PreviewManager, optional) – PreviewManager instance
- Returns
Ready to use OpenCV frame
- Return type
-
static
-
class
depthai_sdk.
Previews
(value)¶ Bases:
enum.Enum
Enum class, assigning preview name with decode function.
Usually used as e.g.
Previews.color.name
when specifying color preview name.Can be also used as e.g.
Previews.color.value(packet)
to transform queue output packet to color camera frameAttributes:
nnInput
(*args, **kwargs)color
(*args, **kwargs)left
(*args, **kwargs)right
(*args, **kwargs)rectifiedLeft
(*args, **kwargs)rectifiedRight
(*args, **kwargs)depthRaw
(*args, **kwargs)depth
(*args, **kwargs)disparity
(*args, **kwargs)disparityColor
(*args, **kwargs)-
nnInput
(*args, **kwargs) = functools.partial(<function PreviewDecoder.nnInput>)¶
-
color
(*args, **kwargs) = functools.partial(<function PreviewDecoder.color>)¶
-
left
(*args, **kwargs) = functools.partial(<function PreviewDecoder.left>)¶
-
right
(*args, **kwargs) = functools.partial(<function PreviewDecoder.right>)¶
-
rectifiedLeft
(*args, **kwargs) = functools.partial(<function PreviewDecoder.rectifiedLeft>)¶
-
rectifiedRight
(*args, **kwargs) = functools.partial(<function PreviewDecoder.rectifiedRight>)¶
-
depthRaw
(*args, **kwargs) = functools.partial(<function PreviewDecoder.depthRaw>)¶
-
depth
(*args, **kwargs) = functools.partial(<function PreviewDecoder.depth>)¶
-
disparity
(*args, **kwargs) = functools.partial(<function PreviewDecoder.disparity>)¶
-
disparityColor
(*args, **kwargs) = functools.partial(<function PreviewDecoder.disparityColor>)¶
-
-
class
depthai_sdk.
Queue
(maxsize=0)¶ Bases:
object
Create a queue object with a given maximum size.
If maxsize is <= 0, the queue size is infinite.
Methods:
__init__
([maxsize])Initialize self.
Indicate that a formerly enqueued task is complete.
join
()Blocks until all items in the Queue have been gotten and processed.
qsize
()Return the approximate size of the queue (not reliable!).
empty
()Return True if the queue is empty, False otherwise (not reliable!).
full
()Return True if the queue is full, False otherwise (not reliable!).
put
(item[, block, timeout])Put an item into the queue.
get
([block, timeout])Remove and return an item from the queue.
put_nowait
(item)Put an item into the queue without blocking.
Remove and return an item from the queue without blocking.
-
__init__
(maxsize=0)¶ Initialize self. See help(type(self)) for accurate signature.
-
task_done
()¶ Indicate that a formerly enqueued task is complete.
Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.
If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue).
Raises a ValueError if called more times than there were items placed in the queue.
-
join
()¶ Blocks until all items in the Queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete.
When the count of unfinished tasks drops to zero, join() unblocks.
-
qsize
()¶ Return the approximate size of the queue (not reliable!).
-
empty
()¶ Return True if the queue is empty, False otherwise (not reliable!).
This method is likely to be removed at some point. Use qsize() == 0 as a direct substitute, but be aware that either approach risks a race condition where a queue can grow before the result of empty() or qsize() can be used.
To create code that needs to wait for all queued tasks to be completed, the preferred technique is to use the join() method.
-
full
()¶ Return True if the queue is full, False otherwise (not reliable!).
This method is likely to be removed at some point. Use qsize() >= n as a direct substitute, but be aware that either approach risks a race condition where a queue can shrink before the result of full() or qsize() can be used.
-
put
(item, block=True, timeout=None)¶ Put an item into the queue.
If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until a free slot is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Full exception if no free slot was available within that time. Otherwise (‘block’ is false), put an item on the queue if a free slot is immediately available, else raise the Full exception (‘timeout’ is ignored in that case).
-
get
(block=True, timeout=None)¶ Remove and return an item from the queue.
If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until an item is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Empty exception if no item was available within that time. Otherwise (‘block’ is false), return an item if one is immediately available, else raise the Empty exception (‘timeout’ is ignored in that case).
-
put_nowait
(item)¶ Put an item into the queue without blocking.
Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception.
-
get_nowait
()¶ Remove and return an item from the queue without blocking.
Only get an item if one is immediately available. Otherwise raise the Empty exception.
-
-
class
depthai_sdk.
Record
(path, record_type)¶ Bases:
object
This class records depthai streams from OAK cameras into different formats. It will also save calibration .json, so depth reconstruction will be possible.
Methods:
__init__
(path, record_type)- param path
Path to the recording folder
write
(packets)start
(device, xouts)Start recording process.
config_mcap
(pointcloud)close
()-
__init__
(path, record_type)¶ - Parameters
path (Path) – Path to the recording folder
record_type (RecordType) – Recording type
-
write
(packets)¶
-
start
(device, xouts)¶ Start recording process. This will create and start the pipeline, start recording threads, and initialize all queues.
- Parameters
device (depthai.Device) –
xouts (List[depthai_sdk.oak_outputs.xout.xout_frames.XoutFrames]) –
-
close
()¶
-
class
depthai_sdk.
RecordType
(value)¶ Bases:
enum.IntEnum
An enumeration.
Attributes:
-
VIDEO
= 1¶
-
VIDEO_LOSSLESS
= 2¶
-
ROSBAG
= 3¶
-
MCAP
= 4¶
-
DB3
= 5¶
-
-
class
depthai_sdk.
Recorder
¶ Bases:
abc.ABC
Methods:
write
(name, frame)close
()update
(path, device, xouts)-
abstract
write
(name, frame)¶ - Parameters
name (str) –
frame (depthai.ImgFrame) –
-
abstract
close
()¶
-
abstract
update
(path, device, xouts)¶ - Parameters
path (pathlib.Path) –
device (depthai.Device) –
xouts (List[XoutFrames]) –
-
abstract
-
class
depthai_sdk.
Replay
(path)¶ Bases:
object
Methods:
__init__
(path)Helper file to replay recorded depthai stream.
Toggle pausing of sending frames to the OAK camera.
set_fps
(fps)Sets frequency at which Replay module will send frames to the camera.
set_loop
(flag)Sets whether to loop the replay.
get_fps
()resize
(stream_name, size[, mode])Resize color frames prior to sending them to the device.
keepAspectRatio
(keepAspectRatio)disableStream
(stream_name[, disableReading])Disable sending a recorded stream to the device.
specify_socket
(stream_name, socket)initPipeline
([pipeline])Prepares the pipeline for replaying.
initStereoDepth
(stereo[, left_name, …])start
()Start sending frames to the OAK device on a new thread
Reads and sends recorded frames from all enabled streams to the OAK camera.
createQueues
(device)Creates input queue for each enabled stream
getShape
(name)Get shape of a stream
close
()Closes all video readers.
-
__init__
(path)¶ Helper file to replay recorded depthai stream. It reads from recorded files (mjpeg/avi/mp4/h265/h264/bag) and sends frames back to OAK camera to replay the scene, including depth reconstruction from 2 synced mono streams.
- Parameters
path (str) – Path to the recording folder.
-
toggle_pause
()¶ Toggle pausing of sending frames to the OAK camera.
-
set_fps
(fps)¶ Sets frequency at which Replay module will send frames to the camera. Default 30FPS.
- Parameters
fps (float) –
-
set_loop
(flag)¶ Sets whether to loop the replay.
- Parameters
flag (bool) – Whether to loop the replay.
-
resize
(stream_name, size, mode=<ResizeMode.STRETCH: 1>)¶ Resize color frames prior to sending them to the device.
- Parameters
stream_name (str) – Name of the stream we want to resize
size (Tuple(width, heigth)) – Size of color frames that are sent to the camera
mode (ResizeMode) – How to actually resize the stream
-
disableStream
(stream_name, disableReading=False)¶ Disable sending a recorded stream to the device.
-
specify_socket
(stream_name, socket)¶ - Parameters
stream_name (str) –
socket (depthai.CameraBoardSocket) –
-
initPipeline
(pipeline=None)¶ Prepares the pipeline for replaying. It creates XLinkIn nodes and sets up StereoDepth node. Returns: dai.Pipeline
- Parameters
pipeline (Optional[depthai.Pipeline]) –
-
initStereoDepth
(stereo, left_name='left', right_name='right', align_to='')¶ - Parameters
stereo (depthai.node.StereoDepth) –
left_name (str) –
right_name (str) –
align_to (str) –
-
start
()¶ Start sending frames to the OAK device on a new thread
-
sendFrames
()¶ Reads and sends recorded frames from all enabled streams to the OAK camera.
- Returns
True if successful, otherwise False.
- Return type
-
createQueues
(device)¶ Creates input queue for each enabled stream
- Parameters
device (dai.Device) – Device to which we will stream frames
-
close
()¶ Closes all video readers.
-
-
class
depthai_sdk.
ReplayStream
¶ Bases:
object
Attributes:
Methods:
__init__
()Initialize self.
-
property
shape
¶
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
-
get_socket
()¶ - Return type
-
property
-
class
depthai_sdk.
SegmentationConfig
(mask_alpha=0.5)¶ Bases:
object
Configuration for drawing segmentation masks.
Attributes:
Methods:
__init__
([mask_alpha])Initialize self.
-
class
depthai_sdk.
StereoColor
(value)¶ Bases:
enum.IntEnum
An enumeration.
Attributes:
-
GRAY
= 1¶
-
RGB
= 2¶
-
RGBD
= 3¶
-
-
class
depthai_sdk.
StereoConfig
(colorize: depthai_sdk.visualize.configs.StereoColor = <StereoColor.RGB: 2>, colormap: numpy.ndarray = <factory>, wls_filter: bool = False, wls_lambda: float = 8000, wls_sigma: float = 1.5)¶ Bases:
object
Attributes:
Methods:
__init__
([colorize, colormap, wls_filter, …])Initialize self.
-
colorize
: depthai_sdk.visualize.configs.StereoColor = 2¶
-
colormap
: numpy.ndarray¶
-
__init__
(colorize=<StereoColor.RGB: 2>, colormap=<factory>, wls_filter=False, wls_lambda=8000, wls_sigma=1.5)¶ Initialize self. See help(type(self)) for accurate signature.
- Parameters
colorize (depthai_sdk.visualize.configs.StereoColor) –
colormap (numpy.ndarray) –
wls_filter (bool) –
wls_lambda (float) –
wls_sigma (float) –
- Return type
-
-
class
depthai_sdk.
TextConfig
(font_face=0, font_color=(255, 255, 255), font_transparency=0.5, font_scale=1.0, font_thickness=2, font_position=<TextPosition.TOP_LEFT: 0>, background_color=None, background_transparency=0.5, outline_color=(0, 0, 0), line_type=16, auto_scale=True)¶ Bases:
object
Configuration for drawing labels.
Attributes:
Methods:
__init__
([font_face, font_color, …])Initialize self.
-
font_position
: depthai_sdk.visualize.configs.TextPosition = 0¶
-
__init__
(font_face=0, font_color=(255, 255, 255), font_transparency=0.5, font_scale=1.0, font_thickness=2, font_position=<TextPosition.TOP_LEFT: 0>, background_color=None, background_transparency=0.5, outline_color=(0, 0, 0), line_type=16, auto_scale=True)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
depthai_sdk.
TextPosition
(value)¶ Bases:
enum.IntEnum
Where on frame do we want to print text.
Attributes:
-
TOP_LEFT
= 0¶
-
MID_LEFT
= 1¶
-
BOTTOM_LEFT
= 2¶
-
TOP_MID
= 10¶
-
MID
= 11¶
-
BOTTOM_MID
= 12¶
-
TOP_RIGHT
= 20¶
-
MID_RIGHT
= 21¶
-
BOTTOM_RIGHT
= 22¶
-
-
class
depthai_sdk.
Thread
(group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None)¶ Bases:
object
A class that represents a thread of control.
This class can be safely subclassed in a limited fashion. There are two ways to specify the activity: by passing a callable object to the constructor, or by overriding the run() method in a subclass.
Methods:
__init__
([group, target, name, args, …])This constructor should always be called with keyword arguments.
start
(*a, **kw)run
()Method representing the thread’s activity.
join
([timeout])Wait until the thread terminates.
is_alive
()Return whether the thread is alive.
isAlive
()Return whether the thread is alive.
isDaemon
()setDaemon
(daemonic)getName
()setName
(name)Attributes:
A string used for identification purposes only.
Thread identifier of this thread or None if it has not been started.
Native integral thread ID of this thread, or None if it has not been started.
A boolean value indicating whether this thread is a daemon thread.
-
__init__
(group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None)¶ This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
-
run
()¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
join
(timeout=None)¶ Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.
-
property
name
¶ A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.
-
property
ident
¶ Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.
-
property
native_id
¶ Native integral thread ID of this thread, or None if it has not been started.
This is a non-negative integer. See the get_native_id() function. This represents the Thread ID as reported by the kernel.
-
is_alive
()¶ Return whether the thread is alive.
This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.
-
isAlive
()¶ Return whether the thread is alive.
This method is deprecated, use is_alive() instead.
-
property
daemon
¶ A boolean value indicating whether this thread is a daemon thread.
This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.
The entire Python program exits when only daemon threads are left.
-
isDaemon
()¶
-
setDaemon
(daemonic)¶
-
getName
()¶
-
setName
(name)¶
-
-
class
depthai_sdk.
TrackingConfig
(max_length=500, deletion_lost_threshold=5, line_thickness=1, fading_tails=False, line_color=(255, 255, 255), line_type=16, show_speed=False)¶ Bases:
object
Configuration for drawing tracking bounding boxes.
Attributes:
Methods:
__init__
([max_length, …])Initialize self.
-
__init__
(max_length=500, deletion_lost_threshold=5, line_thickness=1, fading_tails=False, line_color=(255, 255, 255), line_type=16, show_speed=False)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
depthai_sdk.
TurboJPEG
(lib_path=None)¶ Bases:
object
A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.
Methods:
__init__
([lib_path])Initialize self.
decode_header
(jpeg_buf)decodes JPEG header and returns image properties as a tuple.
decode
(jpeg_buf[, pixel_format, …])decodes JPEG memory buffer to numpy array.
decode_to_yuv
(jpeg_buf[, scaling_factor, …])decodes JPEG memory buffer to yuv array.
decode_to_yuv_planes
(jpeg_buf[, …])decodes JPEG memory buffer to yuv planes.
encode
(img_array[, quality, pixel_format, …])encodes numpy array to JPEG memory buffer.
scale_with_quality
(jpeg_buf[, …])decompresstoYUV with scale factor, recompresstoYUV with quality factor
crop
(jpeg_buf, x, y, w, h[, preserve, gray])losslessly crop a jpeg image with optional grayscale
crop_multiple
(jpeg_buf, crop_parameters[, …])Lossless crop and/or extension operations on jpeg image.
Attributes:
-
__init__
(lib_path=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
decode_header
(jpeg_buf)¶ decodes JPEG header and returns image properties as a tuple. e.g. (width, height, jpeg_subsample, jpeg_colorspace)
-
decode
(jpeg_buf, pixel_format=1, scaling_factor=None, flags=0)¶ decodes JPEG memory buffer to numpy array.
-
decode_to_yuv
(jpeg_buf, scaling_factor=None, pad=4, flags=0)¶ decodes JPEG memory buffer to yuv array.
-
decode_to_yuv_planes
(jpeg_buf, scaling_factor=None, strides=(0, 0, 0), flags=0)¶ decodes JPEG memory buffer to yuv planes.
-
encode
(img_array, quality=85, pixel_format=1, jpeg_subsample=1, flags=0)¶ encodes numpy array to JPEG memory buffer.
-
scale_with_quality
(jpeg_buf, scaling_factor=None, quality=85, flags=0)¶ decompresstoYUV with scale factor, recompresstoYUV with quality factor
-
crop
(jpeg_buf, x, y, w, h, preserve=False, gray=False)¶ losslessly crop a jpeg image with optional grayscale
-
crop_multiple
(jpeg_buf, crop_parameters, background_luminance=1.0, gray=False)¶ Lossless crop and/or extension operations on jpeg image. Crop origin(s) needs be divisable by the MCU block size and inside the input image, or OSError: Invalid crop request is raised.
- Parameters
jpeg_buf (bytes) – Input jpeg image.
crop_parameters (List[Tuple[int, int, int, int]]) – List of crop parameters defining start x and y origin and width and height of each crop operation.
background_luminance (float) – Luminance level (0 -1 ) to fill background when extending image. Default to 1, resulting in white background.
gray (bool) – Produce greyscale output
- Returns
Cropped and/or extended jpeg images.
- Return type
List[bytes]
-
property
scaling_factors
¶
-
-
class
depthai_sdk.
VisConfig
(output=<factory>, stereo=<factory>, detection=<factory>, text=<factory>, tracking=<factory>, circle=<factory>)¶ Bases:
object
Configuration for visualizer.
Attributes:
Methods:
__init__
([output, stereo, detection, text, …])Initialize self.
-
__init__
(output=<factory>, stereo=<factory>, detection=<factory>, text=<factory>, tracking=<factory>, circle=<factory>)¶ Initialize self. See help(type(self)) for accurate signature.
- Parameters
output (depthai_sdk.visualize.configs.OutputConfig) –
stereo (depthai_sdk.visualize.configs.StereoConfig) –
detection (depthai_sdk.visualize.configs.DetectionConfig) –
tracking (depthai_sdk.visualize.configs.TrackingConfig) –
circle (depthai_sdk.visualize.configs.CircleConfig) –
- Return type
-
-
class
depthai_sdk.
Visualizer
(scale=None, fps=False)¶ Bases:
object
Methods:
__init__
([scale, fps])Initialize self.
add_object
(obj)Call set_config, set_frame_shape and prepare for the object and add it to the list of objects.
add_bbox
(bbox[, color, thickness, …])Add a bounding box to the visualizer.
add_detections
(detections[, normalizer, …])Add detections to the visualizer.
add_text
(text[, coords, size, color, …])Add text to the visualizer.
add_trail
(tracklets, label_map[, bbox])Add a trail to the visualizer.
add_circle
(coords, radius[, color, thickness])Add a circle to the visualizer.
add_line
(pt1, pt2[, color, thickness])Add a line to the visualizer.
add_mask
(mask, alpha)Add a mask to the visualizer.
drawn
(frame)Draw all objects on the frame if the platform is PC.
show
(packet)Show the packet on the screen.
serialize
([force_reset])Serialize all contained objects to JSON.
reset
()Clear all objects.
output
([img_scale, show_fps])Configure the output of the visualizer.
stereo
([colorize, colormap, wls_filter, …])detections
([thickness, fill_transparency, …])Configure how bounding boxes will look like.
text
([font_face, font_color, …])Configure how text will look like.
tracking
([max_length, …])Configure how tracking trails will look like.
segmentation
([mask_alpha])close
()Attributes:
-
__init__
(scale=None, fps=False)¶ Initialize self. See help(type(self)) for accurate signature.
-
add_object
(obj)¶ Call set_config, set_frame_shape and prepare for the object and add it to the list of objects. :param obj: The object to add.
- Returns
self
- Parameters
- Return type
-
add_bbox
(bbox, color=None, thickness=None, bbox_style=None, label=None)¶ Add a bounding box to the visualizer.
- Parameters
bbox (depthai_sdk.visualize.bbox.BoundingBox) – Bounding box.
label (Optional[str]) – Label for the detection.
thickness (Optional[int]) – Bounding box thickness.
color (Optional[Tuple[int, int, int]]) – Bounding box color (RGB).
bbox_style (Optional[depthai_sdk.visualize.configs.BboxStyle]) – Bounding box style (one of depthai_sdk.visualize.configs.BboxStyle).
- Returns
self
- Return type
-
add_detections
(detections, normalizer=None, label_map=None, spatial_points=None, label_color=None, label_background_color=None, label_background_transparency=None, is_spatial=False, bbox=None)¶ Add detections to the visualizer.
- Parameters
detections (List[Union[depthai.ImgDetection, depthai.Tracklet]]) – List of detections.
normalizer (Optional[depthai_sdk.visualize.bbox.BoundingBox]) – Normalizer object.
label_map (Optional[List[Tuple[str, Tuple]]]) – List of tuples (label, color).
spatial_points (Optional[List[depthai.Point3f]]) – List of spatial points. None if not spatial.
label_color (Optional[Tuple[int, int, int]]) – Color for the label.
label_background_color (Optional[Tuple[int, int, int]]) – Color for the label background.
label_background_transparency (Optional[float]) – Transparency for the label background.
is_spatial – Flag that indicates if the detections are spatial.
bbox (Optional[Union[numpy.ndarray, Tuple[int, int, int, int]]]) – Bounding box, if there’s a detection inside a bounding box.
- Returns
self
- Return type
-
add_text
(text, coords=None, size=None, color=None, thickness=None, outline=True, background_color=None, background_transparency=0.5, bbox=None, position=<TextPosition.TOP_LEFT: 0>, padding=10)¶ Add text to the visualizer.
- Parameters
text (str) – Text.
size (Optional[int]) – Size of the text.
thickness (Optional[int]) – Thickness of the text.
outline (bool) – Flag that indicates if the text should be outlined.
background_color (Optional[Tuple[int, int, int]]) – Background color.
background_transparency (float) – Background transparency.
bbox (Optional[Union[numpy.ndarray, Tuple, depthai_sdk.visualize.bbox.BoundingBox]]) – Bounding box.
position (depthai_sdk.visualize.configs.TextPosition) – Position.
padding (int) – Padding.
- Returns
self
- Return type
-
add_trail
(tracklets, label_map, bbox=None)¶ Add a trail to the visualizer.
- Parameters
tracklets (List[depthai.Tracklet]) – List of tracklets.
label_map (List[Tuple[str, Tuple]]) – List of tuples (label, color).
bbox (Optional[depthai_sdk.visualize.bbox.BoundingBox]) – Bounding box.
- Returns
self
- Return type
-
add_circle
(coords, radius, color=None, thickness=None)¶ Add a circle to the visualizer.
-
add_line
(pt1, pt2, color=None, thickness=None)¶ Add a line to the visualizer.
-
add_mask
(mask, alpha)¶ Add a mask to the visualizer.
- Parameters
mask (numpy.ndarray) – Mask represented as uint8 numpy array.
alpha (float) – Transparency of the mask.
- Returns
self
-
drawn
(frame)¶ Draw all objects on the frame if the platform is PC. Otherwise, serialize the objects and communicate with the RobotHub application.
- Parameters
frame (numpy.ndarray) – The frame to draw on.
- Returns
np.ndarray if the platform is PC, None otherwise.
- Return type
Optional[numpy.ndarray]
-
show
(packet)¶ Show the packet on the screen.
-
serialize
(force_reset=True)¶ Serialize all contained objects to JSON.
-
reset
()¶ Clear all objects.
-
output
(img_scale=None, show_fps=None)¶ Configure the output of the visualizer.
- Parameters
- Returns
self
- Return type
-
stereo
(colorize=None, colormap=None, wls_filter=None, wls_lambda=None, wls_sigma=None)¶ - Parameters
colorize (Optional[depthai_sdk.visualize.configs.StereoColor]) –
colormap (Optional[int]) –
wls_filter (Optional[bool]) –
wls_lambda (Optional[float]) –
wls_sigma (Optional[float]) –
-
detections
(thickness=None, fill_transparency=None, bbox_roundness=None, color=None, bbox_style=None, line_width=None, line_height=None, hide_label=None, label_position=None, label_padding=None)¶ Configure how bounding boxes will look like. :param thickness: Thickness of the bounding box. :param fill_transparency: Transparency of the bounding box. :param bbox_roundness: Roundness of the bounding box. :param color: Color of the bounding box. :param bbox_style: Style of the bounding box. :param line_width: Width of the bbox horizontal lines CORNERS or ROUNDED_CORNERS style is used. :param line_height: Height of the bbox vertical lines when CORNERS or ROUNDED_CORNERS style is used. :param hide_label: Flag that indicates if the label should be hidden. :param label_position: Position of the label. :param label_padding: Padding of the label.
- Returns
self
- Parameters
thickness (Optional[int]) –
fill_transparency (Optional[float]) –
bbox_roundness (Optional[float]) –
bbox_style (Optional[depthai_sdk.visualize.configs.BboxStyle]) –
line_width (Optional[float]) –
line_height (Optional[float]) –
hide_label (Optional[bool]) –
label_position (Optional[depthai_sdk.visualize.configs.TextPosition]) –
label_padding (Optional[int]) –
- Return type
-
text
(font_face=None, font_color=None, font_transparency=None, font_scale=None, font_thickness=None, font_position=None, background_transparency=None, background_color=None, outline_color=None, line_type=None, auto_scale=None)¶ Configure how text will look like.
- Parameters
font_face (Optional[int]) – Font face (from cv2).
font_transparency (Optional[float]) – Font transparency.
font_scale (Optional[float]) – Font scale.
font_thickness (Optional[int]) – Font thickness.
font_position (Optional[depthai_sdk.visualize.configs.TextPosition]) – Font position.
background_transparency (Optional[float]) – Text background transparency.
background_color (Optional[Tuple[int, int, int]]) – Text background color.
outline_color (Optional[Tuple[int, int, int]]) – Outline color.
line_type (Optional[int]) – Line type (from cv2).
auto_scale (Optional[bool]) – Flag that indicates if the font scale should be automatically adjusted.
- Returns
self
- Return type
-
tracking
(max_length=None, deletion_lost_threshold=None, line_thickness=None, fading_tails=None, show_speed=None, line_color=None, line_type=None, bg_color=None)¶ Configure how tracking trails will look like.
- Parameters
max_length (Optional[int]) – Maximum length of the trail (in pixels).
deletion_lost_threshold (Optional[int]) – Number of consequent LOST statuses after which the trail is deleted.
line_thickness (Optional[int]) – Thickness of the line.
fading_tails (Optional[bool]) – Flag that indicates if the tails should fade.
show_speed (Optional[bool]) – Flag that indicates if the speed should be shown.
line_color (Optional[Tuple[int, int, int]]) – Color of the line.
line_type (Optional[int]) – Type of the line (from cv2).
bg_color (Optional[Tuple[int, int, int]]) – Text background color.
- Returns
self
- Return type
-
property
frame_shape
¶
-
close
()¶
-
-
class
depthai_sdk.
XoutFrames
(frames, fourcc=None)¶ Bases:
depthai_sdk.oak_outputs.xout.xout_base.XoutBase
Stream of frames. Single message, no syncing required.
Methods:
__init__
(frames[, fourcc])- param frames
StreamXout object.
set_fourcc
(fourcc)xstreams
()new_msg
(name, msg)-
__init__
(frames, fourcc=None)¶ - Parameters
frames (depthai_sdk.oak_outputs.xout.xout_base.StreamXout) – StreamXout object.
fourcc (Optional[str]) – Codec to use for encoding. If None, no encoding will be done.
-
set_fourcc
(fourcc)¶ - Parameters
fourcc (str) –
- Return type
depthai_sdk.oak_outputs.xout.xout_frames.XoutFrames
-
xstreams
()¶ - Return type
List[depthai_sdk.oak_outputs.xout.xout_base.StreamXout]
-
get_codec
()¶
-
depthai_sdk.
cosDist
(a, b)¶ Calculates cosine distance - https://en.wikipedia.org/wiki/Cosine_similarity
-
depthai_sdk.
createBlankFrame
(width, height, rgb_color=(0, 0, 0))¶ Create new image(numpy array) filled with certain color in RGB
- Parameters
- Returns
New frame filled with specified color
- Return type
-
depthai_sdk.
cropToAspectRatio
(frame, size)¶ Crop the frame to desired aspect ratio and then scales it down to desired size :param frame: Source frame that will be cropped :type frame: numpy.ndarray :param size: Desired frame size (width, height) :type size: tuple
- Returns
Cropped frame
- Return type
-
depthai_sdk.
dataclass
(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False)¶ Returns the same class as was passed in, with dunder methods added based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method function is added. If frozen is true, fields may not be assigned to after instance creation.
-
depthai_sdk.
downloadRecording
(name, keys)¶ - Parameters
- Return type
-
depthai_sdk.
downloadYTVideo
(video, output_dir=None)¶ Downloads a video from YouTube and returns the path to video. Will choose the best resolutuion if possible.
- Parameters
video (str) – URL to YouTube video
output_dir (pathlib.Path) – Path to directory where youtube video should be downloaded.
- Returns
Path to downloaded video file
- Return type
- Raises
RuntimeError – thrown when video download was unsuccessful
-
depthai_sdk.
field
(*, default=<dataclasses._MISSING_TYPE object>, default_factory=<dataclasses._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=None)¶ Return an object to identify dataclass fields.
default is the default value of the field. default_factory is a 0-argument function called to initialize a field’s value. If init is True, the field will be a parameter to the class’s __init__() function. If repr is True, the field will be included in the object’s repr(). If hash is True, the field will be included in the object’s hash(). If compare is True, the field will be used in comparison functions. metadata, if specified, must be a mapping which is stored but not otherwise examined by dataclass.
It is an error to specify both default and default_factory.
-
depthai_sdk.
frameNorm
(frame, bbox)¶ Mapps bounding box coordinates (0..1) to pixel values on frame
- Parameters
frame (numpy.ndarray) – Frame to which adjust the bounding box
bbox (list) – list of bounding box points in a form of
[x1, y1, x2, y2, ...]
- Returns
Bounding box points mapped to pixel values on frame
- Return type
-
depthai_sdk.
getAvailableRecordings
()¶ Get available (online) depthai-recordings. Returns list of available recordings and it’s size
-
depthai_sdk.
getDeviceInfo
(deviceId=None, debug=False)¶ Find a correct
depthai.DeviceInfo
object, either matching provideddeviceId
or selected by the user (if multiple devices available) Useful for almost every app where there is a possibility of multiple devices being connected simultaneously- Parameters
deviceId (str, optional) – Specifies device MX ID, for which the device info will be collected
- Returns
Object representing selected device info
- Return type
- Raises
RuntimeError – if no DepthAI device was found or, if
deviceId
was specified, no device with matching MX ID was foundValueError – if value supplied by the user when choosing the DepthAI device was incorrect
-
depthai_sdk.
getLocalRecording
(recording)¶ - Parameters
recording (str) –
- Return type
Optional[pathlib.Path]
-
depthai_sdk.
isUrl
(source)¶ - Parameters
source (Union[str, pathlib.Path]) –
- Return type
-
depthai_sdk.
loadModule
(path)¶ Loads module from specified path. Used internally e.g. to load a custom handler file from path
- Parameters
path (pathlib.Path) – path to the module to be loaded
- Returns
loaded module from provided path
- Return type
module
-
depthai_sdk.
merge
(source, destination)¶ Utility function to merge two dictionaries
a = { 'first' : { 'all_rows' : { 'pass' : 'dog', 'number' : '1' } } } b = { 'first' : { 'all_rows' : { 'fail' : 'cat', 'number' : '5' } } } print(merge(b, a)) # { 'first' : { 'all_rows' : { 'pass' : 'dog', 'fail' : 'cat', 'number' : '5' } } }
-
class
depthai_sdk.
partial
¶ Bases:
object
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
Attributes:
tuple of arguments to future partial calls
function object to use in future partial calls
dictionary of keyword arguments to future partial calls
-
args
¶ tuple of arguments to future partial calls
-
func
¶ function object to use in future partial calls
-
keywords
¶ dictionary of keyword arguments to future partial calls
-
-
depthai_sdk.
report_crash_dump
(device)¶ Report crash dump to Sentry if sentry is enabled and crash dump is available.
- Parameters
device (depthai.Device) – DepthAI device object that will be used to get crash dump.
- Return type
-
depthai_sdk.
resizeLetterbox
(frame, size)¶ Transforms the frame to meet the desired size, preserving the aspect ratio and adding black borders (letterboxing) :param frame: Source frame that will be resized :type frame: numpy.ndarray :param size: Desired frame size (width, height) :type size: tuple
- Returns
Resized frame
- Return type
-
depthai_sdk.
set_sentry_status
(status=True)¶ Set sentry status in config file.
-
depthai_sdk.
showProgress
(curr, max)¶ Print progressbar to stdout. Each call to this method will write exactly to the same line, so usually it’s used as
print("Staring processing") while processing: showProgress(currProgress, maxProgress) print(" done") # prints in the same line as progress bar and adds a new line print("Processing finished!")
-
depthai_sdk.
toPlanar
(arr, shape=None)¶ Converts interleaved frame into planar
- Parameters
arr (numpy.ndarray) – Interleaved frame
shape (tuple, optional) – If provided, the interleaved frame will be scaled to specified shape before converting into planar
- Returns
Planar frame
- Return type
-
depthai_sdk.
toTensorResult
(packet)¶ Converts NN packet to dict, with each key being output tensor name and each value being correctly reshaped and converted results array
Useful as a first step of processing NN results for custom neural networks
- Parameters
packet (depthai.NNData) – Packet returned from NN node
- Returns
Dict containing prepared output tensors
- Return type