Pipeline

Pipeline is a collection of nodes and links between them. This flow provides an extensive flexibility that users get for their OAK device. When pipeline object is passed to the Device object, pipeline gets serialized to JSON and sent to the OAK device via XLink.

Pipeline first steps

To get DepthAI up and running, you have to create 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()

# If required, specify OpenVINO version
pipeline.setOpenVINOVersion(depthai.OpenVINO.Version.VERSION_2021_4)

# Create nodes, configure them and link them together

# Upload the pipeline to the device
with depthai.Device(pipeline) as device:
  # Set input/output queues to configure device/host communication through the XLink...

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

Using multiple devices

If user has multiple DepthAI devices, each device can run a different 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.

How to place it

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

Reference

class depthai.Pipeline
create(self: depthai.Pipeline, arg0: object)depthai.Node
createAprilTag(self: depthai.Pipeline)depthai.node.AprilTag
createCamera(self: depthai.Pipeline)depthai.node.Camera
createColorCamera(self: depthai.Pipeline)depthai.node.ColorCamera
createDetectionParser(self: depthai.Pipeline)depthai.node.DetectionParser
createEdgeDetector(self: depthai.Pipeline)depthai.node.EdgeDetector
createFeatureTracker(self: depthai.Pipeline)depthai.node.FeatureTracker
createIMU(self: depthai.Pipeline)depthai.node.IMU
createImageManip(self: depthai.Pipeline)depthai.node.ImageManip
createMobileNetDetectionNetwork(self: depthai.Pipeline)depthai.node.MobileNetDetectionNetwork
createMobileNetSpatialDetectionNetwork(self: depthai.Pipeline)depthai.node.MobileNetSpatialDetectionNetwork
createMonoCamera(self: depthai.Pipeline)depthai.node.MonoCamera
createNeuralNetwork(self: depthai.Pipeline)depthai.node.NeuralNetwork
createObjectTracker(self: depthai.Pipeline)depthai.node.ObjectTracker
createSPIIn(self: depthai.Pipeline)depthai.node.SPIIn
createSPIOut(self: depthai.Pipeline)depthai.node.SPIOut
createScript(self: depthai.Pipeline)depthai.node.Script
createSpatialLocationCalculator(self: depthai.Pipeline)depthai.node.SpatialLocationCalculator
createStereoDepth(self: depthai.Pipeline)depthai.node.StereoDepth
createSystemLogger(self: depthai.Pipeline)depthai.node.SystemLogger
createUVC(self: depthai.Pipeline)depthai.node.UVC
createVideoEncoder(self: depthai.Pipeline)depthai.node.VideoEncoder
createWarp(self: depthai.Pipeline)depthai.node.Warp
createXLinkIn(self: depthai.Pipeline)depthai.node.XLinkIn
createXLinkOut(self: depthai.Pipeline)depthai.node.XLinkOut
createYoloDetectionNetwork(self: depthai.Pipeline)depthai.node.YoloDetectionNetwork
createYoloSpatialDetectionNetwork(self: depthai.Pipeline)depthai.node.YoloSpatialDetectionNetwork
getAllNodes(*args, **kwargs)

Overloaded function.

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

  2. getAllNodes(self: depthai.Pipeline) -> list[depthai.Node]

getAssetManager(*args, **kwargs)

Overloaded function.

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

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

getBoardConfig(self: depthai.Pipeline)depthai.BoardConfig
getCalibrationData(self: depthai.Pipeline)depthai.CalibrationHandler
getConnectionMap(self: depthai.Pipeline)dict[int, set[depthai.Node.Connection]]
getConnections(self: depthai.Pipeline)list[depthai.Node.Connection]
getDeviceConfig(self: depthai.Pipeline)depthai.Device.Config
getGlobalProperties(self: depthai.Pipeline)depthai.GlobalProperties
getNode(*args, **kwargs)

Overloaded function.

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

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

getNodeMap(self: depthai.Pipeline)dict[int, depthai.Node]
getOpenVINOVersion(self: depthai.Pipeline)depthai.OpenVINO.Version
getRequiredOpenVINOVersion(self: depthai.Pipeline) → Optional[depthai.OpenVINO.Version]
link(self: depthai.Pipeline, arg0: depthai.Node.Output, arg1: depthai.Node.Input)None
remove(self: depthai.Pipeline, node: depthai.Node)None
serializeToJson(self: depthai.Pipeline) → json
setBoardConfig(self: depthai.Pipeline, arg0: depthai.BoardConfig)None
setCalibrationData(self: depthai.Pipeline, calibrationDataHandler: depthai.CalibrationHandler)None
setCameraTuningBlobPath(self: depthai.Pipeline, path: Path)None
setOpenVINOVersion(self: depthai.Pipeline, version: depthai.OpenVINO.Version)None
setSippBufferSize(self: depthai.Pipeline, sizeBytes: int)None
setSippDmaBufferSize(self: depthai.Pipeline, sizeBytes: int)None
setXLinkChunkSize(self: depthai.Pipeline, sizeBytes: int)None
unlink(self: depthai.Pipeline, arg0: depthai.Node.Output, arg1: depthai.Node.Input)None
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(SerializationType type = DEFAULT_SERIALIZATION_TYPE) const

Return

Pipeline schema

void serialize(PipelineSchema &schema, Assets &assets, std::vector<std::uint8_t> &assetStorage) const
nlohmann::json serializeToJson() const

Returns whole pipeline represented as JSON.

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

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 possible OpenVINO version to run this pipeline.

tl::optional<OpenVINO::Version> getRequiredOpenVINOVersion() const

Get required OpenVINO version to run this pipeline. Can be none.

void setCameraTuningBlobPath(const dai::Path &path)

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

void setXLinkChunkSize(int sizeBytes)

Set chunk size for splitting device-sent XLink packets, in bytes. A larger value could increase performance, with 0 disabling chunking. A negative value won’t modify the device defaults - configured per protocol, currently 64*1024 for both USB and Ethernet.

void setSippBufferSize(int sizeBytes)

SIPP (Signal Image Processing Pipeline) internal memory pool. SIPP is a framework used to schedule HW filters, e.g. ISP, Warp, Median filter etc. Changing the size of this pool is meant for advanced use cases, pushing the limits of the HW. By default memory is allocated in high speed CMX memory. Setting to 0 will allocate in DDR 256 kilobytes. Units are bytes.

void setSippDmaBufferSize(int sizeBytes)

SIPP (Signal Image Processing Pipeline) internal DMA memory pool. SIPP is a framework used to schedule HW filters, e.g. ISP, Warp, Median filter etc. Changing the size of this pool is meant for advanced use cases, pushing the limits of the HW. Memory is allocated in high speed CMX memory Units are bytes.

bool isOpenVINOVersionCompatible(OpenVINO::Version version) const

Checks whether a given OpenVINO version is compatible with the pipeline.

void setBoardConfig(BoardConfig board)

Sets board configuration.

BoardConfig getBoardConfig() const

Gets board configuration.

Device::Config getDeviceConfig() const

Get device configuration needed for this pipeline.

Private Functions

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

Private Members

std::shared_ptr<PipelineImpl> pimpl

Got questions?

Head over to Discussion Forum for technical support or any other questions you might have.