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

本页目录

  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 参考

DetectionNetwork

Supported on:RVC2RVC4
DetectionNetwork 节点通过执行板载解析(解码)步骤,扩展了 NeuralNetwork 功能。该步骤将 NN 输出(字节数组)解析为边界框、标签和置信度值,并将其格式化为 ImgDetections 消息。Detection Network 目前支持 YOLO 和 SSD NN 输出格式,并取代了 DepthAI API v2 中的 YoloDetectionNetworkMobileNetDetectionNetwork

如何放置

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);

功能示例

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

参考

class

dai::node::DetectionNetwork

#include DetectionNetwork.hpp
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)
function
std::shared_ptr< DetectionNetwork > build(const std::shared_ptr< Camera > & input, const Model & model, std::optional< float > fps, std::optional< dai::ImgResizeMode > resizeMode)
function
std::shared_ptr< DetectionNetwork > build(const std::shared_ptr< Camera > & input, const Model & model, const ImgFrameCapability & capability)
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)
function
void setNNArchive(const NNArchive & nnArchive, int numShaves)
function
void setFromModelZoo(NNModelDescription description, bool useCached)
function
void setFromModelZoo(NNModelDescription description, int numShaves, bool useCached)
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(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 network model into assets.
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(std::string backend)
Specifies backend to use
Parameters
  • backend: String specifying backend to use
function
void setBackendProperties(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()
enum

NeuralNetwork::Model Model

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。