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

本页目录

  • 输入和输出
  • 节点输入
  • 节点输出
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

设备节点

最后更新
在填充 管道时,节点是构建块。每个节点在 DepthAI 上提供特定的功能、一组可配置的属性和输入/输出。在管道上创建节点后,您还可以根据需要配置它并将其链接到其他节点。设备节点是一种特殊类型的节点,它在设备 SoC (RVC) 上运行,利用设备的资源。设备节点用于将主机从可以在设备本身上完成的处理任务中卸载。或者,主机节点可用于在主机 (PC) 上执行计算。在目录(页面左侧)中,所有节点都列在“节点”条目下。您可以单击它们以了解更多信息。

输入和输出

每个节点可以有零个、一个或多个输入和输出。例如,SystemLogger 节点没有输入和 1 个输出,EdgeDetector 有 2 个输入和 1 个输出(如下所示)。Script 节点可以有任意数量的输入/输出。
每个节点的输出都有其池;RAM 中的块,用于存储消息。每个节点的输入都有其消息指针队列(不存储消息本身,只存储指向它的指针)。

节点输入

节点输入队列是消息队列。它可以与其他节点的输出链接(这就是您链接节点的方式)。节点输入是可配置的 - 使用 input.setBlocking(bool) 和 input.setQueueSize(num),例如 edgeDetector.inputImage.setQueueSize(10)。如果输入队列已满,输入的行为取决于阻塞属性。假设我们已将 ColorCamera preview 输出与 NeuralNetwork input 输入链接。
如果输入设置为阻塞模式,并且输入队列已满,则来自 ColorCamera 的新消息将无法进入输入队列。这意味着 ColorCamera 将阻塞并等待发送其消息,直到它可以将消息推送到 NeuralNetwork 输入的队列。如果 ColorCamera 预览连接到多个输入,则行为相同,消息按顺序推送到每个输入。如果阻塞被禁用,新消息将推出旧消息。这消除了管道冻结的风险,但可能导致消息丢失(例如 ImgFrame)。

节点输出

节点输出消息。某些节点具有可配置的输出消息池。输出消息池是保留的内存区域(以减少内存碎片),用于保存输出消息。节点创建输出消息(例如 ImgFrame)后,它将根据链接节点输入/输出时指定的方式将其发送到其他节点。 目前,某些节点(VideoEncoder、NeuralNetwork、ImageManip、XLinkIn)可以配置池大小。 池的大小指定了在其他消息已在管道中时可以创建和发送多少消息。
class

dai::Node

#include Node.hppDerived by dai::NodeGroup, dai::ThreadedNode
using
Id = std::int64_t
Node identificator. Unique for every node on a single Pipeline.
variable
Id id
Id of node. Assigned after being placed on the pipeline.
variable
Id inputId
variable
Id outputId
variable
std::string alias
alias or name
function
Node(const Node &)
function
Node & operator=(const Node &)
function
Node(Node &&)
function
Node & operator=(Node &&)
function
std::string createUniqueInputName()
function
std::string createUniqueOutputName()
function
Pipeline getParentPipeline()
function
const Pipeline getParentPipeline()
inline function
std::string getAlias()
Get alias.
inline function
void setAlias(std::string alias)
Set alias.
function
const char * getName()
Retrieves nodes name.
inline function
void start()
Start node execution.
inline function
void wait()
Wait for node to finish execution.
inline function
void stop()
Stop node execution.
function
void stopPipeline()
function
void buildStage1()
Build stages;.
function
void buildStage2()
function
void buildStage3()
function
void postBuildStage()
function
std::vector< Output > getOutputs()
Retrieves all nodes outputs.
function
std::vector< Input > getInputs()
Retrieves all nodes inputs.
function
std::vector< Output * > getOutputRefs()
Retrieves reference to node outputs.
function
std::vector< const Output * > getOutputRefs()
Retrieves reference to node outputs.
function
std::vector< Input * > getInputRefs()
Retrieves reference to node inputs.
function
std::vector< const Input * > getInputRefs()
Retrieves reference to node inputs.
function
std::vector< OutputMap * > getOutputMapRefs()
Retrieves reference to node outputs.
function
std::vector< InputMap * > getInputMapRefs()
Retrieves reference to node inputs.
function
Output * getOutputRef(const std::string & name)
Retrieves reference to specific output.
function
Output * getOutputRef(const std::string & group, const std::string & name)
function
Input * getInputRef(const std::string & name)
Retrieves reference to specific input.
function
Input * getInputRef(const std::string & group, const std::string & name)
function
OutputMap * getOutputMapRef(const std::string & group)
Retrieves reference to specific output map.
function
InputMap * getInputMapRef(const std::string & group)
Retrieves reference to specific input map.
function
bool isSourceNode()
function
~Node()
function
const AssetManager & getAssetManager()
Get node AssetManager as a const reference.
function
AssetManager & getAssetManager()
Get node AssetManager as a reference.
function
std::vector< uint8_t > loadResource(const std::filesystem::path & uri)
Loads resource specified by URI and returns its data.
function
std::vector< uint8_t > moveResource(const std::filesystem::path & uri)
Moves the resource out.
inline function
std::shared_ptr< N > create()
Create and place Node to this Node.
function
void add(const std::shared_ptr< Node > & node)
Add existing node to nodeMap.
function
std::vector< std::shared_ptr< Node > > getAllNodes()
function
std::shared_ptr< const Node > getNode(Node::Id id)
function
std::shared_ptr< Node > getNode(Node::Id id)
function
void remove(const std::shared_ptr< Node > & node)
function
ConnectionMap getConnectionMap()
function
void link(const Node::Output & out, const Node::Input & in)
function
void unlink(const Node::Output & out, const Node::Input & in)
function
void link(std::shared_ptr< Node > in)
Get a reference to internal node map.
function
Node::Output * requestOutput(const Capability & capability, bool onHost)
function
std::vector< std::pair< Input &, std::shared_ptr< Capability > > > getRequiredInputs()
function
bool runOnHost()
Returns true or false whether the node should be run on host or not.
inline function
bool isBuiltInNode()
Returns whether this node is provided by depthai-core.
inline function
const NodeMap & getNodeMap()
inline function
void buildInternal()
Function called from within the create function to build the node. This function is useful for initialization, setting up inputs and outputs = stuff that cannot be perform in the constuctor.
struct

dai::Node::Connection

#include Node.hpp
variable
Id outputId
variable
std::string outputName
variable
std::string outputGroup
variable
Id inputId
variable
std::string inputName
variable
std::string inputGroup
function
Connection(Output out, Input in)
function
Connection(const ConnectionInternal & c)
function
bool operator==(const Connection & rhs)
struct

dai::Node::ConnectionInternal

#include Node.hpp
variable
std::weak_ptr< Node > outputNode
variable
std::string outputName
variable
std::string outputGroup
variable
std::weak_ptr< Node > inputNode
variable
std::string inputName
variable
std::string inputGroup
variable
Output * out
variable
Input * in
function
ConnectionInternal(Output & out, Input & in)
function
bool operator==(const ConnectionInternal & rhs)
struct

dai::Node::ConnectionInternal::Hash

function
size_t operator()(const dai::Node::ConnectionInternal & obj)
struct

dai::Node::DatatypeHierarchy

variable
DatatypeEnum datatype
variable
bool descendants
inline function
DatatypeHierarchy(DatatypeEnum d, bool c)
class

dai::Node::Input

variable
std::vector< DatatypeHierarchy > possibleDatatypes
function
~Input()
inline explicit function
Input(Node & par, InputDescription desc, bool ref)
inline function
const Node & getParent()
Get the parent node
inline function
Node & getParent()
Get the parent node
inline function
Type getType()
Get type
function
std::string toString()
Input to string representation
function
void setWaitForMessage(bool waitForMessage)
Overrides default wait for message behavior. Applicable for nodes with multiple inputs. Specifies behavior whether to wait for this input when a Node processes certain data or not.
Parameters
  • waitForMessage: Whether to wait for message to arrive to this input or not
function
bool getWaitForMessage()
Get behavior whether to wait for this input when a Node processes certain data or not
Returns
Whether to wait for message to arrive to this input or not
function
std::vector< DatatypeHierarchy > getPossibleDatatypes()
Get possible datatypes that can be received
function
void setPossibleDatatypes(std::vector< DatatypeHierarchy > types)
Set possible datatypes that can be received
function
void setReusePreviousMessage(bool reusePreviousMessage)
Equivalent to setWaitForMessage but with inverted logic.
function
bool getReusePreviousMessage()
Equivalent to getWaitForMessage but with inverted logic.
function
void setGroup(std::string group)
Set group name for this input
function
std::string getGroup()
Get group name for this input
function
bool isConnected()
Check if this input is connected
function
std::shared_ptr< InputQueue > createInputQueue(unsigned int maxSize, bool blocking)
Create an shared pointer to an input queue that can be used to send messages to this input from onhost.
Parameters
  • maxSize: Maximum size of the input queue
  • blocking: Whether the input queue should block when full
Returns
std::shared_ptr<InputQueue>: shared pointer to an input queue
function
std::shared_ptr< dai::node::internal::XLinkInBridge > getXLinkBridge()
Get XLink bridge associated with this input (only valid for device inputs after pipeline build)
Returns
std::shared_ptr<dai::node::internal::XLinkInBridge>: pointer to the XLink bridge or nullptr if not applicable
function
std::shared_ptr< Device > getSourceDevice()
Get the device that produces the data arriving at this input, resolved at pipeline build.
Returns
The source device, or nullptr when the upstream node runs on the host. Throws if this input is connected to sources on more than one device.
enum

Type

enumerator
SReceiver
enumerator
MReceiver
struct

dai::Node::InputDescription

variable
std::string name
variable
std::string group
variable
bool blocking
variable
int queueSize
variable
std::vector< DatatypeHierarchy > types DEFAULT_TYPES
variable
bool waitForMessage
class

dai::Node::InputMap

#include Node.hpp
variable
std::string name
function
InputMap(Node & parent, InputDescription defaultInput)
function
InputMap(Node & parent, std::string name, InputDescription defaultInput)
function
Input & operator[](const std::string & key)
Create or modify an input.
function
Input & operator[](std::pair< std::string, std::string > groupKey)
Create or modify an input with specified group.
function
bool has(const std::string & key)
function
std::map< std::string, std::shared_ptr< Device > > getSourceDevices()
Get the source device of every input in this map, resolved at pipeline build.
Returns
Map of input name to source device; nullptr when the source runs on the host. Inputs created with a group are keyed "<group>/<name>".
class

dai::Node::Output

function
~Output()
inline function
Output(Node & par, OutputDescription desc, bool ref)
inline function
Node & getParent()
inline function
const Node & getParent()
function
std::string toString()
Output to string representation.
inline function
std::string getName()
Get name of the output
inline function
std::string getGroup()
Get group of the output
inline function
void setGroup(std::string group)
Set group name for this output
inline function
void setName(std::string name)
Set name for this output
inline function
Type getType()
Get type of the output
function
std::vector< DatatypeHierarchy > getPossibleDatatypes()
Get possible datatypes that can be sent
function
void setPossibleDatatypes(std::vector< DatatypeHierarchy > types)
Set possible datatypes that can be sent
function
bool isSamePipeline(const Input & in)
Check if this output and given input are on the same pipeline.
See also
canConnect for checking if connection is possible
Returns
True if output and input are on the same pipeline
function
bool canConnect(const Input & in)
Check if connection is possible
Parameters
Returns
True if connection is possible, false otherwise
function
std::vector< ConnectionInternal > getConnections()
Retrieve all connections from this output
Returns
Vector of connections
inline function
std::vector< QueueConnection > getQueueConnections()
Retrieve all queue connections from this output
Returns
Vector of queue connections
function
std::shared_ptr< dai::MessageQueue > createOutputQueue(unsigned int maxSize, bool blocking)
Construct and return a shared pointer to an output message queue.
Parameters
  • maxSize: Maximum size of the output queue
  • blocking: Whether the output queue should block when full
Returns
std::shared_ptr<dai::MessageQueue>: shared pointer to an output queue
function
void link(Input & in)
Link current output to input.Throws an error if this output cannot be linked to given input, or if they are already linked
Parameters
function
void link(std::shared_ptr< Node > in)
function
void unlink(Input & in)
Unlink a previously linked connectionThrows an error if not linked.
Parameters
  • in: Input from which to unlink from
function
void send(const std::shared_ptr< ADatatype > & msg)
Sends a Message to all connected inputs
Parameters
  • msg: Message to send to all connected inputs
function
bool trySend(const std::shared_ptr< ADatatype > & msg)
Try sending a message to all connected inputs
Parameters
  • msg: Message to send to all connected inputs
Returns
True if ALL connected inputs got the message, false otherwise
function
std::shared_ptr< dai::node::internal::XLinkOutBridge > getXLinkBridge()
Get XLink bridge associated with this output (only valid for device outputs after pipeline build)
Returns
std::shared_ptr<dai::node::internal::XLinkOutBridge>: pointer to the XLink bridge or nullptr if not applicable
struct

dai::Node::Output::QueueConnection

variable
Output * output
variable
std::shared_ptr< MessageQueue > queue
inline function
bool operator==(const QueueConnection & rhs)
enum

Type

enumerator
MSender
enumerator
SSender
struct

dai::Node::OutputDescription

variable
std::string name
variable
std::string group
variable
std::vector< DatatypeHierarchy > types DEFAULT_TYPES
class

dai::Node::OutputMap

#include Node.hpp
variable
std::string name
function
OutputMap(Node & parent, std::string name, const OutputDescription & defaultOutput, bool ref)
function
OutputMap(Node & parent, OutputDescription defaultOutput, bool ref)
function
Output & operator[](const std::string & key)
Create or modify an output.
function
Output & operator[](std::pair< std::string, std::string > groupKey)
Create or modify an output with specified group.
struct

dai::Node::PairHash

inline function
std::size_t operator()(const std::pair< T1, T2 > & pair)