Pipeline

Pipeline is a collection of nodes and links between them. This flow provides extensive flexibility that users get for their DepthAI device.

Pipeline first steps

To get DepthAI up and running, one has to define a pipeline, populate it with nodes, configure the nodes and link them together. After that, the pipeline can be loaded onto the Device and be started.

pipeline = depthai.Pipeline()

# Create nodes, configure them and link them together

# Upload the pipeline to the device
with depthai.Device(pipeline) as device:
  # Start the pipeline that is now on the device
  device.startPipeline()

  # Set input/output queues to configure device/host communication through the XLink...

Using multiple devices

If user has multiple DepthAI devices, each device can run a separate pipeline or the same pipeline (demo here). To use different pipeline for each device, you can create multiple pipelines and pass the desired pipeline to the desired device on initialization.

Specifying OpenVINO version

When using a NN blob that was not compiled with the latest OpenVINO (that DepthAI supports), you have to specify the OpenVINO version of the pipeline. The reason behind this is that OpenVINO doesn’t provide version inside the blob.

pipeline = depthai.Pipeline()
# Set the correct version:
pipeline.setOpenVINOVersion(depthai.OpenVINO.Version.VERSION_2020_1)

How to place it

pipeline = dai.Pipeline()
dai::Pipeline pipeline;

Reference

class depthai.Pipeline

Represents the pipeline, set of nodes and connections between them

createColorCamera(self: depthai.Pipeline)depthai.ColorCamera
createIMU(self: depthai.Pipeline)depthai.IMU
createImageManip(self: depthai.Pipeline)depthai.ImageManip
createMobileNetDetectionNetwork(self: depthai.Pipeline)depthai.MobileNetDetectionNetwork
createMobileNetSpatialDetectionNetwork(self: depthai.Pipeline)depthai.MobileNetSpatialDetectionNetwork
createMonoCamera(self: depthai.Pipeline)depthai.MonoCamera
createNeuralNetwork(self: depthai.Pipeline)depthai.NeuralNetwork
createObjectTracker(self: depthai.Pipeline)depthai.ObjectTracker
createSPIOut(self: depthai.Pipeline)depthai.SPIOut
createSpatialLocationCalculator(self: depthai.Pipeline)depthai.SpatialLocationCalculator
createStereoDepth(self: depthai.Pipeline)depthai.StereoDepth
createSystemLogger(self: depthai.Pipeline)depthai.SystemLogger
createVideoEncoder(self: depthai.Pipeline)depthai.VideoEncoder
createXLinkIn(self: depthai.Pipeline)depthai.XLinkIn
createXLinkOut(self: depthai.Pipeline)depthai.XLinkOut
createYoloDetectionNetwork(self: depthai.Pipeline)depthai.YoloDetectionNetwork
createYoloSpatialDetectionNetwork(self: depthai.Pipeline)depthai.YoloSpatialDetectionNetwork
getAllAssets(self: depthai.Pipeline)depthai.AssetManager

Get assets on the pipeline includes nodes assets

getAllNodes(*args, **kwargs)

Overloaded function.

  1. getAllNodes(self: depthai.Pipeline) -> List[depthai.Node]

Get a vector of all nodes

  1. getAllNodes(self: depthai.Pipeline) -> List[depthai.Node]

Get a vector of all nodes

getAssetManager(*args, **kwargs)

Overloaded function.

  1. getAssetManager(self: depthai.Pipeline) -> depthai.AssetManager

Get pipelines AssetManager as reference

  1. getAssetManager(self: depthai.Pipeline) -> depthai.AssetManager

Get pipelines AssetManager as reference

getCalibrationData(self: depthai.Pipeline) → dai::CalibrationHandler

gets the calibration data which is set through pipeline

Returns

the calibrationHandler with calib data in the pipeline

getConnectionMap(self: depthai.Pipeline) → Dict[int, Set[depthai.Node.Connection]]

Get a reference to internal connection representation

getConnections(self: depthai.Pipeline) → List[depthai.Node.Connection]

Get all connections

getGlobalProperties(self: depthai.Pipeline)depthai.GlobalProperties
Returns

Global properties of current pipeline

getNode(*args, **kwargs)

Overloaded function.

  1. getNode(self: depthai.Pipeline, arg0: int) -> depthai.Node

Get node with id if it exists, nullptr otherwise

  1. getNode(self: depthai.Pipeline, arg0: int) -> depthai.Node

Get node with id if it exists, nullptr otherwise

getNodeMap(self: depthai.Pipeline) → Dict[int, depthai.Node]

Get a reference to internal node map

getOpenVINOVersion(self: depthai.Pipeline)depthai.OpenVINO.Version

Get required OpenVINO version to run this pipeline

link(self: depthai.Pipeline, arg0: depthai.Node.Output, arg1: depthai.Node.Input)None

Link output to an input. Both nodes must be on the same pipeline

Throws an error if they aren’t or cannot be connected

Parameter out:

Nodes output to connect from

Parameter in:

Nodes input to connect to

remove(self: depthai.Pipeline, node: depthai.Node)None

Removes a node from pipeline

setCalibrationData(self: depthai.Pipeline, calibrationDataHandler: dai::CalibrationHandler)None

Sets the calibration in pipeline which overrides the calibration data in eeprom

Parameter calibrationDataHandler:

CalibrationHandler object which is loaded with calibration information.

setCameraTuningBlobPath(self: depthai.Pipeline, path: str)None

Set a camera IQ (Image Quality) tuning blob, used for all cameras

setOpenVINOVersion(self: depthai.Pipeline, version: depthai.OpenVINO.Version = <Version.VERSION_2021_3: 6>)None

Set a specific OpenVINO version to use with this pipeline

unlink(self: depthai.Pipeline, arg0: depthai.Node.Output, arg1: depthai.Node.Input)None

Unlink output from an input.

Throws an error if link doesn’t exists

Parameter out:

Nodes output to unlink from

Parameter in:

Nodes input to unlink to

class dai::Pipeline

Represents the pipeline, set of nodes and connections between them.

Public Types

using NodeConnectionMap = PipelineImpl::NodeConnectionMap
using NodeMap = PipelineImpl::NodeMap

Public Functions

Pipeline()

Constructs a new pipeline

Pipeline(const std::shared_ptr<PipelineImpl> &pimpl)
Pipeline clone() const

Clone the pipeline (Creates a copy)

GlobalProperties getGlobalProperties() const

Return

Global properties of current pipeline

PipelineSchema getPipelineSchema()

Return

Pipeline schema

void serialize(PipelineSchema &schema, Assets &assets, std::vector<std::uint8_t> &assetStorage, OpenVINO::Version &version) const
template<class N>
std::shared_ptr<N> create()

Adds a node to pipeline.

Node is specified by template argument N

void remove(std::shared_ptr<Node> node)

Removes a node from pipeline.

std::vector<std::shared_ptr<const Node>> getAllNodes() const

Get a vector of all nodes.

std::vector<std::shared_ptr<Node>> getAllNodes()

Get a vector of all nodes.

std::shared_ptr<const Node> getNode(Node::Id id) const

Get node with id if it exists, nullptr otherwise.

std::shared_ptr<Node> getNode(Node::Id id)

Get node with id if it exists, nullptr otherwise.

std::vector<Node::Connection> getConnections() const

Get all connections.

const NodeConnectionMap &getConnectionMap() const

Get a reference to internal connection representation.

const NodeMap &getNodeMap() const

Get a reference to internal node map.

void link(const Node::Output &out, const Node::Input &in)

Link output to an input. Both nodes must be on the same pipeline

Throws an error if they aren’t or cannot be connected

Parameters
  • out: Nodes output to connect from

  • in: Nodes input to connect to

void unlink(const Node::Output &out, const Node::Input &in)

Unlink output from an input.

Throws an error if link doesn’t exists

Parameters
  • out: Nodes output to unlink from

  • in: Nodes input to unlink to

AssetManager getAllAssets() const

Get assets on the pipeline includes nodes assets.

const AssetManager &getAssetManager() const

Get pipelines AssetManager as reference.

AssetManager &getAssetManager()

Get pipelines AssetManager as reference.

void setOpenVINOVersion(OpenVINO::Version version)

Set a specific OpenVINO version to use with this pipeline.

void setCalibrationData(CalibrationHandler calibrationDataHandler)

Sets the calibration in pipeline which overrides the calibration data in eeprom

Parameters
  • calibrationDataHandler: CalibrationHandler object which is loaded with calibration information.

CalibrationHandler getCalibrationData() const

gets the calibration data which is set through pipeline

Return

the calibrationHandler with calib data in the pipeline

OpenVINO::Version getOpenVINOVersion() const

Get required OpenVINO version to run this pipeline.

void setCameraTuningBlobPath(const std::string &path)

Set a camera IQ (Image Quality) tuning blob, used for all cameras.

Public Static Attributes

constexpr auto DEFAULT_OPENVINO_VERSION = PipelineImpl::DEFAULT_OPENVINO_VERSION

Default Pipeline openvino version.

Private Functions

PipelineImpl *impl()
const PipelineImpl *impl() const

Private Members

std::shared_ptr<PipelineImpl> pimpl

Got questions?

We’re always happy to help with code or other questions you might have.