oakutils.nodes package

Subpackages

Submodules

oakutils.nodes.color_camera module

Module for creating a color camera node in the pipeline.

Functions

create_color_camera

Creates a pipeline for the color camera.

oakutils.nodes.color_camera.create_color_camera(pipeline: ~depthai.Pipeline, resolution: ~depthai.ColorCameraProperties.SensorResolution = <SensorResolution.THE_1080_P: 0>, preview_size: tuple[int, int] = (640, 480), fps: int = 15, brightness: int = 0, saturation: int = 0, contrast: int = 0, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_target_size: tuple[int, int] | None = None, isp_scale: tuple[int, int] | None = None, isp_3a_fps: int | None = None, input_queue_size: int | None = None, *, set_interleaved: bool | None = None, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) ColorCamera

Use to create a pipeline for the color camera.

Note: setVideoSize, setStillSize are both automatically called using the tuple from get_tuple_from_color_sensor_resolution.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the color camera to

  • resolution (dai.ColorCameraProperties.SensorResolution, optional) – The resolution of the color camera, by default dai.ColorCameraProperties.SensorResolution.THE_1080_P

  • preview_size (Tuple[int, int], optional) – The size of the preview, by default (640, 480)

  • set_interleaved (bool, optional) – Whether to set the color camera to interleaved or not, by default False

  • fps (int, optional) – The fps of the color camera, by default 30

  • brightness (int, optional) – The brightness of the mono camera, by default 0 Valid values are -10 … 10

  • saturation (int, optional) – The saturation of the mono camera, by default 0 Valid values are -10 … 10

  • contrast (int, optional) – The contrast of the mono camera, by default 0 Valid values are -10 … 10

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1 Valid values are 0 … 4

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • isp_target_size (Optional[Tuple[int, int]], optional) – Target size for scaled frames from ISP (width, height), by default None Allows scaling of the cameras frames on-board the OAK to any size Works together with the isp_scale parameter

  • isp_scale (Optional[Tuple[int, int]], optional) – The isp scale of the color camera, by default None Allows scaling of the cameras frames on-board the OAK to any size not just the natively supported resolutions. Works together with the isp_target_size parameter

  • isp_3a_fps (Optional[int], optional) – The fps of how often the 3a algorithms will run, by default None Reducing this can help with performance onboard the device. A common value to reduce CPU usage on device is 15. Reference: https://docs.luxonis.com/projects/api/en/latest/tutorials/debugging/#resource-debugging

  • input_queue_size (int, optional) – The size of the input queue, by default None

  • input_reuse (bool, optional) – Whether to reuse inputs or not, by default None

  • input_blocking (bool, optional) – Whether to block the input or not, by default None

  • input_wait_for_message (bool, optional) – Whether to wait for a message or not, by default None

Returns:

The color camera node

Return type:

dai.node.ColorCamera

Raises:
  • ValueError – If the fps is not between 0 and 60

  • ValueError – If the brightness is not between -10 and 10

  • ValueError – If the saturation is not between -10 and 10

  • ValueError – If the contrast is not between -10 and 10

  • ValueError – If the sharpness is not between 0 and 4

  • ValueError – If the luma_denoise is not between 0 and 4

  • ValueError – If the chroma_denoise is not between 0 and 4

oakutils.nodes.image_manip module

Module for creating image manip nodes.

Functions

create_image_manip

Creates an image manip node.

oakutils.nodes.image_manip.create_image_manip(pipeline: Pipeline, input_link: Output, frame_type: Type, center_crop: tuple[float, float] | None = None, color_map: Colormap | None = None, crop_rect: tuple[float, float, float, float] | None = None, crop_rotated_rect: tuple[RotatedRect, bool] | None = None, resize: tuple[int, int] | None = None, resize_thumbnail: tuple[int, int, int, int, int] | None = None, rotation_degrees: float | None = None, rotation_radians: float | None = None, warp_border_fill_color: tuple[int, int, int] | None = None, warp_transform_four_points: tuple[list[Point2f], bool] | None = None, warp_transform_matrix_3x3: list[float] | None = None, input_queue_size: int | None = None, *, horizontal_flip: bool | None = None, keep_aspect_ratio: bool | None = None, vertical_flip: bool | None = None, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) ImageManip

Use to create an image manip node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the image manip node to.

  • input_link (dai.node.XLinkOut) – The input link to connect to the image manip node. Example: cam_rgb.preview.link Explicitly pass in the link as a non-called function.

  • frame_type (dai.RawImgFrame.Type) – The frame type to output.

  • center_crop (Optional[Tuple[float, float]], optional) – The center crop to apply, by default None

  • color_map (Optional[dai.Colormap], optional) – The color map to apply, by default None

  • crop_rect (Optional[Tuple[float, float, float, float]], optional) – The crop rect to apply, by default None

  • crop_rotated_rect (Optional[Tuple[dai.RotatedRect, bool]], optional) – The crop rotated rect to apply, by default None

  • horizontal_flip (Optional[bool], optional) – Whether to horizontally flip the image, by default None

  • keep_aspect_ratio (Optional[bool], optional) – Whether to keep the aspect ratio, by default None

  • resize (Optional[Tuple[int, int]], optional) – The resize to apply, by default None

  • resize_thumbnail (Optional[Tuple[int, int, int, int, int]], optional) – The resize thumbnail to apply, by default None

  • rotation_degrees (Optional[float], optional) – The rotation in degrees to apply, by default None

  • rotation_radians (Optional[float], optional) – The rotation in radians to apply, by default None

  • vertical_flip (Optional[bool], optional) – Whether to vertically flip the image, by default None

  • warp_border_fill_color (Optional[Tuple[int, int, int]], optional) – The warp border fill color to apply, by default None

  • warp_transform_four_points (Optional[Tuple[List[dai.Point2f], bool]], optional) – The warp transform four points to apply, by default None

  • warp_transform_matrix_3x3 (Optional[List[float]], optional) – The warp transform matrix 3x3 to apply, by default None

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The image manip node

Return type:

dai.node.ImageManip

oakutils.nodes.imu module

Module for creating IMU nodes.

Functions

create_imu

Creates a node for the IMU.

oakutils.nodes.imu.create_imu(pipeline: Pipeline, accelerometer_rate: int = 400, gyroscope_rate: int = 400, batch_report_threshold: int = 1, max_batch_reports: int = 10, *, enable_accelerometer_raw: bool | None = None, enable_accelerometer: bool | None = None, enable_linear_acceleration: bool | None = None, enable_gravity: bool | None = None, enable_gyroscope_raw: bool | None = None, enable_gyroscope_calibrated: bool | None = None, enable_gyroscope_uncalibrated: bool | None = None, enable_magnetometer_raw: bool | None = None, enable_magnetometer_calibrated: bool | None = None, enable_magnetometer_uncalibrated: bool | None = None, enable_rotation_vector: bool | None = None, enable_game_rotation_vector: bool | None = None, enable_geomagnetic_rotation_vector: bool | None = None, enable_arvr_stabilized_rotation_vector: bool | None = None, enable_arvr_stabilized_game_rotation_vector: bool | None = None) IMU

Use to create a node for the IMU.

Note: Sensors which use both gyroscope and accelerometer will default to slower rate.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the IMU to

  • accelerometer_rate (int, optional) – The rate of the accelerometer, by default 400 Options are 100, 200, 400

  • gyroscope_rate (int, optional) – The rate of the gyroscope, by default 400 Options are 125, 250, 400

  • batch_report_threshold (int, optional) – The batch report threshold, by default 1

  • max_batch_reports (int, optional) – The maximum batch reports, by default 10

  • enable_accelerometer_raw (bool, optional) – Enable accelerometer raw, by default False

  • enable_accelerometer (bool, optional) – Enable accelerometer, by default False

  • enable_linear_acceleration (bool, optional) – Enable linear acceleration, by default False

  • enable_gravity (bool, optional) – Enable gravity, by default False

  • enable_gyroscope_raw (bool, optional) – Enable gyroscope raw, by default False

  • enable_gyroscope_calibrated (bool, optional) – Enable gyroscope calibrated, by default False

  • enable_gyroscope_uncalibrated (bool, optional) – Enable gyroscope uncalibrated, by default False

  • enable_magnetometer_raw (bool, optional) – Enable magnetometer raw, by default False

  • enable_magnetometer_calibrated (bool, optional) – Enable magnetometer calibrated, by default False

  • enable_magnetometer_uncalibrated (bool, optional) – Enable magnetometer uncalibrated, by default False

  • enable_rotation_vector (bool, optional) – Enable rotation vector, by default False

  • enable_game_rotation_vector (bool, optional) – Enable game rotation vector, by default False

  • enable_geomagnetic_rotation_vector (bool, optional) – Enable geomagnetic rotation vector, by default False

  • enable_arvr_stabilized_rotation_vector (bool, optional) – Enable arvr stabilized rotation vector, by default False

  • enable_arvr_stabilized_game_rotation_vector (bool, optional) – Enable arvr stabilized game rotation vector, by default False

Returns:

The IMU node

Return type:

dai.node.IMU

Raises:
  • ValueError – If accelerometer_rate is not one of the following: 100, 200, 400

  • ValueError – If gyroscope_rate is not one of the following: 125, 250, 400

References

https://docs.luxonis.com/projects/api/en/latest/components/nodes/imu/

oakutils.nodes.mobilenet_detection_network module

Module for creating and using depthai Mobilenet Detection Network nodes.

Functions

create_mobilenet_detection_network

Use to create a mobilenet detection network node

oakutils.nodes.mobilenet_detection_network.create_mobilenet_detection_network(pipeline: dai.Pipeline, input_link: dai.Node.Output, blob_path: Path, confidence_threshold: float | None = None, bounding_box_scale_factor: float = 0.5, depth_input_link: dai.Node.Output | None = None, lower_depth_threshold: int = 100, upper_depth_threshold: int = 20000, num_inference_threads: int = 2, num_nce_per_inference_thread: int | None = None, num_pool_frames: int | None = None, *, mobilenet_data: MobilenetData | None = None, spatial: bool | None = None, input_blocking: bool | None = None) MobileNetDectionNetwork

Use to create a Mobilenet Detection Network node.

Should pass either a single MobilenetData object to the function OR pass all the parameters to the function. If using the parameters, then the MobilenetData object must be set to None. The yolo_data: MobilenetData is required as a keyword only parameter. If altering parameters at runtime, then parameters are recommended. Otherwise, the MobilenetData object is recommended. This function can be used to create either a Mobilenet Detection Network node or a Mobilenet Spatial Detection Network node simply by changing the spatial parameter to True.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the Mobilenet Detection Network node to

  • input_link (dai.Node.Output) – The input link to connect to the Mobilenet Detection Network node Example: cam_rgb.preview

  • blob_path (str) – The path to the blob file

  • mobilenet_data (MobilenetData, optional) – The Mobilenet Detection Network data, by default None

  • confidence_threshold (float) – The confidence threshold

  • bounding_box_scale_factor (float, optional) – The bounding box scale factor, by default 0.5

  • spatial (bool, optional) – Whether or not to use spatial coordinates, by default None If None, then False is used

  • depth_input_link (dai.Node.Output, optional) – The depth input link to connect to the Mobilenet Spatial Detection Network node Example: stereo.depth Must be set if spatial is True

  • lower_depth_threshold (float, optional) – The lower depth threshold for detections. By default 100 mm Only used if spatial is True.

  • upper_depth_threshold (float, optional) – The upper depth threshold for detections. By default 20000 mm Only used if spatial is True

  • num_inference_threads (int, optional) – The number of inference threads, by default 2

  • num_nce_per_inference_thread (int, optional) – The number of NCEs per inference thread, by default None

  • num_pool_frames (int, optional) – The number of pool frames, by default None

  • input_blocking (bool, optional) – Whether or not to use input blocking, by default None If None, then False is used

Returns:

The Mobilenet Detection Network node

Return type:

dai.Node.MobilenetDetectionNetwork | dai.Node.MobilenetSpatialDetectionNetwork

Raises:

ValueError – If mobilenet_data is None and confidence_threshold is None If spatial is True and depth_input_link is None

oakutils.nodes.mono_camera module

Module for creating mono camera nodes.

Functions

create_mono_camera

Creates a pipeline for the mono camera.

create_left_right_cameras

Wrapper function for creating the left and right mono cameras.

oakutils.nodes.mono_camera.create_left_right_cameras(pipeline: ~depthai.Pipeline, resolution: ~depthai.MonoCameraProperties.SensorResolution = <SensorResolution.THE_400_P: 2>, fps: int = 60, brightness: int = 0, saturation: int = 0, contrast: int = 0, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_3a_fps: int | None = None, input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) tuple[MonoCamera, MonoCamera]

Use to create the left and right mono cameras.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the two mono cameras to

  • resolution (dai.MonoCameraProperties.SensorResolution, optional) – The resolution of the mono camera, by default dai.MonoCameraProperties.SensorResolution.THE_400_P

  • fps (int, optional) – The fps of the mono camera, by default 60

  • brightness (int, optional) – The brightness of the mono camera, by default 0 Valid values are -10 … 10

  • saturation (int, optional) – The saturation of the mono camera, by default 0 Valid values are -10 … 10

  • contrast (int, optional) – The contrast of the mono camera, by default 0 Valid values are -10 … 10

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1 Valid values are 0 … 4

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • isp_3a_fps (Optional[int], optional) – The fps of how often the 3a algorithms will run, by default None Reducing this can help with performance onboard the device. A common value to reduce CPU usage on device is 15. Reference: https://docs.luxonis.com/projects/api/en/latest/tutorials/debugging/#resource-debugging

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

  • dai.node.MonoCamera – The left mono camera node

  • dai.node.XLinkOut – The output node for the left mono camera

  • dai.node.MonoCamera – The right mono camera node

  • dai.node.XLinkOut – The output node for the right mono camera

oakutils.nodes.mono_camera.create_mono_camera(pipeline: ~depthai.Pipeline, socket: ~depthai.CameraBoardSocket, resolution: ~depthai.MonoCameraProperties.SensorResolution = <SensorResolution.THE_400_P: 2>, fps: int = 15, brightness: int = 0, saturation: int = 0, contrast: int = 0, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_3a_fps: int | None = None, input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) MonoCamera

Use to create a pipeline for the mono camera.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the mono camera to

  • socket (dai.CameraBoardSocket) – The socket the camera is plugged into

  • resolution (dai.MonoCameraProperties.SensorResolution, optional) – The resolution of the mono camera, by default dai.MonoCameraProperties.SensorResolution.THE_400_P

  • fps (int, optional) – The fps of the mono camera, by default 60

  • brightness (int, optional) – The brightness of the mono camera, by default 0 Valid values are -10 … 10

  • saturation (int, optional) – The saturation of the mono camera, by default 0 Valid values are -10 … 10

  • contrast (int, optional) – The contrast of the mono camera, by default 0 Valid values are -10 … 10

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1 Valid values are 0 … 4

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • isp_3a_fps (Optional[int], optional) – The fps of how often the 3a algorithms will run, by default None Reducing this can help with performance onboard the device. A common value to reduce CPU usage on device is 15. Reference: https://docs.luxonis.com/projects/api/en/latest/tutorials/debugging/#resource-debugging

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The mono camera node

Return type:

dai.node.MonoCamera

Raises:
  • ValueError – If the socket is not LEFT or RIGHT

  • ValueError – If the fps is not between 0 and 120

  • ValueError – If the brightness is not between -10 and 10

  • ValueError – If the saturation is not between -10 and 10

  • ValueError – If the contrast is not between -10 and 10

  • ValueError – If the sharpness is not between 0 and 4

  • ValueError – If the luma_denoise is not between 0 and 4

  • ValueError – If the chroma_denoise is not between 0 and 4

oakutils.nodes.neural_network module

Module for creating neural network nodes.

Functions

create_neural_network

Creates a neural network node.

get_nn_frame

Takes the raw data output from a neural network execution and converts it to a frame usable by cv2.

get_nn_bgr_frame

Takes the raw data output from a neural network execution and converts it to a BGR frame usable by cv2.

get_nn_gray_frame

Takes the raw data output from a neural network execution and converts it to a grayscale frame usable by cv2.

get_nn_point_cloud_buffer

Takes the raw data output from a neural network execution and converts it to a point cloud buffer.

oakutils.nodes.neural_network.create_neural_network(pipeline: dai.Pipeline, input_link: dai.Node.Output | list[dai.Node.Output], blob_path: Path, input_names: str | list[str] | None = None, input_sizes: int | list[int] | None = None, num_inference_threads: int = 2, num_nce_per_inference_thread: int | None = None, num_pool_frames: int | None = None, *, reuse_messages: bool | list[bool | None] | None = None, input_blocking: bool | list[bool] | None = None) dai.node.NeuralNetwork

Use to create a neural network node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the neural network to

  • input_link (Union[dai.Node.Output, list[dai.Node.Output]]) – The input link to connect to the image manip node or, if there are multiple input links, an iterable of input links. Example: cam_rgb.preview or (cam_rgb.preview, stereo.depth)

  • blob_path (Path) – The path to the blob file to use for the neural network.

  • input_names (Optional[Union[str, list[str]]], optional) – The names of the input links, by default None Must be the same length as input_link if a list

  • reuse_messages (Optional[Union[bool, list[bool]]], optional) – Whether to reuse messages, by default None Must be the same length as input_link if a list Values may be None if the input link does not need a value set

  • input_sizes (Optional[Union[int, list[int]]], optional) – The size of the input queue, by default None Must be the same length as input_link if a list

  • input_blocking (Optional[Union[bool, list[bool]]], optional) – Whether the input queue is blocking, by default None Must be the same length as input_link if a list

  • num_inference_threads (int, optional) – The number of inference threads, by default 2

  • num_nce_per_inference_thread (Optional[int], optional) – The number of NCEs per inference thread, by default None NCE: Neural Compute Engine

  • num_pool_frames (Optional[int], optional) – The number of pool frames, by default None

Returns:

The neural network node

Return type:

dai.node.NeuralNetwork

Raises:
  • ValueError – If input_link is an iterable and input_names is None If input_link and input_names are iterables and are not the same length If input_link and reuse_messages are iterables and are not the same length

  • TypeError – If input_link is an iterable and input_names is not an iterable If input_link is an iterable and reuse_messages is not an iterable

oakutils.nodes.neural_network.get_nn_bgr_frame(data: ndarray | NNData, frame_size: tuple[int, int] = (640, 480), resize_factor: float | None = None, normalization: float | Callable | None = None) ndarray

Use to convert the raw data output from a neural network execution and return a BGR frame.

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • frame_size (tuple[int, int], optional) – The size of the frame, by default (640, 480)

  • resize_factor (Optional[float], optional) – The resize factor to apply to the frame, by default None

  • normalization (Optional[float, Callable], optional) – The normalization to apply to the frame, by default None If a float then the frame is multiplied by the float. If a callable then the frame is passed to the callable and set to the return value. If resize_factor is less than 1.0, then normalization is applied after resizing.

Returns:

BGR frame usable by cv2.

Return type:

np.ndarray

oakutils.nodes.neural_network.get_nn_data(data: NNData, reshape_to: tuple[int, ...] | None = None, scale: float | None = None, astype: type | None = None, *, use_first_layer: bool | None = None) ndarray

Use to get arbitrary shaped data from a neural network execution.

This function is used for getting an arbitrarily shaped data from a custom neural network execution, and can handle U8 input models. The data retrieved, reshaped, type cast, then scaled in that order. If the NN returns a single element, an example could be: get_nn_data(nndata, reshape_to(1, 1))[0] The (1, 1) shape is important since all returned tensors have a starting dimension of 1. If the model utilizes U8 inputs, then an example could be: get_nn_data(nndata, use_first_layer=True)

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • reshape_to (Optional[tuple[int, ...]], optional) – The shape to reshape the data to, by default None

  • scale (Optional[float], optional) – The scale to apply to the data, by default None

  • astype (Optional[type], optional) – The type to cast the data to, by default None

  • use_first_layer (Optional[bool], optional) – Whether to use the first layer of the data, by default None If None, then False is used and instead getData is used This should be set to true for networks which take U8 input. The U8 input process means that the first layer fp16 data is the correct output and not the entire buffer.

Returns:

The data from the neural network execution.

Return type:

np.ndarray

oakutils.nodes.neural_network.get_nn_frame(data: ndarray | NNData, channels: int, frame_size: tuple[int, int] = (640, 480), resize_factor: float | None = None, normalization: float | Callable[[ndarray], ndarray] | None = None, rescale_offset: float = 0.5, rescale_multiplier: float = 255.0, *, rescale: bool | None = None, swap_rb: bool | None = None) ndarray

Use to convert the raw data output from a neural network execution and return a frame.

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • channels (int) – The number of channels in the frame.

  • frame_size (tuple[int, int], optional) – The size of the frame, by default (640, 480) This is the size of the frame before any resizing is applied. If frame_size is incorrect, an error will occur.

  • resize_factor (Optional[float], optional) – The resize factor to apply to the frame, by default None

  • normalization (Optional[float, Callable[[np.ndarray], np.ndarray]], optional) – The normalization to apply to the frame, by default None If a float then the frame is multiplied by the float. If a callable then the frame is passed to the callable and set to the return value. If resize_factor is less than 1.0, then normalization is applied after resizing.

  • rescale_offset (float, optional) – The offset to apply to the frame once it has been received, but before other operations are applied such as resizing or normalization. By default this value is 0.5 to convert from [-0.5, 0.5] to [0, 1].

  • rescale_multiplier (float, optional) – The multiplier to apply to the frame once it has been received, but before other operations are applied such as resizing or normalization. By default this value is 255.0 to convert from [0.0, 1.0] to [0, 255].

  • swap_rb (Optional[bool], optional) – Whether to swap the red and blue channels, by default None If None, then False is used

  • rescale (Optional[bool], optional) – Whether or not to perform rescaling to convert from one data range to another. By default None, so not rescaling occurs. When a rescale is performed, the offset is added then the multiplier is applied. The default values for offset and multiplier convert from [-0.5, 0.5] to [0, 255].

Returns:

Frame usable by cv2.

Return type:

np.ndarray

oakutils.nodes.neural_network.get_nn_gray_frame(data: ndarray | NNData, frame_size: tuple[int, int] = (640, 480), resize_factor: float | None = None, normalization: float | Callable | None = None) ndarray

Use to convert the raw data output from a neural network execution and return a grayscale frame.

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • frame_size (tuple[int, int], optional) – The size of the frame, by default (640, 480)

  • resize_factor (Optional[float], optional) – The resize factor to apply to the frame, by default None

  • normalization (Optional[float, Callable], optional) – The normalization to apply to the frame, by default None If a float then the frame is multiplied by the float. If a callable then the frame is passed to the callable and set to the return value. If resize_factor is less than 1.0, then normalization is applied after resizing.

Returns:

Grayscale frame usable by cv2.

Return type:

np.ndarray

oakutils.nodes.stereo_depth module

Module for creating stereo depth nodes.

Functions

create_stereo_depth

Creates a stereo depth given only a pipeline object.

create_stereo_depth_from_mono_cameras

Creates a stereo depth node from a pipeline and two mono cameras.

oakutils.nodes.stereo_depth.create_stereo_depth(pipeline: ~depthai.Pipeline, resolution: ~depthai.MonoCameraProperties.SensorResolution = <SensorResolution.THE_400_P: 2>, fps: int = 15, brightness: int = 1, saturation: int = 1, contrast: int = 1, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_3a_fps: int | None = None, input_queue_size: int | None = None, preset: ~depthai.node.StereoDepth.PresetMode = <PresetMode.HIGH_DENSITY: 1>, align_socket: ~depthai.CameraBoardSocket = <CameraBoardSocket.CAM_B: 1>, confidence_threshold: int = 255, rectify_edge_color: int = 0, median_filter: ~depthai.MedianFilter = <MedianFilter.KERNEL_7x7: 7>, subpixel_fractional_bits: int = 3, min_brightness: int = 0, max_brightness: int = 255, decimation_factor: int = 1, decimation_mode: ~depthai.RawStereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode = <DecimationMode.NON_ZERO_MEAN: 2>, spatial_alpha: float = 0.5, spatial_delta: int = 0, spatial_radius: int = 2, spatial_iterations: int = 1, speckle_range: int = 20, temporal_alpha: float = 0.5, temporal_delta: int = 0, temporal_mode: ~depthai.RawStereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode = <PersistencyMode.VALID_2_IN_LAST_3: 2>, threshold_min_range: int = 200, threshold_max_range: int = 25000, bilateral_sigma: int = 1, stereo_input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None, lr_check: bool | None = None, extended_disparity: bool | None = None, subpixel: bool | None = None, enable_spatial_filter: bool | None = None, enable_speckle_filter: bool | None = None, enable_temporal_filter: bool | None = None, stereo_input_reuse: bool | None = None, stereo_input_blocking: bool | None = None, stereo_input_wait_for_message: bool | None = None) tuple[StereoDepth, MonoCamera, MonoCamera]

Use to create a stereo depth given only a pipeline object.

Note: Creates mono cameras for the left and right cameras using the create_left_right_cameras function.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the stereo depth node to

  • resolution (dai.MonoCameraProperties.SensorResolution, optional) – The resolution of the mono camera, by default dai.MonoCameraProperties.SensorResolution.THE_400_P

  • fps (int, optional) – The fps of the mono camera, by default 60

  • brightness (int, optional) – The brightness of the mono camera, by default 1

  • saturation (int, optional) – The saturation of the mono camera, by default 1

  • contrast (int, optional) – The contrast of the mono camera, by default 1

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1

  • isp_3a_fps (int, optional) – The 3a fps of the mono camera, by default None

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

  • left (dai.node.MonoCamera) – The left mono camera node

  • right (dai.node.MonoCamera) – The right mono camera node

  • preset (dai.node.StereoDepth.PresetMode, optional) – The preset mode of the stereo depth node, by default dai.node.StereoDepth.PresetMode.HIGH_DENSITY

  • align_socket (dai.CameraBoardSocket, optional) – The camera board socket of the stereo depth node, by default dai.CameraBoardSocket.LEFT

  • confidence_threshold (int, optional) – The confidence threshold of the stereo depth node, by default 200

  • rectify_edge_color (int, optional) – The rectify edge color of the stereo depth node, by default 0

  • median_filter (dai.StereoDepthProperties.MedianFilter, optional) – The median filter of the stereo depth node, by default dai.StereoDepthProperties.MedianFilter.KERNEL_7x7

  • lr_check (bool, optional) – The left right check of the stereo depth node, by default True

  • extended_disparity (bool, optional) – The extended disparity of the stereo depth node, by default False

  • subpixel (bool, optional) – The subpixel of the stereo depth node, by default False

  • subpixel_fractional_bits (int, optional) – The subpixel fractional bits of the stereo depth node, by default 3

  • min_brightness (int, optional) – The min brightness of the stereo depth node, by default 0

  • max_brightness (int, optional) – The max brightness of the stereo depth node, by default 255

  • decimation_factor (int, optional) – The decimation factor of the stereo depth node, by default 1

  • decimation_mode (dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode, optional) – The decimation mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode.NON_ZERO_MEAN

  • enable_spatial_filter (bool, optional) – The enable spatial filter of the stereo depth node, by default False

  • spatial_alpha (float, optional) – The spatial alpha of the stereo depth node, by default 0.5

  • spatial_delta (int, optional) – The spatial delta of the stereo depth node, by default 0

  • spatial_radius (int, optional) – The spatial radius of the stereo depth node, by default 2

  • spatial_iterations (int, optional) – The spatial iterations of the stereo depth node, by default 1

  • enable_speckle_filter (bool, optional) – The enable speckle filter of the stereo depth node, by default False

  • speckle_range (int, optional) – The speckle range of the stereo depth node, by default 20

  • enable_temporal_filter (bool, optional) – The enable temporal filter of the stereo depth node, by default False

  • temporal_alpha (float, optional) – The temporal alpha of the stereo depth node, by default 0.5

  • temporal_delta (int, optional) – The temporal delta of the stereo depth node, by default 0

  • temporal_mode (dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode, optional) – The temporal mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode.VALID_2_IN_LAST_3

  • threshold_min_range (int, optional) – The threshold min range of the stereo depth node, by default 200

  • threshold_max_range (int, optional) – The threshold max range of the stereo depth node, by default 25000

  • bilateral_sigma (int, optional) – The bilateral sigma of the stereo depth node, by default 1

  • stereo_input_queue_size (int, optional) – The queue size of the input, by default None

  • stereo_input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • stereo_input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • stereo_input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

  • dai.node.StereoDepth – The stereo depth node

  • dai.node.MonoCamera – The left mono camera node

  • dai.node.MonoCamera – The right mono camera node

oakutils.nodes.stereo_depth.create_stereo_depth_from_mono_cameras(pipeline: ~depthai.Pipeline, left: ~depthai.node.MonoCamera, right: ~depthai.node.MonoCamera, preset: ~depthai.node.StereoDepth.PresetMode = <PresetMode.HIGH_DENSITY: 1>, align_socket: ~depthai.CameraBoardSocket = <CameraBoardSocket.CAM_B: 1>, confidence_threshold: int = 255, rectify_edge_color: int = 0, median_filter: ~depthai.MedianFilter = <MedianFilter.KERNEL_7x7: 7>, subpixel_fractional_bits: int = 3, min_brightness: int = 0, max_brightness: int = 255, decimation_factor: int = 1, decimation_mode: ~depthai.RawStereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode = <DecimationMode.NON_ZERO_MEAN: 2>, spatial_alpha: float = 0.5, spatial_delta: int = 0, spatial_radius: int = 2, spatial_iterations: int = 1, speckle_range: int = 20, temporal_alpha: float = 0.5, temporal_delta: int = 0, temporal_mode: ~depthai.RawStereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode = <PersistencyMode.VALID_2_IN_LAST_3: 2>, threshold_min_range: int = 200, threshold_max_range: int = 25000, bilateral_sigma: int = 1, input_queue_size: int | None = None, *, lr_check: bool | None = None, extended_disparity: bool | None = None, subpixel: bool | None = None, enable_spatial_filter: bool | None = None, enable_speckle_filter: bool | None = None, enable_temporal_filter: bool | None = None, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) StereoDepth

Use to create a stereo depth node from a pipeline and two mono cameras.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the stereo depth node to

  • left (dai.node.MonoCamera) – The left mono camera node

  • right (dai.node.MonoCamera) – The right mono camera node

  • preset (dai.node.StereoDepth.PresetMode, optional) – The preset mode of the stereo depth node, by default dai.node.StereoDepth.PresetMode.HIGH_DENSITY

  • align_socket (dai.CameraBoardSocket, optional) – The camera board socket of the stereo depth node, by default dai.CameraBoardSocket.LEFT

  • confidence_threshold (int, optional) – The confidence threshold of the stereo depth node, by default 200

  • rectify_edge_color (int, optional) – The rectify edge color of the stereo depth node, by default 0

  • median_filter (dai.StereoDepthProperties.MedianFilter, optional) – The median filter of the stereo depth node, by default dai.StereoDepthProperties.MedianFilter.KERNEL_7x7

  • lr_check (bool, optional) – The left right check of the stereo depth node, by default True

  • extended_disparity (bool, optional) – The extended disparity of the stereo depth node, by default False

  • subpixel (bool, optional) – The subpixel of the stereo depth node, by default False

  • subpixel_fractional_bits (int, optional) – The subpixel fractional bits of the stereo depth node, by default 3

  • min_brightness (int, optional) – The min brightness of the stereo depth node, by default 0

  • max_brightness (int, optional) – The max brightness of the stereo depth node, by default 255

  • decimation_factor (int, optional) – The decimation factor of the stereo depth node, by default 1 Valid values are 1, 2, 3, 4

  • decimation_mode (dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode, optional) – The decimation mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode.NON_ZERO_MEAN

  • enable_spatial_filter (bool, optional) – The enable spatial filter of the stereo depth node, by default False

  • spatial_alpha (float, optional) – The spatial alpha of the stereo depth node, by default 0.5 Valid values are 0.0 - 1.0

  • spatial_delta (int, optional) – The spatial delta of the stereo depth node, by default 0

  • spatial_radius (int, optional) – The spatial radius of the stereo depth node, by default 2

  • spatial_iterations (int, optional) – The spatial iterations of the stereo depth node, by default 1

  • enable_speckle_filter (bool, optional) – The enable speckle filter of the stereo depth node, by default False

  • speckle_range (int, optional) – The speckle range of the stereo depth node, by default 20

  • enable_temporal_filter (bool, optional) – The enable temporal filter of the stereo depth node, by default False

  • temporal_alpha (float, optional) – The temporal alpha of the stereo depth node, by default 0.5 Valid values are 0.0 - 1.0

  • temporal_delta (int, optional) – The temporal delta of the stereo depth node, by default 0

  • temporal_mode (dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode, optional) – The temporal mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode.VALID_2_IN_LAST_3

  • threshold_min_range (int, optional) – The threshold min range of the stereo depth node, by default 200

  • threshold_max_range (int, optional) – The threshold max range of the stereo depth node, by default 25000

  • bilateral_sigma (int, optional) – The bilateral sigma of the stereo depth node, by default 1

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The stereo depth node

Return type:

dai.node.StereoDepth

Raises:
  • ValueError – If spatial_alpha is not between 0.0 and 1.0

  • ValueError – If temporal_alpha is not between 0.0 and 1.0

  • ValueError – If decimation_factor is not 1,2,3,4

oakutils.nodes.xin module

Module for creating and using depthai Xin nodes.

Functions

create_xin

Use to create an xin node

oakutils.nodes.xin.create_xin(pipeline: dai.Pipeline, stream_name: str, max_data_size: int = 6144000) dai.node.XLinkIn

Use to create an XLinkIn node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the XLinkIn node to

  • stream_name (str) – The name of the stream

  • max_data_size (int, optional) – The maximum data size, by default 6144000 bytes

Returns:

The XLinkIn node

Return type:

dai.node.XLinkIn

oakutils.nodes.xout module

Module for creating and using depthai Xout nodes.

Functions

create_xout

Use to create an xout node

oakutils.nodes.xout.create_xout(pipeline: dai.Pipeline, input_link: dai.Node.Output, stream_name: str, input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) dai.node.XLinkOut

Use to create an XLinkOut node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the XLinkOut node to

  • input_link (dai.Node.Output) – The input link to connect to the XLinkOut node Example: cam_rgb.preview

  • stream_name (str) – The name of the stream

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The XLinkOut node

Return type:

dai.node.XLinkOut

oakutils.nodes.yolo_detection_network module

Module for creating and using depthai Yolo Detection Network nodes.

Functions

create_yolo_detection_network

Use to create a yolo detection network node

oakutils.nodes.yolo_detection_network.create_yolo_detection_network(pipeline: dai.Pipeline, input_link: dai.Node.Output, blob_path: Path, confidence_threshold: float | None = None, iou_threshold: float | None = None, num_classes: int | None = None, coordinate_size: int | None = None, anchors: list[float] | None = None, anchor_masks: dict[str, list[int]] | None = None, depth_input_link: dai.Node.Output | None = None, lower_depth_threshold: int = 100, upper_depth_threshold: int = 20000, num_inference_threads: int = 2, num_nce_per_inference_thread: int | None = None, num_pool_frames: int | None = None, *, yolo_data: YolomodelData | None = None, spatial: bool | None = None, input_blocking: bool | None = None) YoloDectionNetwork

Use to create a Yolo Detection Network node.

Should pass either a single YoloModelData object to the function OR pass all the parameters to the function. If using the parameters, then the YoloModelData object must be set to None. The yolo_data: YoloModelData is required as a keyword only parameter. If altering parameters at runtime, then parameters are recommended. Otherwise, the YoloModelData object is recommended. This function can be used to create either a Yolo Detection Network node or a Yolo Spatial Detection Network node simply by changing the spatial parameter in the YoloModelData or parameters to True. Corresponding, depth_input_link must be set if spatial is True.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the Yolo Detection Network node to

  • input_link (dai.Node.Output) – The input link to connect to the Yolo Detection Network node Example: cam_rgb.preview

  • blob_path (str) – The path to the blob file

  • yolo_data (YolomodelData, optional) – The Yolo model data, by default None If None, then the other parameters must be set

  • confidence_threshold (float, optional) – The confidence threshold, by default None

  • iou_threshold (float) – The IOU threshold, by default None

  • num_classes (int) – The number of classes the model detects, by default None

  • coordinate_size (int) – The coordinate size of each detection, by default None

  • anchors (list[int]) – The anchors for the yolo model, by default None

  • anchor_masks (dict[str, list[int]]) – The anchor masks for the yolo model, by default None

  • spatial (bool, optional) – Whether or not to use spatial coordinates, by default None If None, then False is used

  • depth_input_link (dai.Node.Output, optional) – The depth input link to connect to the Yolo Spatial Detection Network node Example: stereo.depth Must be set if spatial is True

  • lower_depth_threshold (float, optional) – The lower depth threshold for detections. By default 100 mm Only used if spatial is True.

  • upper_depth_threshold (float, optional) – The upper depth threshold for detections. By default 20000 mm Only used if spatial is True

  • num_inference_threads (int, optional) – The number of inference threads, by default 2

  • num_nce_per_inference_thread (int, optional) – The number of NCEs per inference thread, by default None

  • num_pool_frames (int, optional) – The number of pool frames, by default None

  • input_blocking (bool, optional) – Whether or not to use input blocking, by default None If None, then False is used

Returns:

The Yolo Detection Network node

Return type:

dai.Node.YoloDetectionNetwork | dai.Node.YoloSpatialDetectionNetwork

Raises:

ValueError – If yolo_data is None and any of the following parameters are None: confidence_threshold, iou_threshold, num_classes, coordinate_size, anchors, anchor_masks If spatial is True and depth_input_link is None

Module contents

Module for creating nodes for the OAK-D.

Submodules

buffer

Module for handling buffer communication with the OAK-D.

color_camera

Module for creating color camera nodes.

image_manip

Module for creating image manip nodes.

imu

Module for creating imu nodes.

mono_camera

Module for creating mono camera nodes.

neural_network

Module for creating neural network nodes.

stereo_depth

Module for creating stereo depth nodes.

xin

Module for creating xin nodes.

xout

Module for creating xout nodes.

models

Module for creating nodes for pre-compiled models.

Classes

Buffer

Class for creating a buffer for sending and receiving data from the OAK-D.

MobilenetData

Dataclass for mobilenet detection network data.

YolomodelData

Dataclass for yolo detection network data.

Functions

create_color_camera

Creates a color camera node.

create_image_manip

Creates an image manip node.

create_imu

Creates an imu node.

create_mono_camera

Creates a mono camera node.

create_left_right_cameras

Wrapper function for creating the left and right mono cameras.

create_neural_network

Creates a neural network node.

create_stereo_depth

Creates a stereo depth node.

create_stereo_depth_from_mono_cameras

Creates a stereo depth node from mono cameras.

create_xin

Creates an xin node.

create_xout

Creates an xout node.

create_yolo_detection_network

Creates a yolo detection network node.

create_mobilenet_detection_network

Creates a mobilenet detection network node.

get_nn_data

Gets generic data from a neural network node.

get_nn_frame

Gets the output frame from the neural network node.

get_nn_bgr_frame

Gets the output frame from the neural network node in BGR format.

get_nn_gray_frame

Gets the output frame from the neural network node in grayscale format.

get_nn_point_cloud_buffer

Gets the output point cloud buffer from the neural network node.

get_yolo_data

Get a YolomodelData object from a json file produced during compilation.

frame_norm

Adjusts a bounding box returned from an ImgDetection datatype to the frame size.

class oakutils.nodes.Buffer(device: dai.DeviceBase, input_stream: str | list[str], output_stream: str | list[str])

Bases: object

Buffer for sending and receiving data from OAK-D.

cycle(data: np.ndarray | list[np.ndarray]) dai.ADatatype | list[dai.ADatatype]

Cycle data through the buffer.

Parameters:

data (np.ndarray | list[np.ndarray]) – The data to cycle through the buffer.

Returns:

The data cycled through the buffer.

Return type:

dai.ADatatype | list[dai.ADatatype]

receive() dai.ADatatype | list[dai.ADatatype]

Receive data from the buffer.

Returns:

The data received from the buffer.

Return type:

dai.ADataType | list[dai.ADatatype]

send(data: np.ndarray | list[np.ndarray]) None

Send data through the buffer.

Parameters:

data (np.ndarray | list[np.ndarray]) – The data to send through the buffer.

class oakutils.nodes.MobilenetData(confidence_threshold: 'float', bounding_box_scale_factor: 'float' = 0.5, spatial: 'bool | None' = None, depth_input_link: 'dai.Node.Output | None' = None, lower_depth_threshold: 'int' = 100, upper_depth_threshold: 'int' = 20000, num_inference_threads: 'int' = 2, num_nce_per_inference_thread: 'int | None' = None, num_pool_frames: 'int | None' = None, input_blocking: 'bool | None' = None)

Bases: object

bounding_box_scale_factor: float = 0.5
confidence_threshold: float
input_blocking: bool | None = None
lower_depth_threshold: int = 100
num_inference_threads: int = 2
num_nce_per_inference_thread: int | None = None
num_pool_frames: int | None = None
spatial: bool | None = None
upper_depth_threshold: int = 20000
class oakutils.nodes.MultiBuffer(device: dai.DeviceBase, input_streams: Sequence[str | list[str]], output_streams: Sequence[str | list[str]])

Bases: object

Class for creating multiple Buffers for sending and receiving data from the OAK-D.

cycle(data: list[np.ndarray | list[np.ndarray]]) list[dai.ADatatype | list[dai.ADatatype]]

Cycle data through the multi buffer.

Parameters:

data (list[np.ndarray | list[np.ndarray]]) – The data to cycle through the buffer.

Returns:

The data received from the buffer.

Return type:

list[dai.ADatatype | list[dai.ADatatype]]

receive() list[dai.ADatatype | list[dai.ADatatype]]

Receive data from the multi buffer.

Returns:

The data received from the buffer.

Return type:

list[dai.ADatatype | list[dai.ADatatype]]

send(data: list[np.ndarray | list[np.ndarray]]) None

Send data through the multi buffer.

Parameters:

data (list[np.ndarray | list[np.ndarray]]) – The data to send through the buffer.

class oakutils.nodes.YolomodelData(confidence_threshold: 'float', iou_threshold: 'float', num_classes: 'int', coordinate_size: 'int', anchors: 'list[float]', anchor_masks: 'dict[str, list[int]]', spatial: 'bool | None' = None, depth_input_link: 'dai.Node.Output | None' = None, lower_depth_threshold: 'int' = 100, upper_depth_threshold: 'int' = 20000, num_inference_threads: 'int' = 2, num_nce_per_inference_thread: 'int | None' = None, num_pool_frames: 'int | None' = None, input_blocking: 'bool | None' = None)

Bases: object

anchor_masks: dict[str, list[int]]
anchors: list[float]
confidence_threshold: float
coordinate_size: int
input_blocking: bool | None = None
iou_threshold: float
lower_depth_threshold: int = 100
num_classes: int
num_inference_threads: int = 2
num_nce_per_inference_thread: int | None = None
num_pool_frames: int | None = None
spatial: bool | None = None
upper_depth_threshold: int = 20000
oakutils.nodes.create_color_camera(pipeline: ~depthai.Pipeline, resolution: ~depthai.ColorCameraProperties.SensorResolution = <SensorResolution.THE_1080_P: 0>, preview_size: tuple[int, int] = (640, 480), fps: int = 15, brightness: int = 0, saturation: int = 0, contrast: int = 0, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_target_size: tuple[int, int] | None = None, isp_scale: tuple[int, int] | None = None, isp_3a_fps: int | None = None, input_queue_size: int | None = None, *, set_interleaved: bool | None = None, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) ColorCamera

Use to create a pipeline for the color camera.

Note: setVideoSize, setStillSize are both automatically called using the tuple from get_tuple_from_color_sensor_resolution.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the color camera to

  • resolution (dai.ColorCameraProperties.SensorResolution, optional) – The resolution of the color camera, by default dai.ColorCameraProperties.SensorResolution.THE_1080_P

  • preview_size (Tuple[int, int], optional) – The size of the preview, by default (640, 480)

  • set_interleaved (bool, optional) – Whether to set the color camera to interleaved or not, by default False

  • fps (int, optional) – The fps of the color camera, by default 30

  • brightness (int, optional) – The brightness of the mono camera, by default 0 Valid values are -10 … 10

  • saturation (int, optional) – The saturation of the mono camera, by default 0 Valid values are -10 … 10

  • contrast (int, optional) – The contrast of the mono camera, by default 0 Valid values are -10 … 10

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1 Valid values are 0 … 4

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • isp_target_size (Optional[Tuple[int, int]], optional) – Target size for scaled frames from ISP (width, height), by default None Allows scaling of the cameras frames on-board the OAK to any size Works together with the isp_scale parameter

  • isp_scale (Optional[Tuple[int, int]], optional) – The isp scale of the color camera, by default None Allows scaling of the cameras frames on-board the OAK to any size not just the natively supported resolutions. Works together with the isp_target_size parameter

  • isp_3a_fps (Optional[int], optional) – The fps of how often the 3a algorithms will run, by default None Reducing this can help with performance onboard the device. A common value to reduce CPU usage on device is 15. Reference: https://docs.luxonis.com/projects/api/en/latest/tutorials/debugging/#resource-debugging

  • input_queue_size (int, optional) – The size of the input queue, by default None

  • input_reuse (bool, optional) – Whether to reuse inputs or not, by default None

  • input_blocking (bool, optional) – Whether to block the input or not, by default None

  • input_wait_for_message (bool, optional) – Whether to wait for a message or not, by default None

Returns:

The color camera node

Return type:

dai.node.ColorCamera

Raises:
  • ValueError – If the fps is not between 0 and 60

  • ValueError – If the brightness is not between -10 and 10

  • ValueError – If the saturation is not between -10 and 10

  • ValueError – If the contrast is not between -10 and 10

  • ValueError – If the sharpness is not between 0 and 4

  • ValueError – If the luma_denoise is not between 0 and 4

  • ValueError – If the chroma_denoise is not between 0 and 4

oakutils.nodes.create_image_manip(pipeline: Pipeline, input_link: Output, frame_type: Type, center_crop: tuple[float, float] | None = None, color_map: Colormap | None = None, crop_rect: tuple[float, float, float, float] | None = None, crop_rotated_rect: tuple[RotatedRect, bool] | None = None, resize: tuple[int, int] | None = None, resize_thumbnail: tuple[int, int, int, int, int] | None = None, rotation_degrees: float | None = None, rotation_radians: float | None = None, warp_border_fill_color: tuple[int, int, int] | None = None, warp_transform_four_points: tuple[list[Point2f], bool] | None = None, warp_transform_matrix_3x3: list[float] | None = None, input_queue_size: int | None = None, *, horizontal_flip: bool | None = None, keep_aspect_ratio: bool | None = None, vertical_flip: bool | None = None, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) ImageManip

Use to create an image manip node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the image manip node to.

  • input_link (dai.node.XLinkOut) – The input link to connect to the image manip node. Example: cam_rgb.preview.link Explicitly pass in the link as a non-called function.

  • frame_type (dai.RawImgFrame.Type) – The frame type to output.

  • center_crop (Optional[Tuple[float, float]], optional) – The center crop to apply, by default None

  • color_map (Optional[dai.Colormap], optional) – The color map to apply, by default None

  • crop_rect (Optional[Tuple[float, float, float, float]], optional) – The crop rect to apply, by default None

  • crop_rotated_rect (Optional[Tuple[dai.RotatedRect, bool]], optional) – The crop rotated rect to apply, by default None

  • horizontal_flip (Optional[bool], optional) – Whether to horizontally flip the image, by default None

  • keep_aspect_ratio (Optional[bool], optional) – Whether to keep the aspect ratio, by default None

  • resize (Optional[Tuple[int, int]], optional) – The resize to apply, by default None

  • resize_thumbnail (Optional[Tuple[int, int, int, int, int]], optional) – The resize thumbnail to apply, by default None

  • rotation_degrees (Optional[float], optional) – The rotation in degrees to apply, by default None

  • rotation_radians (Optional[float], optional) – The rotation in radians to apply, by default None

  • vertical_flip (Optional[bool], optional) – Whether to vertically flip the image, by default None

  • warp_border_fill_color (Optional[Tuple[int, int, int]], optional) – The warp border fill color to apply, by default None

  • warp_transform_four_points (Optional[Tuple[List[dai.Point2f], bool]], optional) – The warp transform four points to apply, by default None

  • warp_transform_matrix_3x3 (Optional[List[float]], optional) – The warp transform matrix 3x3 to apply, by default None

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The image manip node

Return type:

dai.node.ImageManip

oakutils.nodes.create_imu(pipeline: Pipeline, accelerometer_rate: int = 400, gyroscope_rate: int = 400, batch_report_threshold: int = 1, max_batch_reports: int = 10, *, enable_accelerometer_raw: bool | None = None, enable_accelerometer: bool | None = None, enable_linear_acceleration: bool | None = None, enable_gravity: bool | None = None, enable_gyroscope_raw: bool | None = None, enable_gyroscope_calibrated: bool | None = None, enable_gyroscope_uncalibrated: bool | None = None, enable_magnetometer_raw: bool | None = None, enable_magnetometer_calibrated: bool | None = None, enable_magnetometer_uncalibrated: bool | None = None, enable_rotation_vector: bool | None = None, enable_game_rotation_vector: bool | None = None, enable_geomagnetic_rotation_vector: bool | None = None, enable_arvr_stabilized_rotation_vector: bool | None = None, enable_arvr_stabilized_game_rotation_vector: bool | None = None) IMU

Use to create a node for the IMU.

Note: Sensors which use both gyroscope and accelerometer will default to slower rate.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the IMU to

  • accelerometer_rate (int, optional) – The rate of the accelerometer, by default 400 Options are 100, 200, 400

  • gyroscope_rate (int, optional) – The rate of the gyroscope, by default 400 Options are 125, 250, 400

  • batch_report_threshold (int, optional) – The batch report threshold, by default 1

  • max_batch_reports (int, optional) – The maximum batch reports, by default 10

  • enable_accelerometer_raw (bool, optional) – Enable accelerometer raw, by default False

  • enable_accelerometer (bool, optional) – Enable accelerometer, by default False

  • enable_linear_acceleration (bool, optional) – Enable linear acceleration, by default False

  • enable_gravity (bool, optional) – Enable gravity, by default False

  • enable_gyroscope_raw (bool, optional) – Enable gyroscope raw, by default False

  • enable_gyroscope_calibrated (bool, optional) – Enable gyroscope calibrated, by default False

  • enable_gyroscope_uncalibrated (bool, optional) – Enable gyroscope uncalibrated, by default False

  • enable_magnetometer_raw (bool, optional) – Enable magnetometer raw, by default False

  • enable_magnetometer_calibrated (bool, optional) – Enable magnetometer calibrated, by default False

  • enable_magnetometer_uncalibrated (bool, optional) – Enable magnetometer uncalibrated, by default False

  • enable_rotation_vector (bool, optional) – Enable rotation vector, by default False

  • enable_game_rotation_vector (bool, optional) – Enable game rotation vector, by default False

  • enable_geomagnetic_rotation_vector (bool, optional) – Enable geomagnetic rotation vector, by default False

  • enable_arvr_stabilized_rotation_vector (bool, optional) – Enable arvr stabilized rotation vector, by default False

  • enable_arvr_stabilized_game_rotation_vector (bool, optional) – Enable arvr stabilized game rotation vector, by default False

Returns:

The IMU node

Return type:

dai.node.IMU

Raises:
  • ValueError – If accelerometer_rate is not one of the following: 100, 200, 400

  • ValueError – If gyroscope_rate is not one of the following: 125, 250, 400

References

https://docs.luxonis.com/projects/api/en/latest/components/nodes/imu/

oakutils.nodes.create_left_right_cameras(pipeline: ~depthai.Pipeline, resolution: ~depthai.MonoCameraProperties.SensorResolution = <SensorResolution.THE_400_P: 2>, fps: int = 60, brightness: int = 0, saturation: int = 0, contrast: int = 0, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_3a_fps: int | None = None, input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) tuple[MonoCamera, MonoCamera]

Use to create the left and right mono cameras.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the two mono cameras to

  • resolution (dai.MonoCameraProperties.SensorResolution, optional) – The resolution of the mono camera, by default dai.MonoCameraProperties.SensorResolution.THE_400_P

  • fps (int, optional) – The fps of the mono camera, by default 60

  • brightness (int, optional) – The brightness of the mono camera, by default 0 Valid values are -10 … 10

  • saturation (int, optional) – The saturation of the mono camera, by default 0 Valid values are -10 … 10

  • contrast (int, optional) – The contrast of the mono camera, by default 0 Valid values are -10 … 10

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1 Valid values are 0 … 4

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • isp_3a_fps (Optional[int], optional) – The fps of how often the 3a algorithms will run, by default None Reducing this can help with performance onboard the device. A common value to reduce CPU usage on device is 15. Reference: https://docs.luxonis.com/projects/api/en/latest/tutorials/debugging/#resource-debugging

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

  • dai.node.MonoCamera – The left mono camera node

  • dai.node.XLinkOut – The output node for the left mono camera

  • dai.node.MonoCamera – The right mono camera node

  • dai.node.XLinkOut – The output node for the right mono camera

oakutils.nodes.create_mobilenet_detection_network(pipeline: dai.Pipeline, input_link: dai.Node.Output, blob_path: Path, confidence_threshold: float | None = None, bounding_box_scale_factor: float = 0.5, depth_input_link: dai.Node.Output | None = None, lower_depth_threshold: int = 100, upper_depth_threshold: int = 20000, num_inference_threads: int = 2, num_nce_per_inference_thread: int | None = None, num_pool_frames: int | None = None, *, mobilenet_data: MobilenetData | None = None, spatial: bool | None = None, input_blocking: bool | None = None) MobileNetDectionNetwork

Use to create a Mobilenet Detection Network node.

Should pass either a single MobilenetData object to the function OR pass all the parameters to the function. If using the parameters, then the MobilenetData object must be set to None. The yolo_data: MobilenetData is required as a keyword only parameter. If altering parameters at runtime, then parameters are recommended. Otherwise, the MobilenetData object is recommended. This function can be used to create either a Mobilenet Detection Network node or a Mobilenet Spatial Detection Network node simply by changing the spatial parameter to True.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the Mobilenet Detection Network node to

  • input_link (dai.Node.Output) – The input link to connect to the Mobilenet Detection Network node Example: cam_rgb.preview

  • blob_path (str) – The path to the blob file

  • mobilenet_data (MobilenetData, optional) – The Mobilenet Detection Network data, by default None

  • confidence_threshold (float) – The confidence threshold

  • bounding_box_scale_factor (float, optional) – The bounding box scale factor, by default 0.5

  • spatial (bool, optional) – Whether or not to use spatial coordinates, by default None If None, then False is used

  • depth_input_link (dai.Node.Output, optional) – The depth input link to connect to the Mobilenet Spatial Detection Network node Example: stereo.depth Must be set if spatial is True

  • lower_depth_threshold (float, optional) – The lower depth threshold for detections. By default 100 mm Only used if spatial is True.

  • upper_depth_threshold (float, optional) – The upper depth threshold for detections. By default 20000 mm Only used if spatial is True

  • num_inference_threads (int, optional) – The number of inference threads, by default 2

  • num_nce_per_inference_thread (int, optional) – The number of NCEs per inference thread, by default None

  • num_pool_frames (int, optional) – The number of pool frames, by default None

  • input_blocking (bool, optional) – Whether or not to use input blocking, by default None If None, then False is used

Returns:

The Mobilenet Detection Network node

Return type:

dai.Node.MobilenetDetectionNetwork | dai.Node.MobilenetSpatialDetectionNetwork

Raises:

ValueError – If mobilenet_data is None and confidence_threshold is None If spatial is True and depth_input_link is None

oakutils.nodes.create_mono_camera(pipeline: ~depthai.Pipeline, socket: ~depthai.CameraBoardSocket, resolution: ~depthai.MonoCameraProperties.SensorResolution = <SensorResolution.THE_400_P: 2>, fps: int = 15, brightness: int = 0, saturation: int = 0, contrast: int = 0, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_3a_fps: int | None = None, input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) MonoCamera

Use to create a pipeline for the mono camera.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the mono camera to

  • socket (dai.CameraBoardSocket) – The socket the camera is plugged into

  • resolution (dai.MonoCameraProperties.SensorResolution, optional) – The resolution of the mono camera, by default dai.MonoCameraProperties.SensorResolution.THE_400_P

  • fps (int, optional) – The fps of the mono camera, by default 60

  • brightness (int, optional) – The brightness of the mono camera, by default 0 Valid values are -10 … 10

  • saturation (int, optional) – The saturation of the mono camera, by default 0 Valid values are -10 … 10

  • contrast (int, optional) – The contrast of the mono camera, by default 0 Valid values are -10 … 10

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1 Valid values are 0 … 4

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1 Valid values are 0 … 4

  • isp_3a_fps (Optional[int], optional) – The fps of how often the 3a algorithms will run, by default None Reducing this can help with performance onboard the device. A common value to reduce CPU usage on device is 15. Reference: https://docs.luxonis.com/projects/api/en/latest/tutorials/debugging/#resource-debugging

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The mono camera node

Return type:

dai.node.MonoCamera

Raises:
  • ValueError – If the socket is not LEFT or RIGHT

  • ValueError – If the fps is not between 0 and 120

  • ValueError – If the brightness is not between -10 and 10

  • ValueError – If the saturation is not between -10 and 10

  • ValueError – If the contrast is not between -10 and 10

  • ValueError – If the sharpness is not between 0 and 4

  • ValueError – If the luma_denoise is not between 0 and 4

  • ValueError – If the chroma_denoise is not between 0 and 4

oakutils.nodes.create_neural_network(pipeline: dai.Pipeline, input_link: dai.Node.Output | list[dai.Node.Output], blob_path: Path, input_names: str | list[str] | None = None, input_sizes: int | list[int] | None = None, num_inference_threads: int = 2, num_nce_per_inference_thread: int | None = None, num_pool_frames: int | None = None, *, reuse_messages: bool | list[bool | None] | None = None, input_blocking: bool | list[bool] | None = None) dai.node.NeuralNetwork

Use to create a neural network node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the neural network to

  • input_link (Union[dai.Node.Output, list[dai.Node.Output]]) – The input link to connect to the image manip node or, if there are multiple input links, an iterable of input links. Example: cam_rgb.preview or (cam_rgb.preview, stereo.depth)

  • blob_path (Path) – The path to the blob file to use for the neural network.

  • input_names (Optional[Union[str, list[str]]], optional) – The names of the input links, by default None Must be the same length as input_link if a list

  • reuse_messages (Optional[Union[bool, list[bool]]], optional) – Whether to reuse messages, by default None Must be the same length as input_link if a list Values may be None if the input link does not need a value set

  • input_sizes (Optional[Union[int, list[int]]], optional) – The size of the input queue, by default None Must be the same length as input_link if a list

  • input_blocking (Optional[Union[bool, list[bool]]], optional) – Whether the input queue is blocking, by default None Must be the same length as input_link if a list

  • num_inference_threads (int, optional) – The number of inference threads, by default 2

  • num_nce_per_inference_thread (Optional[int], optional) – The number of NCEs per inference thread, by default None NCE: Neural Compute Engine

  • num_pool_frames (Optional[int], optional) – The number of pool frames, by default None

Returns:

The neural network node

Return type:

dai.node.NeuralNetwork

Raises:
  • ValueError – If input_link is an iterable and input_names is None If input_link and input_names are iterables and are not the same length If input_link and reuse_messages are iterables and are not the same length

  • TypeError – If input_link is an iterable and input_names is not an iterable If input_link is an iterable and reuse_messages is not an iterable

oakutils.nodes.create_stereo_depth(pipeline: ~depthai.Pipeline, resolution: ~depthai.MonoCameraProperties.SensorResolution = <SensorResolution.THE_400_P: 2>, fps: int = 15, brightness: int = 1, saturation: int = 1, contrast: int = 1, sharpness: int = 1, luma_denoise: int = 1, chroma_denoise: int = 1, isp_3a_fps: int | None = None, input_queue_size: int | None = None, preset: ~depthai.node.StereoDepth.PresetMode = <PresetMode.HIGH_DENSITY: 1>, align_socket: ~depthai.CameraBoardSocket = <CameraBoardSocket.CAM_B: 1>, confidence_threshold: int = 255, rectify_edge_color: int = 0, median_filter: ~depthai.MedianFilter = <MedianFilter.KERNEL_7x7: 7>, subpixel_fractional_bits: int = 3, min_brightness: int = 0, max_brightness: int = 255, decimation_factor: int = 1, decimation_mode: ~depthai.RawStereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode = <DecimationMode.NON_ZERO_MEAN: 2>, spatial_alpha: float = 0.5, spatial_delta: int = 0, spatial_radius: int = 2, spatial_iterations: int = 1, speckle_range: int = 20, temporal_alpha: float = 0.5, temporal_delta: int = 0, temporal_mode: ~depthai.RawStereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode = <PersistencyMode.VALID_2_IN_LAST_3: 2>, threshold_min_range: int = 200, threshold_max_range: int = 25000, bilateral_sigma: int = 1, stereo_input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None, lr_check: bool | None = None, extended_disparity: bool | None = None, subpixel: bool | None = None, enable_spatial_filter: bool | None = None, enable_speckle_filter: bool | None = None, enable_temporal_filter: bool | None = None, stereo_input_reuse: bool | None = None, stereo_input_blocking: bool | None = None, stereo_input_wait_for_message: bool | None = None) tuple[StereoDepth, MonoCamera, MonoCamera]

Use to create a stereo depth given only a pipeline object.

Note: Creates mono cameras for the left and right cameras using the create_left_right_cameras function.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the stereo depth node to

  • resolution (dai.MonoCameraProperties.SensorResolution, optional) – The resolution of the mono camera, by default dai.MonoCameraProperties.SensorResolution.THE_400_P

  • fps (int, optional) – The fps of the mono camera, by default 60

  • brightness (int, optional) – The brightness of the mono camera, by default 1

  • saturation (int, optional) – The saturation of the mono camera, by default 1

  • contrast (int, optional) – The contrast of the mono camera, by default 1

  • sharpness (int, optional) – The sharpness of the mono camera, by default 1

  • luma_denoise (int, optional) – The luma denoise of the mono camera, by default 1

  • chroma_denoise (int, optional) – The chroma denoise of the mono camera, by default 1

  • isp_3a_fps (int, optional) – The 3a fps of the mono camera, by default None

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

  • left (dai.node.MonoCamera) – The left mono camera node

  • right (dai.node.MonoCamera) – The right mono camera node

  • preset (dai.node.StereoDepth.PresetMode, optional) – The preset mode of the stereo depth node, by default dai.node.StereoDepth.PresetMode.HIGH_DENSITY

  • align_socket (dai.CameraBoardSocket, optional) – The camera board socket of the stereo depth node, by default dai.CameraBoardSocket.LEFT

  • confidence_threshold (int, optional) – The confidence threshold of the stereo depth node, by default 200

  • rectify_edge_color (int, optional) – The rectify edge color of the stereo depth node, by default 0

  • median_filter (dai.StereoDepthProperties.MedianFilter, optional) – The median filter of the stereo depth node, by default dai.StereoDepthProperties.MedianFilter.KERNEL_7x7

  • lr_check (bool, optional) – The left right check of the stereo depth node, by default True

  • extended_disparity (bool, optional) – The extended disparity of the stereo depth node, by default False

  • subpixel (bool, optional) – The subpixel of the stereo depth node, by default False

  • subpixel_fractional_bits (int, optional) – The subpixel fractional bits of the stereo depth node, by default 3

  • min_brightness (int, optional) – The min brightness of the stereo depth node, by default 0

  • max_brightness (int, optional) – The max brightness of the stereo depth node, by default 255

  • decimation_factor (int, optional) – The decimation factor of the stereo depth node, by default 1

  • decimation_mode (dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode, optional) – The decimation mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode.NON_ZERO_MEAN

  • enable_spatial_filter (bool, optional) – The enable spatial filter of the stereo depth node, by default False

  • spatial_alpha (float, optional) – The spatial alpha of the stereo depth node, by default 0.5

  • spatial_delta (int, optional) – The spatial delta of the stereo depth node, by default 0

  • spatial_radius (int, optional) – The spatial radius of the stereo depth node, by default 2

  • spatial_iterations (int, optional) – The spatial iterations of the stereo depth node, by default 1

  • enable_speckle_filter (bool, optional) – The enable speckle filter of the stereo depth node, by default False

  • speckle_range (int, optional) – The speckle range of the stereo depth node, by default 20

  • enable_temporal_filter (bool, optional) – The enable temporal filter of the stereo depth node, by default False

  • temporal_alpha (float, optional) – The temporal alpha of the stereo depth node, by default 0.5

  • temporal_delta (int, optional) – The temporal delta of the stereo depth node, by default 0

  • temporal_mode (dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode, optional) – The temporal mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode.VALID_2_IN_LAST_3

  • threshold_min_range (int, optional) – The threshold min range of the stereo depth node, by default 200

  • threshold_max_range (int, optional) – The threshold max range of the stereo depth node, by default 25000

  • bilateral_sigma (int, optional) – The bilateral sigma of the stereo depth node, by default 1

  • stereo_input_queue_size (int, optional) – The queue size of the input, by default None

  • stereo_input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • stereo_input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • stereo_input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

  • dai.node.StereoDepth – The stereo depth node

  • dai.node.MonoCamera – The left mono camera node

  • dai.node.MonoCamera – The right mono camera node

oakutils.nodes.create_stereo_depth_from_mono_cameras(pipeline: ~depthai.Pipeline, left: ~depthai.node.MonoCamera, right: ~depthai.node.MonoCamera, preset: ~depthai.node.StereoDepth.PresetMode = <PresetMode.HIGH_DENSITY: 1>, align_socket: ~depthai.CameraBoardSocket = <CameraBoardSocket.CAM_B: 1>, confidence_threshold: int = 255, rectify_edge_color: int = 0, median_filter: ~depthai.MedianFilter = <MedianFilter.KERNEL_7x7: 7>, subpixel_fractional_bits: int = 3, min_brightness: int = 0, max_brightness: int = 255, decimation_factor: int = 1, decimation_mode: ~depthai.RawStereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode = <DecimationMode.NON_ZERO_MEAN: 2>, spatial_alpha: float = 0.5, spatial_delta: int = 0, spatial_radius: int = 2, spatial_iterations: int = 1, speckle_range: int = 20, temporal_alpha: float = 0.5, temporal_delta: int = 0, temporal_mode: ~depthai.RawStereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode = <PersistencyMode.VALID_2_IN_LAST_3: 2>, threshold_min_range: int = 200, threshold_max_range: int = 25000, bilateral_sigma: int = 1, input_queue_size: int | None = None, *, lr_check: bool | None = None, extended_disparity: bool | None = None, subpixel: bool | None = None, enable_spatial_filter: bool | None = None, enable_speckle_filter: bool | None = None, enable_temporal_filter: bool | None = None, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) StereoDepth

Use to create a stereo depth node from a pipeline and two mono cameras.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the stereo depth node to

  • left (dai.node.MonoCamera) – The left mono camera node

  • right (dai.node.MonoCamera) – The right mono camera node

  • preset (dai.node.StereoDepth.PresetMode, optional) – The preset mode of the stereo depth node, by default dai.node.StereoDepth.PresetMode.HIGH_DENSITY

  • align_socket (dai.CameraBoardSocket, optional) – The camera board socket of the stereo depth node, by default dai.CameraBoardSocket.LEFT

  • confidence_threshold (int, optional) – The confidence threshold of the stereo depth node, by default 200

  • rectify_edge_color (int, optional) – The rectify edge color of the stereo depth node, by default 0

  • median_filter (dai.StereoDepthProperties.MedianFilter, optional) – The median filter of the stereo depth node, by default dai.StereoDepthProperties.MedianFilter.KERNEL_7x7

  • lr_check (bool, optional) – The left right check of the stereo depth node, by default True

  • extended_disparity (bool, optional) – The extended disparity of the stereo depth node, by default False

  • subpixel (bool, optional) – The subpixel of the stereo depth node, by default False

  • subpixel_fractional_bits (int, optional) – The subpixel fractional bits of the stereo depth node, by default 3

  • min_brightness (int, optional) – The min brightness of the stereo depth node, by default 0

  • max_brightness (int, optional) – The max brightness of the stereo depth node, by default 255

  • decimation_factor (int, optional) – The decimation factor of the stereo depth node, by default 1 Valid values are 1, 2, 3, 4

  • decimation_mode (dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode, optional) – The decimation mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode.NON_ZERO_MEAN

  • enable_spatial_filter (bool, optional) – The enable spatial filter of the stereo depth node, by default False

  • spatial_alpha (float, optional) – The spatial alpha of the stereo depth node, by default 0.5 Valid values are 0.0 - 1.0

  • spatial_delta (int, optional) – The spatial delta of the stereo depth node, by default 0

  • spatial_radius (int, optional) – The spatial radius of the stereo depth node, by default 2

  • spatial_iterations (int, optional) – The spatial iterations of the stereo depth node, by default 1

  • enable_speckle_filter (bool, optional) – The enable speckle filter of the stereo depth node, by default False

  • speckle_range (int, optional) – The speckle range of the stereo depth node, by default 20

  • enable_temporal_filter (bool, optional) – The enable temporal filter of the stereo depth node, by default False

  • temporal_alpha (float, optional) – The temporal alpha of the stereo depth node, by default 0.5 Valid values are 0.0 - 1.0

  • temporal_delta (int, optional) – The temporal delta of the stereo depth node, by default 0

  • temporal_mode (dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode, optional) – The temporal mode of the stereo depth node, by default dai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode.VALID_2_IN_LAST_3

  • threshold_min_range (int, optional) – The threshold min range of the stereo depth node, by default 200

  • threshold_max_range (int, optional) – The threshold max range of the stereo depth node, by default 25000

  • bilateral_sigma (int, optional) – The bilateral sigma of the stereo depth node, by default 1

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The stereo depth node

Return type:

dai.node.StereoDepth

Raises:
  • ValueError – If spatial_alpha is not between 0.0 and 1.0

  • ValueError – If temporal_alpha is not between 0.0 and 1.0

  • ValueError – If decimation_factor is not 1,2,3,4

oakutils.nodes.create_xin(pipeline: dai.Pipeline, stream_name: str, max_data_size: int = 6144000) dai.node.XLinkIn

Use to create an XLinkIn node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the XLinkIn node to

  • stream_name (str) – The name of the stream

  • max_data_size (int, optional) – The maximum data size, by default 6144000 bytes

Returns:

The XLinkIn node

Return type:

dai.node.XLinkIn

oakutils.nodes.create_xout(pipeline: dai.Pipeline, input_link: dai.Node.Output, stream_name: str, input_queue_size: int | None = None, *, input_reuse: bool | None = None, input_blocking: bool | None = None, input_wait_for_message: bool | None = None) dai.node.XLinkOut

Use to create an XLinkOut node.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the XLinkOut node to

  • input_link (dai.Node.Output) – The input link to connect to the XLinkOut node Example: cam_rgb.preview

  • stream_name (str) – The name of the stream

  • input_queue_size (int, optional) – The queue size of the input, by default None

  • input_reuse (Optional[bool], optional) – Whether to reuse the previous message, by default None

  • input_blocking (Optional[bool], optional) – Whether to block the input, by default None

  • input_wait_for_message (Optional[bool], optional) – Whether to wait for a message, by default None

Returns:

The XLinkOut node

Return type:

dai.node.XLinkOut

oakutils.nodes.create_yolo_detection_network(pipeline: dai.Pipeline, input_link: dai.Node.Output, blob_path: Path, confidence_threshold: float | None = None, iou_threshold: float | None = None, num_classes: int | None = None, coordinate_size: int | None = None, anchors: list[float] | None = None, anchor_masks: dict[str, list[int]] | None = None, depth_input_link: dai.Node.Output | None = None, lower_depth_threshold: int = 100, upper_depth_threshold: int = 20000, num_inference_threads: int = 2, num_nce_per_inference_thread: int | None = None, num_pool_frames: int | None = None, *, yolo_data: YolomodelData | None = None, spatial: bool | None = None, input_blocking: bool | None = None) YoloDectionNetwork

Use to create a Yolo Detection Network node.

Should pass either a single YoloModelData object to the function OR pass all the parameters to the function. If using the parameters, then the YoloModelData object must be set to None. The yolo_data: YoloModelData is required as a keyword only parameter. If altering parameters at runtime, then parameters are recommended. Otherwise, the YoloModelData object is recommended. This function can be used to create either a Yolo Detection Network node or a Yolo Spatial Detection Network node simply by changing the spatial parameter in the YoloModelData or parameters to True. Corresponding, depth_input_link must be set if spatial is True.

Parameters:
  • pipeline (dai.Pipeline) – The pipeline to add the Yolo Detection Network node to

  • input_link (dai.Node.Output) – The input link to connect to the Yolo Detection Network node Example: cam_rgb.preview

  • blob_path (str) – The path to the blob file

  • yolo_data (YolomodelData, optional) – The Yolo model data, by default None If None, then the other parameters must be set

  • confidence_threshold (float, optional) – The confidence threshold, by default None

  • iou_threshold (float) – The IOU threshold, by default None

  • num_classes (int) – The number of classes the model detects, by default None

  • coordinate_size (int) – The coordinate size of each detection, by default None

  • anchors (list[int]) – The anchors for the yolo model, by default None

  • anchor_masks (dict[str, list[int]]) – The anchor masks for the yolo model, by default None

  • spatial (bool, optional) – Whether or not to use spatial coordinates, by default None If None, then False is used

  • depth_input_link (dai.Node.Output, optional) – The depth input link to connect to the Yolo Spatial Detection Network node Example: stereo.depth Must be set if spatial is True

  • lower_depth_threshold (float, optional) – The lower depth threshold for detections. By default 100 mm Only used if spatial is True.

  • upper_depth_threshold (float, optional) – The upper depth threshold for detections. By default 20000 mm Only used if spatial is True

  • num_inference_threads (int, optional) – The number of inference threads, by default 2

  • num_nce_per_inference_thread (int, optional) – The number of NCEs per inference thread, by default None

  • num_pool_frames (int, optional) – The number of pool frames, by default None

  • input_blocking (bool, optional) – Whether or not to use input blocking, by default None If None, then False is used

Returns:

The Yolo Detection Network node

Return type:

dai.Node.YoloDetectionNetwork | dai.Node.YoloSpatialDetectionNetwork

Raises:

ValueError – If yolo_data is None and any of the following parameters are None: confidence_threshold, iou_threshold, num_classes, coordinate_size, anchors, anchor_masks If spatial is True and depth_input_link is None

oakutils.nodes.frame_norm(frame: ndarray, bbox: tuple[float, float, float, float]) tuple[int, int, int, int]

Use to adjust a bounding box returned from a YoloDetectionModel node.

Parameters:
  • frame (np.ndarray) – The frame to adjust the bounding box for

  • bbox (tuple[float, float, float, float]) – The bounding box to adjust

Returns:

The adjusted bounding box

Return type:

tuple[int, int, int, int]

References

https://docs.luxonis.com/projects/api/en/latest/samples/Yolo/tiny_yolo/#rgb-tiny-yolo

oakutils.nodes.get_nn_bgr_frame(data: ndarray | NNData, frame_size: tuple[int, int] = (640, 480), resize_factor: float | None = None, normalization: float | Callable | None = None) ndarray

Use to convert the raw data output from a neural network execution and return a BGR frame.

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • frame_size (tuple[int, int], optional) – The size of the frame, by default (640, 480)

  • resize_factor (Optional[float], optional) – The resize factor to apply to the frame, by default None

  • normalization (Optional[float, Callable], optional) – The normalization to apply to the frame, by default None If a float then the frame is multiplied by the float. If a callable then the frame is passed to the callable and set to the return value. If resize_factor is less than 1.0, then normalization is applied after resizing.

Returns:

BGR frame usable by cv2.

Return type:

np.ndarray

oakutils.nodes.get_nn_data(data: NNData, reshape_to: tuple[int, ...] | None = None, scale: float | None = None, astype: type | None = None, *, use_first_layer: bool | None = None) ndarray

Use to get arbitrary shaped data from a neural network execution.

This function is used for getting an arbitrarily shaped data from a custom neural network execution, and can handle U8 input models. The data retrieved, reshaped, type cast, then scaled in that order. If the NN returns a single element, an example could be: get_nn_data(nndata, reshape_to(1, 1))[0] The (1, 1) shape is important since all returned tensors have a starting dimension of 1. If the model utilizes U8 inputs, then an example could be: get_nn_data(nndata, use_first_layer=True)

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • reshape_to (Optional[tuple[int, ...]], optional) – The shape to reshape the data to, by default None

  • scale (Optional[float], optional) – The scale to apply to the data, by default None

  • astype (Optional[type], optional) – The type to cast the data to, by default None

  • use_first_layer (Optional[bool], optional) – Whether to use the first layer of the data, by default None If None, then False is used and instead getData is used This should be set to true for networks which take U8 input. The U8 input process means that the first layer fp16 data is the correct output and not the entire buffer.

Returns:

The data from the neural network execution.

Return type:

np.ndarray

oakutils.nodes.get_nn_frame(data: ndarray | NNData, channels: int, frame_size: tuple[int, int] = (640, 480), resize_factor: float | None = None, normalization: float | Callable[[ndarray], ndarray] | None = None, rescale_offset: float = 0.5, rescale_multiplier: float = 255.0, *, rescale: bool | None = None, swap_rb: bool | None = None) ndarray

Use to convert the raw data output from a neural network execution and return a frame.

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • channels (int) – The number of channels in the frame.

  • frame_size (tuple[int, int], optional) – The size of the frame, by default (640, 480) This is the size of the frame before any resizing is applied. If frame_size is incorrect, an error will occur.

  • resize_factor (Optional[float], optional) – The resize factor to apply to the frame, by default None

  • normalization (Optional[float, Callable[[np.ndarray], np.ndarray]], optional) – The normalization to apply to the frame, by default None If a float then the frame is multiplied by the float. If a callable then the frame is passed to the callable and set to the return value. If resize_factor is less than 1.0, then normalization is applied after resizing.

  • rescale_offset (float, optional) – The offset to apply to the frame once it has been received, but before other operations are applied such as resizing or normalization. By default this value is 0.5 to convert from [-0.5, 0.5] to [0, 1].

  • rescale_multiplier (float, optional) – The multiplier to apply to the frame once it has been received, but before other operations are applied such as resizing or normalization. By default this value is 255.0 to convert from [0.0, 1.0] to [0, 255].

  • swap_rb (Optional[bool], optional) – Whether to swap the red and blue channels, by default None If None, then False is used

  • rescale (Optional[bool], optional) – Whether or not to perform rescaling to convert from one data range to another. By default None, so not rescaling occurs. When a rescale is performed, the offset is added then the multiplier is applied. The default values for offset and multiplier convert from [-0.5, 0.5] to [0, 255].

Returns:

Frame usable by cv2.

Return type:

np.ndarray

oakutils.nodes.get_nn_gray_frame(data: ndarray | NNData, frame_size: tuple[int, int] = (640, 480), resize_factor: float | None = None, normalization: float | Callable | None = None) ndarray

Use to convert the raw data output from a neural network execution and return a grayscale frame.

Parameters:
  • data (Union[np.ndarray, dai.NNData]) – Raw data output from a neural network execution.

  • frame_size (tuple[int, int], optional) – The size of the frame, by default (640, 480)

  • resize_factor (Optional[float], optional) – The resize factor to apply to the frame, by default None

  • normalization (Optional[float, Callable], optional) – The normalization to apply to the frame, by default None If a float then the frame is multiplied by the float. If a callable then the frame is passed to the callable and set to the return value. If resize_factor is less than 1.0, then normalization is applied after resizing.

Returns:

Grayscale frame usable by cv2.

Return type:

np.ndarray

oakutils.nodes.get_nn_point_cloud_buffer(data: NNData, frame_size: tuple[int, int] = (640, 400), scale: float = 1000.0, *, remove_zeros: bool | None = None) ndarray

Use to convert the raw data output from a neural network execution and converts it to a point cloud.

Parameters:
  • data (dai.NNData) – Raw data output from a neural network execution.

  • frame_size (tuple[int, int], optional) – The size of the buffer, by default (640, 400) Usually this will be the size of the depth frame. Which inherits its shape from the MonoCamera resolutions.

  • scale (float, optional) – The scale to apply to the point cloud, by default 1000.0 This will convert from mm to m.

  • remove_zeros (bool, optional) – Whether to remove zero points, by default None If None, then True is used Recommended to set to True to remove zero points Can speedup reading and filtering of the point cloud by up to 10x

Returns:

Point cloud buffer

Return type:

np.ndarray

oakutils.nodes.get_yolo_data(yolo_json_path: Path | str) YolomodelData

Create a YolomodelData object from a json file.

Parameters:

yolo_json_path (Path | str) – The path to the json file

Returns:

The YolomodelData object

Return type:

YolomodelData

Raises:

FileNotFoundError – If the file does not exist