DetectionNetwork.cpp
Go to the documentation of this file.
2 
3 #include <sstream>
4 
7 
8 namespace dai {
9 namespace node {
10 
11 //--------------------------------------------------------------------
12 // Base Detection Network Class
13 //--------------------------------------------------------------------
14 DetectionNetwork::DetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId) : DetectionNetwork(par, nodeId, std::make_unique<Properties>()) {}
15 DetectionNetwork::DetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props)
16  : NodeCRTP<NeuralNetwork, DetectionNetwork, DetectionNetworkProperties>(par, nodeId, std::move(props)) {
17  setInputRefs({&input});
18  setOutputRefs({&out, &passthrough});
19 
20  // Default confidence threshold
22 }
23 
26 }
27 
30 }
31 
32 //--------------------------------------------------------------------
33 // MobileNet
34 //--------------------------------------------------------------------
35 MobileNetDetectionNetwork::MobileNetDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId)
36  : MobileNetDetectionNetwork(par, nodeId, std::make_unique<Properties>()) {}
37 MobileNetDetectionNetwork::MobileNetDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props)
40 }
41 
42 //--------------------------------------------------------------------
43 // YOLO
44 //--------------------------------------------------------------------
45 YoloDetectionNetwork::YoloDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId)
46  : YoloDetectionNetwork(par, nodeId, std::make_unique<Properties>()) {}
47 YoloDetectionNetwork::YoloDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props)
51 }
52 
53 void YoloDetectionNetwork::setNumClasses(const int numClasses) {
54  properties.parser.classes = numClasses;
55 }
56 
57 void YoloDetectionNetwork::setCoordinateSize(const int coordinates) {
58  properties.parser.coordinates = coordinates;
59 }
60 
61 void YoloDetectionNetwork::setAnchors(std::vector<float> anchors) {
62  properties.parser.anchors = anchors;
63 }
64 
65 void YoloDetectionNetwork::setAnchorMasks(std::map<std::string, std::vector<int>> anchorMasks) {
66  properties.parser.anchorMasks = anchorMasks;
67 }
68 
71 }
72 
75  return properties.parser.classes;
76 }
77 
81 }
82 
84 std::vector<float> YoloDetectionNetwork::getAnchors() const {
85  return properties.parser.anchors;
86 }
87 
89 std::map<std::string, std::vector<int>> YoloDetectionNetwork::getAnchorMasks() const {
91 }
92 
96 }
97 
98 } // namespace node
99 } // namespace dai
dai::NodeCRTP< NeuralNetwork, DetectionNetwork, DetectionNetworkProperties >::properties
Properties & properties
Underlying properties.
Definition: Node.hpp:346
dai::DetectionParserOptions::coordinates
int coordinates
Definition: DetectionParserOptions.hpp:20
dai::node::DetectionNetwork::out
Output out
Definition: DetectionNetwork.hpp:33
dai::DetectionParserOptions::confidenceThreshold
float confidenceThreshold
Definition: DetectionParserOptions.hpp:16
dai::utility::map
static std::unordered_map< std::string, std::string > map
Definition: Environment.cpp:16
dai::DetectionParserOptions::anchorMasks
std::map< std::string, std::vector< int > > anchorMasks
Definition: DetectionParserOptions.hpp:22
dai::DetectionParserOptions::nnFamily
DetectionNetworkType nnFamily
Generic Neural Network properties.
Definition: DetectionParserOptions.hpp:15
dai::node::NeuralNetwork
NeuralNetwork node. Runs a neural inference on input data.
Definition: NeuralNetwork.hpp:18
dai::NodeCRTP
Definition: Node.hpp:342
dai::node::YoloDetectionNetwork::setAnchors
void setAnchors(std::vector< float > anchors)
Set anchors.
Definition: DetectionNetwork.cpp:61
dai::node::YoloDetectionNetwork::setNumClasses
void setNumClasses(int numClasses)
Set num classes.
Definition: DetectionNetwork.cpp:53
dai::DetectionParserOptions::classes
int classes
YOLO specific network properties.
Definition: DetectionParserOptions.hpp:19
dai::node::YoloDetectionNetwork
YoloDetectionNetwork node. Parses Yolo results.
Definition: DetectionNetwork.hpp:65
dai::node::YoloDetectionNetwork::getAnchors
std::vector< float > getAnchors() const
Get anchors.
Definition: DetectionNetwork.cpp:84
dai::node::YoloDetectionNetwork::setIouThreshold
void setIouThreshold(float thresh)
Set Iou threshold.
Definition: DetectionNetwork.cpp:69
dai::node::YoloDetectionNetwork::YoloDetectionNetwork
YoloDetectionNetwork(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: DetectionNetwork.cpp:45
dai::node::YoloDetectionNetwork::setCoordinateSize
void setCoordinateSize(int coordinates)
Set coordianate size.
Definition: DetectionNetwork.cpp:57
dai::node::DetectionNetwork::setConfidenceThreshold
void setConfidenceThreshold(float thresh)
Definition: DetectionNetwork.cpp:24
dai::node::DetectionNetwork::DetectionNetwork
DetectionNetwork(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: DetectionNetwork.cpp:14
dai::node::YoloDetectionNetwork::getNumClasses
int getNumClasses() const
Get num classes.
Definition: DetectionNetwork.cpp:74
dai::node::DetectionNetwork
DetectionNetwork, base for different network specializations.
Definition: DetectionNetwork.hpp:20
BlobReader.hpp
dai::node::YoloDetectionNetwork::getIouThreshold
float getIouThreshold() const
Get Iou threshold.
Definition: DetectionNetwork.cpp:94
dai::DetectionParserOptions::anchors
std::vector< float > anchors
Definition: DetectionParserOptions.hpp:21
DetectionNetwork.hpp
dai::Properties
Base Properties structure.
Definition: Properties.hpp:8
dai::node::MobileNetDetectionNetwork::MobileNetDetectionNetwork
MobileNetDetectionNetwork(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: DetectionNetwork.cpp:35
dai::DetectionNetworkProperties::parser
DetectionParserOptions parser
Definition: DetectionNetworkProperties.hpp:17
dai::DetectionNetworkProperties
Definition: DetectionNetworkProperties.hpp:16
dai::node::DetectionNetwork::getConfidenceThreshold
float getConfidenceThreshold() const
Definition: DetectionNetwork.cpp:28
dai::node::YoloDetectionNetwork::getCoordinateSize
int getCoordinateSize() const
Get coordianate size.
Definition: DetectionNetwork.cpp:79
dai::node::YoloDetectionNetwork::setAnchorMasks
void setAnchorMasks(std::map< std::string, std::vector< int >> anchorMasks)
Set anchor masks.
Definition: DetectionNetwork.cpp:65
DetectionNetworkType::YOLO
@ YOLO
DetectionNetworkType.hpp
std
Definition: Node.hpp:366
dai::node::YoloDetectionNetwork::getAnchorMasks
std::map< std::string, std::vector< int > > getAnchorMasks() const
Get anchor masks.
Definition: DetectionNetwork.cpp:89
dai::node::MobileNetDetectionNetwork
MobileNetDetectionNetwork node. Parses MobileNet results.
Definition: DetectionNetwork.hpp:56
dai::DetectionParserOptions::iouThreshold
float iouThreshold
Definition: DetectionParserOptions.hpp:23
dai
Definition: CameraExposureOffset.hpp:6
DetectionNetworkType::MOBILENET
@ MOBILENET


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19