YoloSpatialDetectionNetwork¶
Spatial detection for the Yolo NN. It is similar to a combination of the YoloDetectionNetwork and SpatialLocationCalculator.
How to place it¶
pipeline = dai.Pipeline()
yoloSpatial = pipeline.create(dai.node.YoloSpatialDetectionNetwork)
dai::Pipeline pipeline;
auto yoloSpatial = pipeline.create<dai::node::YoloSpatialDetectionNetwork>();
Inputs and Outputs¶
┌───────────────────┐
input │ │ passthrough
──────────────►│-------------------├─────────────────►
│ Yolo │ out
│ Spatial ├─────────────────►
│ Detection │boundingBoxMapping
│ Network ├─────────────────►
inputDepth │ │ passthroughDepth
──────────────►│-------------------├─────────────────►
└───────────────────┘
Message types
input
- ImgFrameinputDepth
- ImgFramepassthrough
- ImgFrameout
- SpatialImgDetectionsboundingBoxMapping
- SpatialLocationCalculatorConfigpassthroughDepth
- ImgFrame
Usage¶
pipeline = dai.Pipeline()
yoloSpatial = pipeline.create(dai.node.YoloSpatialDetectionNetwork)
yoloSpatial.setBlobPath(nnBlobPath)
# Spatial detection specific parameters
yoloSpatial.setConfidenceThreshold(0.5)
yoloSpatial.input.setBlocking(False)
yoloSpatial.setBoundingBoxScaleFactor(0.5)
yoloSpatial.setDepthLowerThreshold(100) # Min 10 centimeters
yoloSpatial.setDepthUpperThreshold(5000) # Max 5 meters
# Yolo specific parameters
yoloSpatial.setNumClasses(80)
yoloSpatial.setCoordinateSize(4)
yoloSpatial.setAnchors([10,14, 23,27, 37,58, 81,82, 135,169, 344,319])
yoloSpatial.setAnchorMasks({ "side26": [1,2,3], "side13": [3,4,5] })
yoloSpatial.setIouThreshold(0.5)
dai::Pipeline pipeline;
auto yoloSpatial = pipeline.create<dai::node::YoloSpatialDetectionNetwork>();
yoloSpatial->setBlobPath(nnBlobPath);
// Spatial detection specific parameters
yoloSpatial->setConfidenceThreshold(0.5f);
yoloSpatial->input.setBlocking(false);
yoloSpatial->setBoundingBoxScaleFactor(0.5);
yoloSpatial->setDepthLowerThreshold(100); // Min 10 centimeters
yoloSpatial->setDepthUpperThreshold(5000); // Max 5 meters
// yolo specific parameters
yoloSpatial->setNumClasses(80);
yoloSpatial->setCoordinateSize(4);
yoloSpatial->setAnchors({10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319});
yoloSpatial->setAnchorMasks({{"side13", {3, 4, 5}}, {"side26", {1, 2, 3}}});
yoloSpatial->setIouThreshold(0.5f);
Examples of functionality¶
Spatial coordinate system¶
OAK camera uses left-handed (Cartesian) coordinate system for all spatial coordiantes.
Middle of the frame is 0,0 in terms of X,Y coordinates. If you go up, Y will increase, and if you go right, X will increase.
Reference¶
-
class
depthai.node.
YoloSpatialDetectionNetwork
-
class
Id
Node identificator. Unique for every node on a single Pipeline
-
getAnchorMasks
(self: depthai.node.YoloSpatialDetectionNetwork) → dict[str, list[int]]
-
getAnchors
(self: depthai.node.YoloSpatialDetectionNetwork) → list[float]
-
getAssetManager
(*args, **kwargs) Overloaded function.
getAssetManager(self: depthai.Node) -> depthai.AssetManager
getAssetManager(self: depthai.Node) -> depthai.AssetManager
-
getConfidenceThreshold
(self: depthai.node.DetectionNetwork) → float
-
getCoordinateSize
(self: depthai.node.YoloSpatialDetectionNetwork) → int
-
getInputRefs
(*args, **kwargs) Overloaded function.
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
-
getInputs
(self: depthai.Node) → list[depthai.Node.Input]
-
getIouThreshold
(self: depthai.node.YoloSpatialDetectionNetwork) → float
-
getName
(self: depthai.Node) → str
-
getNumClasses
(self: depthai.node.YoloSpatialDetectionNetwork) → int
-
getNumInferenceThreads
(self: depthai.node.NeuralNetwork) → int
-
getOutputRefs
(*args, **kwargs) Overloaded function.
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
-
getOutputs
(self: depthai.Node) → list[depthai.Node.Output]
-
getParentPipeline
(*args, **kwargs) Overloaded function.
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
-
setAnchorMasks
(self: depthai.node.YoloSpatialDetectionNetwork, anchorMasks: dict[str, list[int]]) → None
-
setAnchors
(self: depthai.node.YoloSpatialDetectionNetwork, anchors: list[float]) → None
-
setBlob
(*args, **kwargs) Overloaded function.
setBlob(self: depthai.node.NeuralNetwork, blob: depthai.OpenVINO.Blob) -> None
setBlob(self: depthai.node.NeuralNetwork, path: Path) -> None
-
setBlobPath
(self: depthai.node.NeuralNetwork, path: Path) → None
-
setBoundingBoxScaleFactor
(self: depthai.node.SpatialDetectionNetwork, scaleFactor: float) → None
-
setConfidenceThreshold
(self: depthai.node.DetectionNetwork, thresh: float) → None
-
setCoordinateSize
(self: depthai.node.YoloSpatialDetectionNetwork, coordinates: int) → None
-
setDepthLowerThreshold
(self: depthai.node.SpatialDetectionNetwork, lowerThreshold: int) → None
-
setDepthUpperThreshold
(self: depthai.node.SpatialDetectionNetwork, upperThreshold: int) → None
-
setIouThreshold
(self: depthai.node.YoloSpatialDetectionNetwork, thresh: float) → None
-
setNumClasses
(self: depthai.node.YoloSpatialDetectionNetwork, numClasses: int) → None
-
setNumInferenceThreads
(self: depthai.node.NeuralNetwork, numThreads: int) → None
-
setNumNCEPerInferenceThread
(self: depthai.node.NeuralNetwork, numNCEPerThread: int) → None
-
setNumPoolFrames
(self: depthai.node.NeuralNetwork, numFrames: int) → None
-
setSpatialCalculationAlgorithm
(self: depthai.node.SpatialDetectionNetwork, calculationAlgorithm: depthai.SpatialLocationCalculatorAlgorithm) → None
-
setSpatialCalculationStepSize
(self: depthai.node.SpatialDetectionNetwork, stepSize: int) → None
-
class
-
class
dai::node
::
YoloSpatialDetectionNetwork
: public dai::NodeCRTP<SpatialDetectionNetwork, YoloSpatialDetectionNetwork, SpatialDetectionNetworkProperties>¶ YoloSpatialDetectionNetwork node. Yolo-based network with spatial location data.
Public Functions
-
void
setNumClasses
(const int numClasses)¶ Set num classes.
-
void
setCoordinateSize
(const int coordinates)¶ Set coordianate size.
-
void
setAnchors
(std::vector<float> anchors)¶ Set anchors.
-
void
setAnchorMasks
(std::map<std::string, std::vector<int>> anchorMasks)¶ Set anchor masks.
-
void
setIouThreshold
(float thresh)¶ Set Iou threshold.
-
int
getNumClasses
() const¶ Get num classes.
-
int
getCoordinateSize
() const¶ Get coordianate size.
-
std::vector<float>
getAnchors
() const¶ Get anchors.
-
std::map<std::string, std::vector<int>>
getAnchorMasks
() const¶ Get anchor masks.
-
float
getIouThreshold
() const¶ Get Iou threshold.
-
void