# 管道

管道是[节点](https://docs.luxonis.com/software/depthai-components/nodes.md)及其连接的集合。
这种流程为用户提供了极大的灵活性，可用于OAK设备。当管道对象被传递给[设备](https://docs.luxonis.com/software/depthai-components/device.md)对象时，管道会被序列化为JSON，并通过XLink发送到OAK设备。

## 管道初始步骤

要启动并运行DepthAI，您需要创建管道、填充节点、配置节点并将它们连接起来。之后，管道可以加载到[设备](https://docs.luxonis.com/software/depthai-components/device.md)上并启动。

```python
pipeline = depthai.pipeline()

# 如有需要，指定OpenVINO版本
pipeline.setOpenVINOVersion(depthai.OpenVINO.Version.VERSION_2021_4)

# 创建节点，配置并连接它们

# 将管道上传到设备
with depthai.Device(pipeline) as device:
  # 设置输入/输出队列以通过XLink配置设备/主机通信...
```

## 指定OpenVINO版本

当使用未使用最新OpenVINO（DepthAI支持）编译的NN blob时，您需要指定管道的OpenVINO版本。原因在于OpenVINO不提供blob内部的版本信息。

```python
pipeline = depthai.pipeline()
# 设置正确的版本：
pipeline.setOpenVINOVersion(depthai.OpenVINO.Version.VERSION_2021_4)
```

## 使用多个设备

如果用户拥有多个Luxonis设备，每个设备可以运行不同的管道或相同的管道（[演示在此](https://github.com/luxonis/oak-examples/tree/master/gen2-multiple-devices)）。要为每个设备使用不同的管道，您可以创建多个管道，并在初始化时将所需的管道传递给相应的设备。有关更多信息，请参阅[多设备设置](https://docs.luxonis.com/software/depthai/multi-device-setup.md)。

## 如何放置

#### Python

```python
pipeline = dai.Pipeline()
```

#### C++

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

## 参考

### depthai.Pipeline

Kind: Class

#### __init__(self)

Kind: Method

Constructs a new pipeline

#### create(self, arg0: typing.Any) -> Node: Node

Kind: Method

#### createAprilTag(self) -> node.AprilTag: node.AprilTag

Kind: Method

#### createCamera(self) -> node.Camera: node.Camera

Kind: Method

#### createColorCamera(self) -> node.ColorCamera: node.ColorCamera

Kind: Method

#### createDetectionParser(self) -> node.DetectionParser: node.DetectionParser

Kind: Method

#### createEdgeDetector(self) -> node.EdgeDetector: node.EdgeDetector

Kind: Method

#### createFeatureTracker(self) -> node.FeatureTracker: node.FeatureTracker

Kind: Method

#### createIMU(self) -> node.IMU: node.IMU

Kind: Method

#### createImageManip(self) -> node.ImageManip: node.ImageManip

Kind: Method

#### createMobileNetDetectionNetwork(self) -> node.MobileNetDetectionNetwork: node.MobileNetDetectionNetwork

Kind: Method

#### createMobileNetSpatialDetectionNetwork(self) -> node.MobileNetSpatialDetectionNetwork: node.MobileNetSpatialDetectionNetwork

Kind: Method

#### createMonoCamera(self) -> node.MonoCamera: node.MonoCamera

Kind: Method

#### createNeuralNetwork(self) -> node.NeuralNetwork: node.NeuralNetwork

Kind: Method

#### createObjectTracker(self) -> node.ObjectTracker: node.ObjectTracker

Kind: Method

#### createSPIIn(self) -> node.SPIIn: node.SPIIn

Kind: Method

#### createSPIOut(self) -> node.SPIOut: node.SPIOut

Kind: Method

#### createScript(self) -> node.Script: node.Script

Kind: Method

#### createSpatialLocationCalculator(self) -> node.SpatialLocationCalculator: node.SpatialLocationCalculator

Kind: Method

#### createStereoDepth(self) -> node.StereoDepth: node.StereoDepth

Kind: Method

#### createSystemLogger(self) -> node.SystemLogger: node.SystemLogger

Kind: Method

#### createUVC(self) -> node.UVC: node.UVC

Kind: Method

#### createVideoEncoder(self) -> node.VideoEncoder: node.VideoEncoder

Kind: Method

#### createWarp(self) -> node.Warp: node.Warp

Kind: Method

#### createXLinkIn(self) -> node.XLinkIn: node.XLinkIn

Kind: Method

#### createXLinkOut(self) -> node.XLinkOut: node.XLinkOut

Kind: Method

#### createYoloDetectionNetwork(self) -> node.YoloDetectionNetwork: node.YoloDetectionNetwork

Kind: Method

#### createYoloSpatialDetectionNetwork(self) -> node.YoloSpatialDetectionNetwork: node.YoloSpatialDetectionNetwork

Kind: Method

#### getAllNodes()

Kind: Method

#### getAssetManager()

Kind: Method

#### getBoardConfig(self) -> BoardConfig: BoardConfig

Kind: Method

Gets board configuration

#### getCalibrationData(self) -> CalibrationHandler: CalibrationHandler

Kind: Method

gets the calibration data which is set through pipeline

Returns:
the calibrationHandler with calib data in the pipeline

#### getConnectionMap(self) -> dict[int, set[Node.Connection]]: dict[int, set[Node.Connection]]

Kind: Method

Get a reference to internal connection representation

#### getConnections(self) -> list[Node.Connection]: list[Node.Connection]

Kind: Method

Get all connections

#### getDeviceConfig(self) -> Device.Config: Device.Config

Kind: Method

Get device configuration needed for this pipeline

#### getGlobalProperties(self) -> GlobalProperties: GlobalProperties

Kind: Method

Returns:
Global properties of current pipeline

#### getNode()

Kind: Method

#### getNodeMap(self) -> dict[int, Node]: dict[int, Node]

Kind: Method

Get a reference to internal node map

#### getOpenVINOVersion(self) -> OpenVINO.Version: OpenVINO.Version

Kind: Method

Get possible OpenVINO version to run this pipeline

#### getRequiredOpenVINOVersion(self) -> depthai.OpenVINO.Version|None: depthai.OpenVINO.Version|None

Kind: Method

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

#### link(self, arg0: Node.Output, arg1: Node.Input)

Kind: Method

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, node: Node)

Kind: Method

Removes a node from pipeline

#### serializeToJson(self) -> json: json

Kind: Method

Returns whole pipeline represented as JSON

#### setBoardConfig(self, arg0: BoardConfig)

Kind: Method

Sets board configuration

#### setCalibrationData(self, calibrationDataHandler: CalibrationHandler)

Kind: Method

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

Parameter ``calibrationDataHandler``:
CalibrationHandler object which is loaded with calibration information.

#### setCameraTuningBlobPath(self, path: Path)

Kind: Method

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

#### setOpenVINOVersion(self, version: OpenVINO.Version)

Kind: Method

Set a specific OpenVINO version to use with this pipeline

#### setSippBufferSize(self, sizeBytes: typing.SupportsInt)

Kind: Method

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.

#### setSippDmaBufferSize(self, sizeBytes: typing.SupportsInt)

Kind: Method

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.

#### setXLinkChunkSize(self, sizeBytes: typing.SupportsInt)

Kind: Method

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.

#### unlink(self, arg0: Node.Output, arg1: Node.Input)

Kind: Method

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
