# 管道

管道是 [节点](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes.md) 及其之间链接的集合。 这种流程为用户提供了极大的灵活性，以操作其 OAK 设备。

## 管道入门

要启动 DepthAI，您必须创建一个管道，填充节点，配置节点并将它们链接在一起。之后，管道 可以加载到
[设备](https://docs.luxonis.com/software-v3/depthai/depthai-components/device.md) 上并启动。

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

  # 创建节点，配置它们并链接在一起
  ...

  # 将管道上传到设备
  pipeline.start()
```

## 使用多个设备

如果用户有多个 Luxonis 设备，每个设备可以运行不同的管道或相同的管道。 有关更多信息，请参阅
[多设备设置](https://docs.luxonis.com/software-v3/depthai/tutorials/multi-device-setup.md)。

## 如何放置

#### Python

```python
pipeline = dai.Pipeline() # 不过我们通常更倾向于使用上下文管理器（with 语句）
```

#### C++

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

## 参考

### 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 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

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

Kind: function

#### std::string getTelemetryPipelineId()

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
