# Pipeline

Pipeline is a collection of [Nodes](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes.md) and links between
them. This flow provides an extensive flexibility that users get for their OAK device.

## 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](https://docs.luxonis.com/software-v3/depthai/depthai-components/device.md) and be started.

```python
with dai.Pipeline() as pipeline:

  # Create nodes, configure them and link them together
  ...

  # Upload the pipeline to the device
  pipeline.start()
```

## Using multiple devices

If user has multiple Luxonis' devices, each device can run a different pipeline or the same pipeline. See [Multi-device
Setup](https://docs.luxonis.com/software-v3/depthai/tutorials/multi-device-setup.md) for more information.

## How to place it

#### Python

```python
pipeline = dai.Pipeline() # though we usually prefer to use the context manager (with statement)
```

#### C++

```cpp
dai::Pipeline pipeline;
```

## Reference

### dai::Pipeline

Kind: class

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

#### PipelineAutoCalibrationMode AutoCalibrationMode

Kind: enum

#### PipelineImpl::NodeConnectionMap NodeConnectionMap

Kind: enum

#### PipelineImpl * impl()

Kind: function

#### const PipelineImpl * impl()

Kind: function

#### std::vector< std::shared_ptr< Node > > getSourceNodes()

Kind: function

#### Pipeline(bool createImplicitDevice)

Kind: function

Creates a pipeline parameters: createImplicitDevice: If true, creates a default device (default = true)

#### Pipeline(std::shared_ptr< Device > device)

Kind: function

Creates a pipeline with specified device

#### Pipeline(std::shared_ptr< PipelineImpl > pimpl)

Kind: function

Creates a pipeline with specified device

#### GlobalProperties getGlobalProperties()

Kind: function

return: Global properties of current pipeline

#### void setGlobalProperties(GlobalProperties globalProperties)

Kind: function

Sets global properties of pipeline

#### void setDefaultDeviceProperties(DeviceProperties deviceProperties)

Kind: function

Sets default device properties

#### void setDefaultDevicePropertiesRef(DeviceProperties * deviceProperties)

Kind: function

Sets default device properties reference. The properties should live at least as long as the pipeline.

#### std::optional< DeviceProperties > getDefaultDeviceProperties()

Kind: function

Gets a copy of default device properties. If pipeline is in host only mode, returns host properties, otherwise returns device
properties

#### PipelineSchema getPipelineSchema(SerializationType type, bool includePipelineDebugging)

Kind: function

return: Pipeline schema

#### PipelineSchema getDevicePipelineSchema(SerializationType type, bool includePipelineDebugging)

Kind: function

return: Device pipeline schema (without host only nodes and connections)

#### void serialize(PipelineSchema & schema, Assets & assets, std::vector< std::uint8_t > & assetStorage)

Kind: function

#### nlohmann::json serializeToJson(bool includeAssests)

Kind: function

Returns whole pipeline represented as JSON.

#### std::shared_ptr< N > create(Args &&... args)

Kind: function

Creates and adds a node to the pipeline. Node is specified by template argument N

#### void add(std::shared_ptr< Node > node)

Kind: function

Adds an existing node to the pipeline

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

Kind: function

Removes a node from pipeline.

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

Kind: function

Get a vector of all nodes.

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

Kind: function

Get node with id if it exists, nullptr otherwise.

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

Kind: function

Get node with id if it exists, nullptr otherwise.

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

Kind: function

Get all connections.

#### NodeConnectionMap getConnectionMap()

Kind: function

#### const AssetManager & getAssetManager()

Kind: function

Get pipelines AssetManager as reference.

#### AssetManager & getAssetManager()

Kind: function

Get pipelines AssetManager as reference.

#### void setOpenVINOVersion(OpenVINO::Version version)

Kind: function

Set a specific OpenVINO version to use with this pipeline.

#### void setCalibrationData(CalibrationHandler calibrationDataHandler)

Kind: function

Sets the calibration in pipeline which overrides the calibration data in eeprom parameters: calibrationDataHandler:
CalibrationHandler object which is loaded with calibration information.

#### CalibrationHandler getCalibrationData()

Kind: function

gets the calibration data which is set through pipeline return: the calibrationHandler with calib data in the pipeline

#### bool isCalibrationDataAvailable()

Kind: function

check if calib data is available on the device return: true - calib data is available return: false - calib data is not available

#### std::optional< EepromData > getEepromData()

Kind: function

gets the eeprom data from the pipeline return: eepromData from the the pipeline

#### void setEepromData(std::optional< EepromData > eepromData)

Kind: function

Sets the eeprom data in pipeline parameters: eepromData: EepromData object that is loaded in the pipeline.

#### uint32_t getEepromId()

Kind: function

Gets the eeprom id from the pipeline return: eeprom id from the pipeline

#### void setCameraTuningBlobPath(const fs::path & path)

Kind: function

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

#### void setCameraTuningBlobPath(CameraBoardSocket socket, const fs::path & path)

Kind: function

Set a camera IQ (Image Quality) tuning blob, used for specific board socket.

#### void setXLinkChunkSize(int sizeBytes)

Kind: function

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)

Kind: function

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)

Kind: function

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.

#### void setBoardConfig(BoardConfig board)

Kind: function

Sets board configuration.

#### void setAutoCalibration(AutoCalibrationMode mode)

Kind: function

Sets implicit automatic calibration policy for this pipeline.

#### AutoCalibrationMode getAutoCalibration()

Kind: function

Gets implicit automatic calibration policy for this pipeline.

#### void setAutoCalibrationMode(AutoCalibrationMode mode)

Kind: function

Sets implicit automatic calibration policy for this pipeline.

#### AutoCalibrationMode getAutoCalibrationMode()

Kind: function

Gets implicit automatic calibration policy for this pipeline.

#### BoardConfig getBoardConfig()

Kind: function

Gets board configuration.

#### Device::Config getDeviceConfig()

Kind: function

Get device configuration needed for this pipeline.

#### bool isRunning()

Kind: function

#### bool isBuilt()

Kind: function

#### void build()

Kind: function

#### void buildDevice()

Kind: function

#### void start()

Kind: function

#### void wait()

Kind: function

#### void stop()

Kind: function

#### void processTasks(bool waitForTasks, double timeoutSeconds)

Kind: function

#### void run()

Kind: function

#### std::shared_ptr< Device > getDefaultDevice()

Kind: function

#### void addTask(std::function< void()> task)

Kind: function

#### void enableHolisticRecord(const RecordConfig & config)

Kind: function

Record and Replay.

#### void enableHolisticReplay(const std::string & pathToRecording)

Kind: function

#### bool isHolisticRecordEnabled()

Kind: function

#### bool isHolisticReplayEnabled()

Kind: function

#### void enablePipelineDebugging(bool enable)

Kind: function

Pipeline debugging.

#### bool isPipelineDebuggingEnabled()

Kind: function

#### std::shared_ptr< MessageQueue > getPipelineStateOut()

Kind: function

#### std::shared_ptr< InputQueue > getPipelineStateRequest()

Kind: function

#### PipelineStateApi getPipelineState()

Kind: function
