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

本页目录

  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

SegmentationParser

最后更新
Supported on:RVC4
SegmentationParser 节点接收分割 NN 的原始输出,并应用逐像素 argmax 将原始输出张量转换为单通道分割掩码,然后将其作为 SegmentationMask 消息输出。 某些分割 NN 直接将分割掩码作为单通道输出,在这种情况下,SegmentationParser 节点可用于简单地将原始输出张量转换为 SegmentationMask 消息,而无需应用 argmax。

如何放置

Python

Python
1pipeline = dai.Pipeline()
2segmentation = pipeline.create(dai.node.SegmentationParser)

C++

C++
1dai::Pipeline pipeline;
2auto segmentation = pipeline.create<dai::node::SegmentationParser>();

输入和输出

用法

Python

Python
1model = dai.NNModelDescription("luxonis/deeplab-v3-plus:512x512")
2pipeline = dai.Pipeline()
3camera = pipeline.create(dai.node.Camera).build()
4nn = pipeline.create(dai.node.NeuralNetwork).build(camera, model)
5parser = pipeline.create(dai.node.SegmentationParser).build(nn.out, model )

C++

C++
1dai::NNModelDescription model("luxonis/deeplab-v3-plus:512x512");
2dai::Pipeline pipeline;
3auto camera = pipeline.create<dai::node::Camera>()->build();
4auto nn = pipeline.create<dai::node::NeuralNetwork>()->build(camera, model);
5auto parser = pipeline.create<dai::node::SegmentationParser>()->build(nn->out, model);

功能示例

参考

class

dai::node::SegmentationParser

#include SegmentationParser.hpp
using
Model = std::variant< NNModelDescription, NNArchive, std::string >
variable
std::shared_ptr< SegmentationParserConfig > initialConfig
Initial config to use when parsing segmentation masks.
variable
Input input
Input NN results with segmentation data to parser
variable
Input inputConfig
Input SegmentationParserConfig message with ability to modify parameters in runtime.
variable
Output out
Outputs segmentation mask
function
~SegmentationParser()
function
SegmentationParser()
inline function
SegmentationParser(std::unique_ptr< Properties > props)
function
std::shared_ptr< SegmentationParser > build(Node::Output & nnInput, const Model & model)
Build SegmentationParser node.
Parameters
  • nnInput: Output to link
  • model: Neural network model
function
std::shared_ptr< SegmentationParser > build(Node::Output & nnInput, const dai::nn_archive::v1::Head & head)
Build SegmentationParser node with the specific head from NNArchive. Useful when model outputs multiple segmentation heads.
Parameters
  • nnInput: Output to link
  • head: Specific head from NNArchive to use for this parser
function
void setNNArchive(const NNArchive & nnArchive)
Set NNArchive for this Node.
Parameters
function
void setNNArchiveHead(const dai::nn_archive::v1::Head & head)
Set NNArchive head for this Node.
Parameters
function
void setLabels(const std::vector< std::string > & labels)
Sets the class labels associated with the segmentation mask. The label at index $i$ in the labels vector corresponds to the value $i$ in the segmentation mask data array.
Parameters
  • labels: Vector of class labels
function
std::vector< std::string > getLabels()
Returns the class labels associated with the segmentation mask.
function
void setBackgroundClass(bool backgroundClass)
Sets whether the first class (index 0) is considered the background class. If true, the pixels classified as index 0 will be treated as background.
Parameters
  • backgroundClass: Boolean indicating if the first class is the background class
Note
Only applicable if the number of classes is greater than 1 and the output classes are not in a single layer (eg. classesInOneLayer = false).
function
bool getBackgroundClass()
Gets whether the first class (index 0) is considered the background class.
function
void setRunOnHost(bool runOnHost)
Specify whether to run on host or device By default, the node will run on device.
function
bool runOnHost()
Check if the node is set to run on host
function
void run()
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.
inline function
DeviceNodeCRTP()
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

需要帮助?

请访问讨论论坛以获取技术支持或您可能有的任何其他问题。