Pipeline manager

PipelineManager is the first class that we will learn how to use as it is the one that is goes hand in hand with every other class. It is created with the purpose to help you with creating and setting up processing pipelines. In this tutorial bellow we will see and learn how to declare and use them.

Getting started

Before we begin we must first import pipeline_manager from DepthAI_SDK. After that we will initialize the pipeline and define its sources.

 1from depthai_sdk.managers import PipelineManager
 2import depthai as dai
 3
 4
 5# declaring the pipeline
 6pm = PipelineManager()
 7
 8# after the declaration, we define it's sources
 9pm.createColorCam(xout=True)
10
11# connecting to device
12with dai.Device(pm.pipeline) as device:
13    # pipeline is created and the device is connected
14    print("Successfully connected to the device!")

We successfully created and initialized the pipeline. If everything was setup correctly, you should receive a message in your terminal, that will inform you that the connecting was successful.

../../_images/connecting_message.png

But the above code currently one has one source as it’s stream. We can initialize more sources in one pipeline.

 1from depthai_sdk.managers import PipelineManager
 2import depthai as dai
 3
 4
 5# declaring the pipeline
 6pm = PipelineManager()
 7
 8# after the declaration, we define it's sources
 9
10# color camera
11pm.createColorCam(xout=True)
12
13# left camera
14pm.createLeftCam(xout=True)
15
16# right camera
17pm.createRightCam(xout=True)
18
19# depth
20pm.createDepth(useDepth=True)
21
22# connecting to device
23with dai.Device(pm.pipeline) as device:
24    # pipeline is created and the device is connected
25    print("Successfully connected to the device!")

We now declared more then one source in the pipeline. To fully use the pipeline, you can use it with PreviewManager to see the streams or EncodingManager to save streams to files. As you can see above we also added another argument to the color camera stream, called previewSize which will resize the stream to wanted ratio (height x width). All sources have many more arguments, xout will help us in the next tutorial where we will learn about the PreviewManager. In the above example we also declared a Depth source. We gave it useDepth as an argument which will create a queue for depth frames. If we wish to use a different queue for depth, we can change this argument to:

  • useDisparity to use disparity frames,

  • useRectifiedLeft for rectified left frames,

  • and useRectifiedRigh for rectified right frames.

Of course these are not the only arguments that you can use in the PipelineManager.

class depthai_sdk.managers.PipelineManager

Manager class handling different depthai.Pipeline operations. Most of the functions wrap up nodes creation and connection logic onto a set of convenience functions.

__init__(openvinoVersion=None, poeQuality=100, lowCapabilities=False, lowBandwidth=False)
pipeline

Ready to use requested pipeline. Can be passed to depthai.Device to start execution

Type

depthai.Pipeline

nodes

Contains all nodes added to the pipeline object, can be used to conveniently access nodes by their name

Type

types.SimpleNamespace

openvinoVersion = None

OpenVINO version which will be used in pipeline

Type

depthai.OpenVINO.Version

poeQuality = None

PoE encoding quality, can decrease frame quality but decrease latency

Type

int, Optional

lowBandwidth = False

If set to True, manager will MJPEG-encode the packets sent from device to host to lower the bandwidth usage. Can break if more than 3 encoded outputs requested

Type

bool

lowCapabilities = False

If set to True, manager will try to optimize the pipeline to reduce the amount of host-side calculations (useful for RPi or other embedded systems)

Type

bool

setNnManager(nnManager)

Assigns NN manager. It also syncs the pipeline versions between those two objects

Parameters

nnManager (depthai_sdk.managers.NNetManager) – NN manager instance

createDefaultQueues(device)

Creates default queues for config updates

Parameters

device (depthai.Device) – Running device instance

closeDefaultQueues()

Creates default queues for config updates

Parameters

device (depthai.Device) – Running device instance

createColorCam(previewSize=None, res=<SensorResolution.THE_1080_P: 0>, fps=30, fullFov=True, orientation=None, colorOrder=<ColorOrder.BGR: 0>, xout=False, xoutVideo=False, xoutStill=False, control=True, pipeline=None, args=None)

Creates depthai.node.ColorCamera node based on specified attributes

Parameters
  • previewSize (tuple, Optional) – Size of the preview - (width, height)

  • res (depthai.ColorCameraProperties.SensorResolution, Optional) – Camera resolution to be used

  • fps (int, Optional) – Camera FPS set on the device. Can limit / increase the amount of frames produced by the camera

  • fullFov (bool, Optional) – If set to True, full frame will be scaled down to nn size. If to False, it will first center crop the frame to meet the NN aspect ratio and then scale down the image.

  • orientation (depthai.CameraImageOrientation, Optional) – Custom camera orientation to be set on the device

  • colorOrder (depthai.ColorCameraProperties, Optional) – Color order to be used

  • xout (bool, Optional) – If set to True, a dedicated depthai.node.XLinkOut will be created for this node

  • xoutVideo (bool, Optional) – If set to True, a dedicated depthai.node.XLinkOut will be created for video output of this node

  • xoutStill (bool, Optional) – If set to True, a dedicated depthai.node.XLinkOut will be created for still output of this node

  • args (Object, Optional) – Arguments from the ArgsManager

Return type

ColorCamera

createLeftCam(res=None, fps=30, orientation=None, xout=False, control=True, pipeline=None, args=None)

Creates depthai.node.MonoCamera node based on specified attributes, assigned to depthai.CameraBoardSocket.LEFT

Parameters
Return type

MonoCamera

createRightCam(res=None, fps=30, orientation=None, xout=False, control=True, pipeline=None, args=None)

Creates depthai.node.MonoCamera node based on specified attributes, assigned to depthai.CameraBoardSocket.RIGHT

Parameters
Return type

MonoCamera

updateIrConfig(device, irLaser=None, irFlood=None)

Updates IR configuration

Parameters
  • irLaser (int, Optional) – Sets the IR laser dot projector brightness (0..1200)

  • irFlood (int, Optional) – Sets the IR flood illuminator light brightness (0..1500)

createDepth(dct=245, median=None, sigma=0, lr=True, lrcThreshold=5, extended=False, subpixel=False, useDisparity=False, useDepth=False, useRectifiedLeft=False, useRectifiedRight=False, runtimeSwitch=False, alignment=None, control=True, pipeline=None, args=None)

Creates depthai.node.StereoDepth node based on specified attributes

Parameters
  • dct (int, Optional) – Disparity Confidence Threshold (0..255). The less confident the network is, the more empty values are present in the depth map.

  • median (depthai.MedianFilter, Optional) – Median filter to be applied on the depth, use with depthai.MedianFilter.MEDIAN_OFF to disable median filtering

  • sigma (int, Optional) – Sigma value for bilateral filter (0..65535). If set to 0, the filter will be disabled.

  • lr (bool, Optional) – Set to True to enable Left-Right Check

  • lrcThreshold (int, Optional) – Sets the Left-Right Check threshold value (0..10)

  • extended (bool, Optional) – Set to True to enable the extended disparity

  • subpixel (bool, Optional) – Set to True to enable the subpixel disparity

  • useDisparity (bool, Optional) – Set to True to create output queue for disparity frames

  • useDepth (bool, Optional) – Set to True to create output queue for depth frames

  • useRectifiedLeft (bool, Optional) – Set to True to create output queue for rectified left frames

  • useRectifiedRigh (bool, Optional) – Set to True to create output queue for rectified right frames

  • runtimeSwitch (bool, Optional) – Allows to change the depth configuration during the runtime but allocates resources for worst-case scenario (disabled by default)

  • alignment (depthai.CameraBoardSocket, Optional) – Aligns the depth map to the specified camera socket

  • args (Object, Optional) – Arguments from the ArgsManager

Raises

RuntimeError – if left of right mono cameras were not initialized

Return type

StereoDepth

captureStill()
triggerAutoFocus()
triggerAutoExposure()
triggerAutoWhiteBalance()
updateColorCamConfig(exposure=None, sensitivity=None, saturation=None, contrast=None, brightness=None, sharpness=None, autofocus=None, autowhitebalance=None, focus=None, whitebalance=None)

Updates depthai.node.ColorCamera node config

Parameters
  • exposure (int, Optional) – Exposure time in microseconds. Has to be set together with sensitivity (Usual range: 1..33000)

  • sensitivity (int, Optional) – Sensivity as ISO value. Has to be set together with exposure (Usual range: 100..1600)

  • saturation (int, Optional) – Image saturation (Allowed range: -10..10)

  • contrast (int, Optional) – Image contrast (Allowed range: -10..10)

  • brightness (int, Optional) – Image brightness (Allowed range: -10..10)

  • sharpness (int, Optional) – Image sharpness (Allowed range: 0..4)

  • autofocus (dai.CameraControl.AutoFocusMode, Optional) – Set the autofocus mode

  • autowhitebalance (dai.CameraControl.AutoFocusMode, Optional) – Set the autowhitebalance mode

  • focus (int, Optional) – Set the manual focus (lens position)

  • whitebalance (int, Optional) – Set the manual white balance

updateLeftCamConfig(exposure=None, sensitivity=None, saturation=None, contrast=None, brightness=None, sharpness=None)

Updates left depthai.node.MonoCamera node config

Parameters
  • exposure (int, Optional) – Exposure time in microseconds. Has to be set together with sensitivity (Usual range: 1..33000)

  • sensitivity (int, Optional) – Sensivity as ISO value. Has to be set together with exposure (Usual range: 100..1600)

  • saturation (int, Optional) – Image saturation (Allowed range: -10..10)

  • contrast (int, Optional) – Image contrast (Allowed range: -10..10)

  • brightness (int, Optional) – Image brightness (Allowed range: -10..10)

  • sharpness (int, Optional) – Image sharpness (Allowed range: 0..4)

updateRightCamConfig(exposure=None, sensitivity=None, saturation=None, contrast=None, brightness=None, sharpness=None)

Updates right depthai.node.MonoCamera node config

Parameters
  • exposure (int, Optional) – Exposure time in microseconds. Has to be set together with sensitivity (Usual range: 1..33000)

  • sensitivity (int, Optional) – Sensivity as ISO value. Has to be set together with exposure (Usual range: 100..1600)

  • saturation (int, Optional) – Image saturation (Allowed range: -10..10)

  • contrast (int, Optional) – Image contrast (Allowed range: -10..10)

  • brightness (int, Optional) – Image brightness (Allowed range: -10..10)

  • sharpness (int, Optional) – Image sharpness (Allowed range: 0..4)

updateDepthConfig(dct=None, sigma=None, median=None, lrcThreshold=None)

Updates depthai.node.StereoDepth node config

Parameters
  • dct (int, Optional) – Disparity Confidence Threshold (0..255). The less confident the network is, the more empty values are present in the depth map.

  • median (depthai.MedianFilter, Optional) – Median filter to be applied on the depth, use with depthai.MedianFilter.MEDIANOFF to disable median filtering

  • sigma (int, Optional) – Sigma value for bilateral filter (0..65535). If set to 0, the filter will be disabled.

  • lrc (bool, Optional) – Enables or disables Left-Right Check mode

  • lrcThreshold (int, Optional) – Sets the Left-Right Check threshold value (0..10)

addNn(nn, xoutNnInput=False, xoutSbb=False)

Adds NN node to current pipeline. Usually obtained by calling depthai_sdk.managers.NNetManager.createNN method first

Parameters
  • nn (depthai.node.NeuralNetwork) – prepared NeuralNetwork node to be attached to the pipeline

  • xoutNnInput (bool) – Set to True to create output queue for NN’s passthough frames

  • xoutSbb (bool) – Set to True to create output queue for Spatial Bounding Boxes (area that is used to calculate spatial location)

createSystemLogger(rate=1)

Creates depthai.node.SystemLogger node together with XLinkOut

Parameters

rate (int, Optional) – Specify logging rate (in Hz)

createEncoder(cameraName, encFps=30, encQuality=100)

Creates H.264 / H.265 video encoder (depthai.node.VideoEncoder instance)

Parameters
  • cameraName (str) – Camera name to create the encoder for

  • encFps (int, Optional) – Specify encoding FPS

  • encQuality (int, Optional) – Specify encoding quality (1-100)

Raises
  • ValueError – if cameraName is not a supported camera name

  • RuntimeError – if specified camera node was not present

enableLowBandwidth(poeQuality)

Enables low-bandwidth mode

Parameters

poeQuality (int, Optional) – PoE encoding quality, can decrease frame quality but decrease latency

setXlinkChunkSize(chunkSize)
setCameraTuningBlob(path)