此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 管道第一步
  • 使用多个设备
  • 如何放置它
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包
最后更新
管道是节点及其之间链接的集合。 这种流程为用户提供了极大的灵活性,可用于他们的 OAK 设备。

管道第一步

要启动并运行 DepthAI,您必须创建一个管道,用节点填充它,配置节点并将它们连接起来。之后,管道 可以加载到设备上并启动。
Python
1with dai.Pipeline() as pipeline:
2
3  # 创建节点,配置它们并将它们连接起来
4  ...
5
6  # 将管道上传到设备
7  pipeline.start()

使用多个设备

如果用户有多个 Luxonis 设备,每个设备可以运行不同的管道或相同的管道。 有关更多信息,请参阅多设备设置。

如何放置它

Python

Python
1pipeline = dai.Pipeline() # 尽管我们通常更喜欢使用上下文管理器(with 语句)

C++

C++
1dai::Pipeline pipeline;

参考

class

dai::Pipeline

#include Pipeline.hpp
using
AutoCalibrationMode = PipelineAutoCalibrationMode
using
NodeConnectionMap = PipelineImpl::NodeConnectionMap
inline function
PipelineImpl * impl()
inline function
const PipelineImpl * impl()
inline function
std::vector< std::shared_ptr< Node > > getSourceNodes()
explicit function
Pipeline(bool createImplicitDevice)
Creates a pipeline
Parameters
  • createImplicitDevice: If true, creates a default device (default = true)
explicit function
Pipeline(std::shared_ptr< Device > device)
Creates a pipeline with specified device
explicit function
Pipeline(std::shared_ptr< PipelineImpl > pimpl)
Creates a pipeline with specified device
inline function
GlobalProperties getGlobalProperties()
Returns
Global properties of current pipeline
inline function
void setGlobalProperties(GlobalProperties globalProperties)
Sets global properties of pipeline
inline function
void setDefaultDeviceProperties(DeviceProperties deviceProperties)
Sets default device properties
inline function
void setDefaultDevicePropertiesRef(DeviceProperties * deviceProperties)
Sets default device properties reference. The properties should live at least as long as the pipeline.
inline function
std::optional< DeviceProperties > getDefaultDeviceProperties()
Gets a copy of default device properties. If pipeline is in host only mode, returns host properties, otherwise returns device properties
function
PipelineSchema getPipelineSchema(SerializationType type, bool includePipelineDebugging)
Returns
Pipeline schema
function
PipelineSchema getDevicePipelineSchema(SerializationType type, bool includePipelineDebugging)
Returns
Device pipeline schema (without host only nodes and connections)
inline function
void serialize(PipelineSchema & schema, Assets & assets, std::vector< std::uint8_t > & assetStorage)
inline function
nlohmann::json serializeToJson(bool includeAssests)
Returns whole pipeline represented as JSON.
inline function
std::shared_ptr< N > create(Args &&... args)
Creates and adds a node to the pipeline.Node is specified by template argument N
inline function
std::enable_if_t< std::is_base_of< DeviceNode, N >::value, std::shared_ptr< N > > create(std::shared_ptr< Device > device, Args &&... args)
Creates a device node on the specified device and adds it to the pipeline. The device becomes part of the pipeline on first use. Only device nodes can be created this way - creating a host node with a device is a compile-time error.
inline function
std::enable_if_t< std::is_base_of< DeviceNode, N >::value, std::shared_ptr< N > > createForDevice(std::shared_ptr< Device > device, Args &&... args)
Creates a device node on the specified device and adds it to the pipeline. Same as create(device, ...) - kept as an explicitly named alternative.
inline function
void add(std::shared_ptr< Node > node)
Adds an existing node to the pipeline
inline function
void remove(std::shared_ptr< Node > node)
Removes a node from pipeline.
inline function
std::vector< std::shared_ptr< Node > > getAllNodes()
Get a vector of all nodes.
inline function
std::shared_ptr< const Node > getNode(Node::Id id)
Get node with id if it exists, nullptr otherwise.
inline function
std::shared_ptr< Node > getNode(Node::Id id)
Get node with id if it exists, nullptr otherwise.
inline function
std::vector< Node::Connection > getConnections()
Get all connections.
inline function
NodeConnectionMap getConnectionMap()
inline function
const AssetManager & getAssetManager()
Get pipelines AssetManager as reference.
inline function
AssetManager & getAssetManager()
Get pipelines AssetManager as reference.
inline function
void setOpenVINOVersion(OpenVINO::Version version)
Set a specific OpenVINO version to use with this pipeline.
inline function
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.
inline function
CalibrationHandler getCalibrationData()
gets the calibration data which is set through pipeline
Returns
the calibrationHandler with calib data in the pipeline
inline function
bool isCalibrationDataAvailable()
check if calib data is available on the device
Returns
true - calib data is available
Returns
false - calib data is not available
inline function
std::optional< EepromData > getEepromData()
gets the eeprom data from the pipeline
Returns
eepromData from the the pipeline
inline function
void setEepromData(std::optional< EepromData > eepromData)
Sets the eeprom data in pipeline
Parameters
  • eepromData: EepromData object that is loaded in the pipeline.
inline function
void setMultiDeviceCalibration(std::vector< MultiDeviceExtrinsics > graph)
Sets the cross-device calibration graph shared by all devices in the pipeline.The graph is validated with beta::MultiDeviceCalibrationHandler. Before the pipeline is built it is only stored and travels to the devices with the pipeline schema. On a built pipeline it is additionally checked against every assigned device's local calibration and pushed to all assigned devices at runtime, so already streaming Camera and ToF nodes switch to the new graph.
Parameters
  • std::invalid_argument: when the graph structure is invalid
  • std::runtime_error: when a device's local calibration does not match the graph or a device rejects the update; devices updated before the failure are restored to the previous graph and the pipeline keeps the previous graph
Parameters
  • graph: Directed cross-device calibration edges.
inline function
std::optional< std::vector< MultiDeviceExtrinsics > > getMultiDeviceCalibration()
Gets the cross-device calibration graph from the pipeline
Returns
the graph when one is set, std::nullopt otherwise
inline function
void clearMultiDeviceCalibration()
Removes any cross-device calibration graph from the pipeline.On a built pipeline the removal is pushed to all assigned devices, which then publish their local calibration metadata again.
Parameters
  • std::runtime_error: when a device rejects the update
inline function
uint32_t getEepromId()
Gets the eeprom id from the pipeline
Returns
eeprom id from the pipeline
inline function
void setCameraTuningBlobPath(const fs::path & path)
Set a camera IQ (Image Quality) tuning blob, used for all cameras.
inline function
void setCameraTuningBlobPath(CameraBoardSocket socket, const fs::path & path)
Set a camera IQ (Image Quality) tuning blob, used for specific board socket.
inline function
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.
inline function
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.
inline function
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.
inline function
void setBoardConfig(BoardConfig board)
Sets board configuration.
inline function
void setAutoCalibrationMode(AutoCalibrationMode mode)
Sets implicit automatic calibration policy for this pipeline.
inline function
AutoCalibrationMode getAutoCalibrationMode()
Gets implicit automatic calibration policy for this pipeline.
inline function
BoardConfig getBoardConfig()
Gets board configuration.
inline function
Device::Config getDeviceConfig()
Get device configuration needed for this pipeline.
inline function
bool isRunning()
inline function
bool isBuilt()
inline function
void build()
inline function
void buildDevice()
inline function
void start()
inline function
void wait()
inline function
void stop()
inline function
void processTasks(bool waitForTasks, double timeoutSeconds)
inline function
void run()
inline function
std::shared_ptr< Device > getDefaultDevice()
inline function
std::shared_ptr< const Device > getDefaultDevice()
function
std::shared_ptr< Device > addDevice(std::shared_ptr< Device > device)
Add a device to the pipeline. The first device added to a pipeline created without an implicit device is promoted to the default device (master), so nodes created without an explicit device run on it.
Parameters
  • device: Already constructed device to add
Returns
The added device
function
std::shared_ptr< Device > addDevice(const DeviceInfo & deviceInfo)
Construct a device from the given device info and add it to the pipeline.
Parameters
  • deviceInfo: Device info to construct the device from
Returns
The constructed device
function
std::shared_ptr< Device > addDevice(const std::string & idOrIpOrName)
Construct a device from a device id, IP address or name and add it to the pipeline.
Parameters
  • idOrIpOrName: Device id, IP address or name to construct the device from
Returns
The constructed device
function
std::vector< std::shared_ptr< Device > > getDevices()
Get all devices that are part of this pipeline - the default device (master) first, then the rest in registration order. Devices become part of the pipeline explicitly via addDevice or implicitly on first use by a node.
inline function
DeviceState getDeviceState(const std::shared_ptr< Device > & device)
Get the pipeline-level state of a device: RUNNING, DISCONNECTED, RECONNECTING or FAILED. Losing a device does not stop the pipeline (its streams go idle) unless it was the last device alive or a device consuming other devices' streams. See setStopOnDeviceLoss to stop on any device loss.
inline function
void setDeviceStateCallback(std::function< void(std::shared_ptr< Device >, DeviceState)> callback)
Set a callback invoked on every device state transition. The callback is invoked from the affected device's monitor thread; do not block in it and do not call pipeline stop/start from it directly.
inline function
void setStopOnDeviceLoss(bool stop)
Stop the pipeline when any device that runs a node is lost for good (strict mode). Off by default (permissive mode): the pipeline keeps running, the lost device's streams go idle and it stops only when the last device alive or a device consuming other devices' streams is lost.A device is lost for good when its state becomes FAILED - after the reconnection attempts are exhausted. To stop as soon as a device disconnects, disable reconnection on the devices (Device::setMaxReconnectionAttempts(0)). Can be changed while the pipeline runs.
Parameters
  • stop: True to stop the pipeline on any device loss
inline function
bool getStopOnDeviceLoss()
Get whether the pipeline stops when any device that runs a node is lost for good.
function
void setCameraTuningBlobPath(const std::shared_ptr< Device > & device, const fs::path & path)
Set a camera IQ (Image Quality) tuning blob for all cameras of the given pipeline device.
function
void setCameraTuningBlobPath(const std::shared_ptr< Device > & device, CameraBoardSocket socket, const fs::path & path)
Set a camera IQ (Image Quality) tuning blob for a specific board socket of the given pipeline device.
function
void setXLinkChunkSize(const std::shared_ptr< Device > & device, int sizeBytes)
Set chunk size for splitting device-sent XLink packets for the given pipeline device; see the no-device overload.
function
void setSippBufferSize(const std::shared_ptr< Device > & device, int sizeBytes)
Set the SIPP buffer size of the given pipeline device; see the no-device overload.
function
void setSippDmaBufferSize(const std::shared_ptr< Device > & device, int sizeBytes)
Set the SIPP DMA buffer size of the given pipeline device; see the no-device overload.
function
void setBoardConfig(const std::shared_ptr< Device > & device, const BoardConfig & board)
Sets the board configuration for the given pipeline device. Board configuration is applied when a device boots, so for an already connected device it only takes effect on flows that (re)boot with this pipeline's configuration.
function
BoardConfig getBoardConfig(const std::shared_ptr< Device > & device)
Gets the board configuration of the given pipeline device.
function
Device::Config getDeviceConfig(const std::shared_ptr< Device > & device)
Get device configuration needed for this pipeline, for the given pipeline device.
function
void setCalibrationData(const std::shared_ptr< Device > & device, const CalibrationHandler & calibrationDataHandler)
Sets the calibration of the given pipeline device, overriding the one in eeprom.
function
bool isCalibrationDataAvailable(const std::shared_ptr< Device > & device)
Check if calibration data is available on the given pipeline device.
function
CalibrationHandler getCalibrationData(const std::shared_ptr< Device > & device)
Gets the calibration data of the given pipeline device.
function
void setEepromData(const std::shared_ptr< Device > & device, const std::optional< EepromData > & eepromData)
Sets the eeprom data of the given pipeline device.
function
std::optional< EepromData > getEepromData(const std::shared_ptr< Device > & device)
Gets the eeprom data of the given pipeline device.
function
uint32_t getEepromId(const std::shared_ptr< Device > & device)
Gets the eeprom id of the given pipeline device.
function
void setDeviceProperties(const std::shared_ptr< Device > & device, const DeviceProperties & deviceProperties)
Sets device properties of the given pipeline device.
function
DeviceProperties getDeviceProperties(const std::shared_ptr< Device > & device)
Gets device properties of the given pipeline device.
inline function
std::string getTelemetryPipelineId()
inline function
void addTask(std::function< void()> task)
function
void enableHolisticRecord(const RecordConfig & config)
Record and Replay.
function
void enableHolisticReplay(const std::string & pathToRecording)
function
bool isHolisticRecordEnabled()
function
bool isHolisticReplayEnabled()
function
void enablePipelineDebugging(bool enable)
Pipeline debugging.
function
bool isPipelineDebuggingEnabled()
function
std::shared_ptr< MessageQueue > getPipelineStateOut()
function
std::shared_ptr< InputQueue > getPipelineStateRequest()
function
PipelineStateApi getPipelineState()