# 设备节点

节点是填充[管道](https://docs.luxonis.com/software-v3/depthai/depthai-components/pipeline.md)时的构建块。每个节点在DepthAI上提供特定功能，一组可配置的属性和输入/输出。在管道上创建节点后，您可以按需配置它并将其链接到其他节点。

设备节点是一种特殊类型的节点，它在设备SoC（RVC）上运行，利用设备资源。设备节点用于将主机上的处理任务卸载到设备本身。或者，[主机节点](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes.md)可用于在主机（PC）上执行计算。

在目录（页面左侧）中，所有节点都列在Node条目下。您可以点击它们以了解更多信息。

## 输入和输出

每个节点可以有零个、一个或多个输入和输出。例如，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的preview连接到多个输入，则行为类似，消息会依次推送到每个输入。

如果禁用阻塞，新消息将推出旧消息。这消除了管道冻结的风险，但可能导致消息丢失（例如ImgFrame）。

### 节点输出

节点输出消息。一些节点有可配置的输出消息池。输出消息池是一个预留的内存区域（以减少内存碎片），用于保存输出消息。节点创建输出消息（例如ImgFrame）后，它将根据链接节点输入/输出时的指定，将消息发送到其他节点。
目前，一些节点（VideoEncoder、NeuralNetwork、ImageManip、XLinkIn）可以配置池的大小。 池的大小指定了在其他消息已经在管道中的情况下，可以创建和发送多少消息。

> **管道冻结**
> 当池中的所有消息都已发送且尚未返回时，节点将阻塞（冻结）并等待，直到某个消息被释放（不被管道中任何节点使用）。

### dai::Node

Kind: class

Abstract Node .

#### dai::Node::Connection

Kind: struct

Connection between an Input and Output .

##### Id outputId

Kind: variable

##### std::string outputName

Kind: variable

##### std::string outputGroup

Kind: variable

##### Id inputId

Kind: variable

##### std::string inputName

Kind: variable

##### std::string inputGroup

Kind: variable

##### Connection(Output out, Input in)

Kind: function

##### Connection(const ConnectionInternal & c)

Kind: function

##### bool operator==(const Connection & rhs)

Kind: function

#### dai::Node::ConnectionInternal

Kind: struct

Connection between an Input and Output internal.

##### dai::Node::ConnectionInternal::Hash

Kind: struct

###### size_t operator()(const dai::Node::ConnectionInternal & obj)

Kind: function

##### std::weak_ptr< Node > outputNode

Kind: variable

##### std::string outputName

Kind: variable

##### std::string outputGroup

Kind: variable

##### std::weak_ptr< Node > inputNode

Kind: variable

##### std::string inputName

Kind: variable

##### std::string inputGroup

Kind: variable

##### Output * out

Kind: variable

##### Input * in

Kind: variable

##### ConnectionInternal(Output & out, Input & in)

Kind: function

##### bool operator==(const ConnectionInternal & rhs)

Kind: function

#### dai::Node::DatatypeHierarchy

Kind: struct

##### DatatypeEnum datatype

Kind: variable

##### bool descendants

Kind: variable

##### DatatypeHierarchy(DatatypeEnum d, bool c)

Kind: function

#### dai::Node::Input

Kind: class

##### Type

Kind: enum

###### SReceiver

Kind: enum_value

###### MReceiver

Kind: enum_value

##### std::vector< DatatypeHierarchy > possibleDatatypes

Kind: variable

##### ~Input()

Kind: function

##### Input(Node & par, InputDescription desc, bool ref)

Kind: function

##### const Node & getParent()

Kind: function

Get the parent node

##### Node & getParent()

Kind: function

Get the parent node

##### Type getType()

Kind: function

Get type

##### std::string toString()

Kind: function

Input to string representation

##### void setWaitForMessage(bool waitForMessage)

Kind: function

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

##### bool getWaitForMessage()

Kind: function

Get behavior whether to wait for this input when a Node processes certain data or not return: Whether to wait for message to
arrive to this input or not

##### std::vector< DatatypeHierarchy > getPossibleDatatypes()

Kind: function

Get possible datatypes that can be received

##### void setPossibleDatatypes(std::vector< DatatypeHierarchy > types)

Kind: function

Set possible datatypes that can be received

##### void setReusePreviousMessage(bool reusePreviousMessage)

Kind: function

Equivalent to setWaitForMessage but with inverted logic.

##### bool getReusePreviousMessage()

Kind: function

Equivalent to getWaitForMessage but with inverted logic.

##### void setGroup(std::string group)

Kind: function

Set group name for this input

##### std::string getGroup()

Kind: function

Get group name for this input

##### bool isConnected()

Kind: function

Check if this input is connected

##### std::shared_ptr< InputQueue > createInputQueue(unsigned int maxSize, bool blocking)

Kind: function

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 return:
std::shared_ptr<InputQueue>: shared pointer to an input queue

##### std::shared_ptr< dai::node::internal::XLinkInBridge > getXLinkBridge()

Kind: function

Get XLink bridge associated with this input (only valid for device inputs after pipeline build)

return: std::shared_ptr<dai::node::internal::XLinkInBridge>: pointer to the XLink bridge or nullptr if not applicable

#### dai::Node::InputDescription

Kind: struct

##### std::string name

Kind: variable

##### std::string group

Kind: variable

##### bool blocking

Kind: variable

##### int queueSize

Kind: variable

##### std::vector< DatatypeHierarchy > types DEFAULT_TYPES

Kind: variable

##### bool waitForMessage

Kind: variable

#### dai::Node::InputMap

Kind: class

Input map which keeps track of inputs assigned to a node Extends std::unordered_map<std::string, dai::Node::Input>

##### std::string name

Kind: variable

##### InputMap(Node & parent, InputDescription defaultInput)

Kind: function

##### InputMap(Node & parent, std::string name, InputDescription defaultInput)

Kind: function

##### Input & operator[](const std::string & key)

Kind: function

Create or modify an input.

##### Input & operator[](std::pair< std::string, std::string > groupKey)

Kind: function

Create or modify an input with specified group.

##### bool has(const std::string & key)

Kind: function

#### dai::Node::Output

Kind: class

##### dai::Node::Output::QueueConnection

Kind: struct

###### Output * output

Kind: variable

###### std::shared_ptr< MessageQueue > queue

Kind: variable

###### bool operator==(const QueueConnection & rhs)

Kind: function

##### Type

Kind: enum

###### MSender

Kind: enum_value

###### SSender

Kind: enum_value

##### ~Output()

Kind: function

##### Output(Node & par, OutputDescription desc, bool ref)

Kind: function

##### Node & getParent()

Kind: function

##### const Node & getParent()

Kind: function

##### std::string toString()

Kind: function

Output to string representation.

##### std::string getName()

Kind: function

Get name of the output

##### std::string getGroup()

Kind: function

Get group of the output

##### void setGroup(std::string group)

Kind: function

Set group name for this output

##### void setName(std::string name)

Kind: function

Set name for this output

##### Type getType()

Kind: function

Get type of the output

##### std::vector< DatatypeHierarchy > getPossibleDatatypes()

Kind: function

Get possible datatypes that can be sent

##### void setPossibleDatatypes(std::vector< DatatypeHierarchy > types)

Kind: function

Set possible datatypes that can be sent

##### bool isSamePipeline(const Input & in)

Kind: function

Check if this output and given input are on the same pipeline. see: canConnect for checking if connection is possible return: True
if output and input are on the same pipeline

##### bool canConnect(const Input & in)

Kind: function

Check if connection is possible parameters: in: Input to connect to return: True if connection is possible, false otherwise

##### std::vector< ConnectionInternal > getConnections()

Kind: function

Retrieve all connections from this output return: Vector of connections

##### std::vector< QueueConnection > getQueueConnections()

Kind: function

Retrieve all queue connections from this output return: Vector of queue connections

##### std::shared_ptr< dai::MessageQueue > createOutputQueue(unsigned int maxSize, bool blocking)

Kind: function

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 return:
std::shared_ptr<dai::MessageQueue>: shared pointer to an output queue

##### void link(Input & in)

Kind: function

Link current output to input. Throws an error if this output cannot be linked to given input, or if they are already linked
parameters: in: Input to link to

##### void link(std::shared_ptr< Node > in)

Kind: function

##### void unlink(Input & in)

Kind: function

Unlink a previously linked connection Throws an error if not linked. parameters: in: Input from which to unlink from

##### void send(const std::shared_ptr< ADatatype > & msg)

Kind: function

Sends a Message to all connected inputs parameters: msg: Message to send to all connected inputs

##### bool trySend(const std::shared_ptr< ADatatype > & msg)

Kind: function

Try sending a message to all connected inputs parameters: msg: Message to send to all connected inputs return: True if ALL
connected inputs got the message, false otherwise

##### std::shared_ptr< dai::node::internal::XLinkOutBridge > getXLinkBridge()

Kind: function

Get XLink bridge associated with this output (only valid for device outputs after pipeline build)

return: std::shared_ptr<dai::node::internal::XLinkOutBridge>: pointer to the XLink bridge or nullptr if not applicable

#### dai::Node::OutputDescription

Kind: struct

##### std::string name

Kind: variable

##### std::string group

Kind: variable

##### std::vector< DatatypeHierarchy > types DEFAULT_TYPES

Kind: variable

#### dai::Node::OutputMap

Kind: class

Output map which keeps track of extra outputs assigned to a node Extends std::unordered_map<std::string, dai::Node::Output>

##### std::string name

Kind: variable

##### OutputMap(Node & parent, std::string name, const OutputDescription & defaultOutput, bool ref)

Kind: function

##### OutputMap(Node & parent, OutputDescription defaultOutput, bool ref)

Kind: function

##### Output & operator[](const std::string & key)

Kind: function

Create or modify an output.

##### Output & operator[](std::pair< std::string, std::string > groupKey)

Kind: function

Create or modify an output with specified group.

#### dai::Node::PairHash

Kind: struct

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

Kind: function

#### std::int64_t Id

Kind: enum

Node identificator. Unique for every node on a single Pipeline .

#### Id id

Kind: variable

Id of node. Assigned after being placed on the pipeline.

#### Id inputId

Kind: variable

#### Id outputId

Kind: variable

#### std::string alias

Kind: variable

alias or name

#### Node(const Node &)

Kind: function

#### Node & operator=(const Node &)

Kind: function

#### Node(Node &&)

Kind: function

#### Node & operator=(Node &&)

Kind: function

#### std::string createUniqueInputName()

Kind: function

#### std::string createUniqueOutputName()

Kind: function

#### Pipeline getParentPipeline()

Kind: function

#### const Pipeline getParentPipeline()

Kind: function

#### std::string getAlias()

Kind: function

Get alias.

#### void setAlias(std::string alias)

Kind: function

Set alias.

#### const char * getName()

Kind: function

Retrieves nodes name.

#### void start()

Kind: function

Start node execution.

#### void wait()

Kind: function

Wait for node to finish execution.

#### void stop()

Kind: function

Stop node execution.

#### void stopPipeline()

Kind: function

#### void buildStage1()

Kind: function

Build stages;.

#### void buildStage2()

Kind: function

#### void buildStage3()

Kind: function

#### void postBuildStage()

Kind: function

#### std::vector< Output > getOutputs()

Kind: function

Retrieves all nodes outputs.

#### std::vector< Input > getInputs()

Kind: function

Retrieves all nodes inputs.

#### std::vector< Output * > getOutputRefs()

Kind: function

Retrieves reference to node outputs.

#### std::vector< const Output * > getOutputRefs()

Kind: function

Retrieves reference to node outputs.

#### std::vector< Input * > getInputRefs()

Kind: function

Retrieves reference to node inputs.

#### std::vector< const Input * > getInputRefs()

Kind: function

Retrieves reference to node inputs.

#### std::vector< OutputMap * > getOutputMapRefs()

Kind: function

Retrieves reference to node outputs.

#### std::vector< InputMap * > getInputMapRefs()

Kind: function

Retrieves reference to node inputs.

#### Output * getOutputRef(const std::string & name)

Kind: function

Retrieves reference to specific output.

#### Output * getOutputRef(const std::string & group, const std::string & name)

Kind: function

#### Input * getInputRef(const std::string & name)

Kind: function

Retrieves reference to specific input.

#### Input * getInputRef(const std::string & group, const std::string & name)

Kind: function

#### OutputMap * getOutputMapRef(const std::string & group)

Kind: function

Retrieves reference to specific output map.

#### InputMap * getInputMapRef(const std::string & group)

Kind: function

Retrieves reference to specific input map.

#### bool isSourceNode()

Kind: function

#### ~Node()

Kind: function

#### const AssetManager & getAssetManager()

Kind: function

Get node AssetManager as a const reference.

#### AssetManager & getAssetManager()

Kind: function

Get node AssetManager as a reference.

#### std::vector< uint8_t > loadResource(const std::filesystem::path & uri)

Kind: function

Loads resource specified by URI and returns its data.

#### std::vector< uint8_t > moveResource(const std::filesystem::path & uri)

Kind: function

Moves the resource out.

#### std::shared_ptr< N > create()

Kind: function

Create and place Node to this Node .

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

Kind: function

Add existing node to nodeMap.

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

Kind: function

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

Kind: function

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

Kind: function

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

Kind: function

#### ConnectionMap getConnectionMap()

Kind: function

#### void link(const Node::Output & out, const Node::Input & in)

Kind: function

#### void unlink(const Node::Output & out, const Node::Input & in)

Kind: function

#### void link(std::shared_ptr< Node > in)

Kind: function

Get a reference to internal node map.

#### Node::Output * requestOutput(const Capability & capability, bool onHost)

Kind: function

#### std::vector< std::pair< Input &, std::shared_ptr< Capability > > > getRequiredInputs()

Kind: function

#### bool runOnHost()

Kind: function

Returns true or false whether the node should be run on host or not.

#### bool isBuiltInNode()

Kind: function

Returns whether this node is provided by depthai-core.

#### const NodeMap & getNodeMap()

Kind: function

#### void buildInternal()

Kind: function

Function called from within the
