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

本页目录

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

DetectionNetwork

最后更新
Supported on:RVC2RVC4
DetectionNetwork 节点通过执行相机端解析(解码)步骤来扩展 NeuralNetwork,该步骤将 NN 输出(字节数组)解析为边界框、标签和置信度值,并将其格式化为 ImgDetections 消息。检测网络目前支持 YOLO 和 SSD NN 输出格式,并取代了 DepthAI API v2 中的 YoloDetectionNetwork 和 MobileNetDetectionNetwork。

如何放置

Python

Python
1pipeline = dai.Pipeline()
2detection = pipeline.create(dai.node.DetectionNetwork)

C++

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

输入和输出

outNetwork 输出来自 NN 的原始/未解析的 NN 输出(字节数组),可用于主机上的自定义解析。

用法

Python

Python
1pipeline = dai.Pipeline()
2camera = pipeline.create(dai.node.Camera).build()
3detection = pipeline.create(dai.node.DetectionNetwork).build(camera, dai.NNModelDescription("yolov6-nano"))
4detection.setConfidenceThreshold(0.5)
5detection.input.setBlocking(False)

C++

C++
1dai::Pipeline pipeline;
2auto camera = pipeline.create<dai::node.Camera>()->build();
3auto detection = pipeline.create<dai::node.DetectionNetwork>()->build(camera, dai::NNModelDescription("yolov6-nano"));
4detection->setConfidenceThreshold(0.5f);
5detection->input.setBlocking(false);

功能示例

  • 检测网络 - 运行 YOLOv6n 对象检测模型并在视频流上显示结果(边界框)。
  • 检测网络重映射 - 运行 YOLOv6 对象检测模型并将边界框映射到深度帧上。
  • 检测网络回放 - 在回放的视频流上运行 YOLOv6 对象检测模型,并在我们自定义的可视化工具中显示检测结果。

参考

class

dai::node::DetectionNetwork

#include DetectionNetwork.hpp
using
Model = NeuralNetwork::Model
variable
Subnode< NeuralNetwork > neuralNetwork
variable
Subnode< DetectionParser > detectionParser
variable
Output & out
Outputs ImgDetections message that carries parsed detection results. Overrides NeuralNetwork 'out' with ImgDetections output message type.
variable
Output & outNetwork
Outputs unparsed inference results.
variable
Input & input
Input message with data to be inferred upon Default queue is blocking with size 5
variable
Output & passthrough
Passthrough message on which the inference was performed.Suitable for when input queue is set to non-blocking behavior.
function
DetectionNetwork(const std::shared_ptr< Device > & device)
function
std::shared_ptr< DetectionNetwork > build(Node::Output & input, const NNArchive & nnArchive)
Build DetectionNetwork node. Connect output to this node's input. Also call setNNArchive() with provided NNArchive.
Parameters
  • output: Output to link
  • nnArchive: Neural network archive
Returns
Shared pointer to DetectionNetwork node
function
std::shared_ptr< DetectionNetwork > build(const std::shared_ptr< Camera > & input, const Model & model, std::optional< float > fps, std::optional< dai::ImgResizeMode > resizeMode)
Build DetectionNetwork node. Connect Camera output to this node's input and configure the inference model.
Parameters
  • input: Camera node
  • model: Neural network model description, NNArchive or HubAI model id string
  • fps: Desired frames per second
  • resizeMode: Resize mode for input frames
Returns
Shared pointer to DetectionNetwork node
function
std::shared_ptr< DetectionNetwork > build(const std::shared_ptr< Camera > & input, const Model & model, const ImgFrameCapability & capability)
Build DetectionNetwork node. Connect Camera output to this node's input and configure the inference model.
Parameters
  • input: Camera node
  • model: Neural network model description, NNArchive or HubAI model id string
  • capability: Camera capabilities
Returns
Shared pointer to DetectionNetwork node
function
std::shared_ptr< DetectionNetwork > build(const std::shared_ptr< ReplayVideo > & input, const Model & model, std::optional< float > fps)
function
void setNNArchive(const NNArchive & nnArchive)
Set NNArchive for this Node. If the archive's type is SUPERBLOB, use default number of shaves.
Parameters
function
void setNNArchive(const NNArchive & nnArchive, int numShaves)
Set NNArchive for this Node, throws if the archive's type is not SUPERBLOB.
Parameters
  • nnArchive: NNArchive to set
  • numShaves: Number of shaves to use
function
void setFromModelZoo(NNModelDescription description, bool useCached)
Download model from zoo and set it for this Node.
Parameters
  • description: Model description to download
  • useCached: Use cached model if available
function
void setFromModelZoo(NNModelDescription description, int numShaves, bool useCached)
Download model from zoo and set it for this node.
Parameters
  • description: Model description to download
  • numShaves: Number of shaves to use
  • useCached: Use cached model if available
function
void setBlobPath(const std::filesystem::path & path)
Load network blob into assets and use once pipeline is started.
Parameters
  • Error: if file doesn't exist or isn't a valid network blob.
Parameters
  • path: Path to network blob
function
void setBlob(const OpenVINO::Blob & blob)
Load network blob into assets and use once pipeline is started.
Parameters
  • blob: Network blob
function
void setBlob(const std::filesystem::path & path)
Same functionality as the setBlobPath(). Load network blob into assets and use once pipeline is started.
Parameters
  • Error: if file doesn't exist or isn't a valid network blob.
Parameters
  • path: Path to network blob
function
void setModelPath(const std::filesystem::path & modelPath)
Load a network model into assets. DLC and other custom model files are loaded lazily and must remain available and unchanged until the pipeline has been built.
Parameters
  • modelPath: Path to the model file.
function
void setNumPoolFrames(int numFrames)
Specifies how many frames will be available in the pool
Parameters
  • numFrames: How many frames will pool have
function
void setNumInferenceThreads(int numThreads)
How many threads should the node use to run the network.
Parameters
  • numThreads: Number of threads to dedicate to this node
function
void setNumNCEPerInferenceThread(int numNCEPerThread)
How many Neural Compute Engines should a single thread use for inference
Parameters
  • numNCEPerThread: Number of NCE per thread
function
void setNumShavesPerInferenceThread(int numShavesPerThread)
How many Shaves should a single thread use for inference
Parameters
  • numShavesPerThread: Number of shaves per thread
function
void setBackend(const std::string & backend)
Specifies backend to use
Parameters
  • backend: String specifying backend to use
function
void setBackendProperties(const std::map< std::string, std::string > & properties)
Set backend properties
Parameters
  • backendProperties: backend properties map
function
int getNumInferenceThreads()
How many inference threads will be used to run the network
Returns
Number of threads, 0, 1 or 2. Zero means AUTO
function
void setConfidenceThreshold(float thresh)
Specifies confidence threshold at which to filter the rest of the detections.
Parameters
  • thresh: Detection confidence must be greater than specified threshold to be added to the list
function
float getConfidenceThreshold()
Retrieves threshold at which to filter the rest of the detections.
Returns
Detection confidence
function
std::vector< std::pair< Input &, std::shared_ptr< Capability > > > getRequiredInputs()
function
std::optional< std::vector< std::string > > getClasses()
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.

需要帮助?

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