SpatialDetectionNetwork.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 SpatialDetectionNetwork::SpatialDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId)
15  : SpatialDetectionNetwork(par, nodeId, std::make_unique<Properties>()) {}
16 SpatialDetectionNetwork::SpatialDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props)
18  setInputRefs({&input, &inputDepth});
19  setOutputRefs({&out, &boundingBoxMapping, &passthrough, &passthroughDepth});
20 }
21 
23  properties.detectedBBScaleFactor = scaleFactor;
24 }
25 
26 void SpatialDetectionNetwork::setDepthLowerThreshold(uint32_t lowerThreshold) {
27  properties.depthThresholds.lowerThreshold = lowerThreshold;
28 }
29 
30 void SpatialDetectionNetwork::setDepthUpperThreshold(uint32_t upperThreshold) {
31  properties.depthThresholds.upperThreshold = upperThreshold;
32 }
33 
35  properties.calculationAlgorithm = calculationAlgorithm;
36 }
37 
40 }
41 
42 //--------------------------------------------------------------------
43 // MobileNet
44 //--------------------------------------------------------------------
45 MobileNetSpatialDetectionNetwork::MobileNetSpatialDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId)
48 }
49 
50 //--------------------------------------------------------------------
51 // YOLO
52 //--------------------------------------------------------------------
53 YoloSpatialDetectionNetwork::YoloSpatialDetectionNetwork(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId)
56 }
57 
58 void YoloSpatialDetectionNetwork::setNumClasses(const int numClasses) {
59  properties.parser.classes = numClasses;
60 }
61 
63  properties.parser.coordinates = coordinates;
64 }
65 
66 void YoloSpatialDetectionNetwork::setAnchors(std::vector<float> anchors) {
67  properties.parser.anchors = anchors;
68 }
69 
70 void YoloSpatialDetectionNetwork::setAnchorMasks(std::map<std::string, std::vector<int>> anchorMasks) {
71  properties.parser.anchorMasks = anchorMasks;
72 }
73 
76 }
77 
80  return properties.parser.classes;
81 }
82 
86 }
87 
89 std::vector<float> YoloSpatialDetectionNetwork::getAnchors() const {
90  return properties.parser.anchors;
91 }
92 
94 std::map<std::string, std::vector<int>> YoloSpatialDetectionNetwork::getAnchorMasks() const {
96 }
97 
101 }
102 
103 } // namespace node
104 } // namespace dai
dai::NodeCRTP< DetectionNetwork, SpatialDetectionNetwork, SpatialDetectionNetworkProperties >::properties
Properties & properties
Underlying properties.
Definition: Node.hpp:346
dai::DetectionParserOptions::coordinates
int coordinates
Definition: DetectionParserOptions.hpp:20
dai::SpatialDetectionNetworkProperties
Definition: SpatialDetectionNetworkProperties.hpp:19
dai::node::SpatialDetectionNetwork::inputDepth
Input inputDepth
Definition: SpatialDetectionNetwork.hpp:39
dai::node::SpatialDetectionNetwork::SpatialDetectionNetwork
SpatialDetectionNetwork(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: SpatialDetectionNetwork.cpp:14
dai::utility::map
static std::unordered_map< std::string, std::string > map
Definition: Environment.cpp:16
dai::node::MobileNetSpatialDetectionNetwork::MobileNetSpatialDetectionNetwork
MobileNetSpatialDetectionNetwork(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: SpatialDetectionNetwork.cpp:45
dai::node::YoloSpatialDetectionNetwork::getAnchorMasks
std::map< std::string, std::vector< int > > getAnchorMasks() const
Get anchor masks.
Definition: SpatialDetectionNetwork.cpp:94
dai::node::SpatialDetectionNetwork
SpatialDetectionNetwork node. Runs a neural inference on input image and calculates spatial location ...
Definition: SpatialDetectionNetwork.hpp:20
dai::SpatialDetectionNetworkProperties::depthThresholds
SpatialLocationCalculatorConfigThresholds depthThresholds
Definition: SpatialDetectionNetworkProperties.hpp:21
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::SpatialLocationCalculatorConfigThresholds::lowerThreshold
uint32_t lowerThreshold
Definition: RawSpatialLocationCalculatorConfig.hpp:23
dai::node::SpatialDetectionNetwork::setDepthUpperThreshold
void setDepthUpperThreshold(uint32_t upperThreshold)
Definition: SpatialDetectionNetwork.cpp:30
dai::node::YoloSpatialDetectionNetwork::setAnchorMasks
void setAnchorMasks(std::map< std::string, std::vector< int >> anchorMasks)
Set anchor masks.
Definition: SpatialDetectionNetwork.cpp:70
dai::SpatialDetectionNetworkProperties::detectedBBScaleFactor
float detectedBBScaleFactor
Definition: SpatialDetectionNetworkProperties.hpp:20
dai::NodeCRTP
Definition: Node.hpp:342
dai::node::SpatialDetectionNetwork::input
Input input
Definition: SpatialDetectionNetwork.hpp:33
dai::SpatialDetectionNetworkProperties::calculationAlgorithm
SpatialLocationCalculatorAlgorithm calculationAlgorithm
Definition: SpatialDetectionNetworkProperties.hpp:22
dai::node::SpatialDetectionNetwork::setDepthLowerThreshold
void setDepthLowerThreshold(uint32_t lowerThreshold)
Definition: SpatialDetectionNetwork.cpp:26
dai::DetectionParserOptions::classes
int classes
YOLO specific network properties.
Definition: DetectionParserOptions.hpp:19
dai::node::YoloSpatialDetectionNetwork
Definition: SpatialDetectionNetwork.hpp:117
dai::node::YoloSpatialDetectionNetwork::YoloSpatialDetectionNetwork
YoloSpatialDetectionNetwork(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: SpatialDetectionNetwork.cpp:53
dai::SpatialDetectionNetworkProperties::stepSize
std::int32_t stepSize
Definition: SpatialDetectionNetworkProperties.hpp:23
dai::node::SpatialDetectionNetwork::passthrough
Output passthrough
Definition: SpatialDetectionNetwork.hpp:58
dai::node::DetectionNetwork
DetectionNetwork, base for different network specializations.
Definition: DetectionNetwork.hpp:20
dai::node::YoloSpatialDetectionNetwork::setIouThreshold
void setIouThreshold(float thresh)
Set Iou threshold.
Definition: SpatialDetectionNetwork.cpp:74
BlobReader.hpp
dai::DetectionParserOptions::anchors
std::vector< float > anchors
Definition: DetectionParserOptions.hpp:21
dai::node::SpatialDetectionNetwork::setBoundingBoxScaleFactor
void setBoundingBoxScaleFactor(float scaleFactor)
Definition: SpatialDetectionNetwork.cpp:22
dai::Properties
Base Properties structure.
Definition: Properties.hpp:8
dai::node::SpatialDetectionNetwork::setSpatialCalculationAlgorithm
void setSpatialCalculationAlgorithm(dai::SpatialLocationCalculatorAlgorithm calculationAlgorithm)
Definition: SpatialDetectionNetwork.cpp:34
dai::node::YoloSpatialDetectionNetwork::getIouThreshold
float getIouThreshold() const
Get Iou threshold.
Definition: SpatialDetectionNetwork.cpp:99
dai::node::MobileNetSpatialDetectionNetwork
Definition: SpatialDetectionNetwork.hpp:109
dai::node::YoloSpatialDetectionNetwork::setAnchors
void setAnchors(std::vector< float > anchors)
Set anchors.
Definition: SpatialDetectionNetwork.cpp:66
dai::DetectionNetworkProperties::parser
DetectionParserOptions parser
Definition: DetectionNetworkProperties.hpp:17
SpatialDetectionNetwork.hpp
DetectionNetworkType::YOLO
@ YOLO
DetectionNetworkType.hpp
stepSize
static constexpr float stepSize
Definition: mono_camera_control.cpp:16
dai::node::SpatialDetectionNetwork::setSpatialCalculationStepSize
void setSpatialCalculationStepSize(int stepSize)
Definition: SpatialDetectionNetwork.cpp:38
std
Definition: Node.hpp:366
dai::node::YoloSpatialDetectionNetwork::getCoordinateSize
int getCoordinateSize() const
Get coordianate size.
Definition: SpatialDetectionNetwork.cpp:84
dai::node::SpatialDetectionNetwork::out
Output out
Definition: SpatialDetectionNetwork.hpp:44
dai::node::YoloSpatialDetectionNetwork::setCoordinateSize
void setCoordinateSize(const int coordinates)
Set coordianate size.
Definition: SpatialDetectionNetwork.cpp:62
dai::node::SpatialDetectionNetwork::passthroughDepth
Output passthroughDepth
Definition: SpatialDetectionNetwork.hpp:65
dai::node::YoloSpatialDetectionNetwork::getNumClasses
int getNumClasses() const
Get num classes.
Definition: SpatialDetectionNetwork.cpp:79
dai::SpatialLocationCalculatorAlgorithm
SpatialLocationCalculatorAlgorithm
Definition: RawSpatialLocationCalculatorConfig.hpp:36
dai::SpatialLocationCalculatorConfigThresholds::upperThreshold
uint32_t upperThreshold
Definition: RawSpatialLocationCalculatorConfig.hpp:27
dai::DetectionParserOptions::iouThreshold
float iouThreshold
Definition: DetectionParserOptions.hpp:23
dai::node::SpatialDetectionNetwork::boundingBoxMapping
Output boundingBoxMapping
Definition: SpatialDetectionNetwork.hpp:51
dai
Definition: CameraExposureOffset.hpp:6
DetectionNetworkType::MOBILENET
@ MOBILENET
dai::node::YoloSpatialDetectionNetwork::getAnchors
std::vector< float > getAnchors() const
Get anchors.
Definition: SpatialDetectionNetwork.cpp:89
dai::node::YoloSpatialDetectionNetwork::setNumClasses
void setNumClasses(const int numClasses)
Set num classes.
Definition: SpatialDetectionNetwork.cpp:58


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