Yolo detection network node is very similar to NeuralNetwork (in fact it extends it). The only difference is that this node is specifically for the (tiny) Yolo V3/V4 NN and it decodes the result of the NN on device. This means that Out of this node is not a NNData (a byte array) but a ImgDetections that can easily be used in your code.

How to place it

pipeline = dai.Pipeline()
yoloDet = pipeline.create(dai.node.YoloDetectionNetwork)
dai::Pipeline pipeline;
auto yoloDet = pipeline.create<dai::node::YoloDetectionNetwork>();

Inputs and Outputs

            │                   │       out
            │                   ├───────────►
            │     Yolo          │
            │     Detection     │
input       │     Network       │ passthrough
            │                   │

Message types


pipeline = dai.Pipeline()
yoloDet = pipeline.create(dai.node.YoloDetectionNetwork)

# Yolo specific parameters
yoloDet.setAnchors([10,14, 23,27, 37,58, 81,82, 135,169, 344,319])
yoloDet.setAnchorMasks({"side26": [1, 2, 3], "side13": [3, 4, 5]})
dai::Pipeline pipeline;
auto yoloDet = pipeline.create<dai::node::YoloDetectionNetwork>();

// yolo specific parameters
yoloDet->setAnchors({10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319});
yoloDet->setAnchorMasks({{"side13", {3, 4, 5}}, {"side26", {1, 2, 3}}});

Examples of functionality


class depthai.node.YoloDetectionNetwork

YoloDetectionNetwork node. Parses Yolo results

class Connection

Connection between an Input and Output

class Id

Node identificator. Unique for every node on a single Pipeline


alias of depthai.DetectionNetworkProperties

getAnchorMasks(self: depthai.node.YoloDetectionNetwork) → Dict[str, List[int]]

Get anchor masks

getAnchors(self: depthai.node.YoloDetectionNetwork) → List[float]

Get anchors

getAssetManager(*args, **kwargs)

Overloaded function.

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

getConfidenceThreshold(self: depthai.node.DetectionNetwork)float

Retrieves threshold at which to filter the rest of the detections.


Detection confidence

getCoordinateSize(self: depthai.node.YoloDetectionNetwork)int

Get coordianate size

getInputRefs(*args, **kwargs)

Overloaded function.

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

getInputs(self: depthai.Node) → List[depthai.Node.Input]

Retrieves all nodes inputs

getIouThreshold(self: depthai.node.YoloDetectionNetwork)float

Get Iou threshold

getName(self: depthai.Node)str

Retrieves nodes name

getNumClasses(self: depthai.node.YoloDetectionNetwork)int

Get num classes

getNumInferenceThreads(self: depthai.node.NeuralNetwork)int

How many inference threads will be used to run the network


Number of threads, 0, 1 or 2. Zero means AUTO

getOutputRefs(*args, **kwargs)

Overloaded function.

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

getOutputs(self: depthai.Node) → List[depthai.Node.Output]

Retrieves all nodes outputs

getParentPipeline(*args, **kwargs)

Overloaded function.

  1. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

  2. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

property id

Id of node

property input

Input message with data to be inferred upon Default queue is blocking with size 5

property inputs

Inputs mapped to network inputs. Useful for inferring from separate data sources Default input is non-blocking with queue size 1 and waits for messages

property out

Outputs ImgDetections message that carries parsed detection results. Overrides NeuralNetwork ‘out’ with ImgDetections output message type.

property passthrough

Passthrough message on which the inference was performed.

Suitable for when input queue is set to non-blocking behavior.

property passthroughs

Passthroughs which correspond to specified input

setAnchorMasks(self: depthai.node.YoloDetectionNetwork, anchorMasks: Dict[str, List[int]])None

Set anchor masks

setAnchors(self: depthai.node.YoloDetectionNetwork, anchors: List[float])None

Set anchors

setBlobPath(self: depthai.node.NeuralNetwork, path: object)None

Load network blob into assets and use once pipeline is started.


Error if file doesn’t exist or isn’t a valid network blob.

Parameter path:

Path to network blob

setConfidenceThreshold(self: depthai.node.DetectionNetwork, thresh: float)None

Specifies confidence threshold at which to filter the rest of the detections.

Parameter thresh:

Detection confidence must be greater than specified threshold to be added to the list

setCoordinateSize(self: depthai.node.YoloDetectionNetwork, coordinates: int)None

Set coordianate size

setIouThreshold(self: depthai.node.YoloDetectionNetwork, thresh: float)None

Set Iou threshold

setNumClasses(self: depthai.node.YoloDetectionNetwork, numClasses: int)None

Set num classes

setNumInferenceThreads(self: depthai.node.NeuralNetwork, numThreads: int)None

How many threads should the node use to run the network.

Parameter numThreads:

Number of threads to dedicate to this node

setNumNCEPerInferenceThread(self: depthai.node.NeuralNetwork, numNCEPerThread: int)None

How many Neural Compute Engines should a single thread use for inference

Parameter numNCEPerThread:

Number of NCE per thread

setNumPoolFrames(self: depthai.node.NeuralNetwork, numFrames: int)None

Specifies how many frames will be available in the pool

Parameter numFrames:

How many frames will pool have

class dai::node::YoloDetectionNetwork : public dai::NodeCRTP<DetectionNetwork, YoloDetectionNetwork, DetectionNetworkProperties>

YoloDetectionNetwork node. Parses Yolo results.

Public Functions

YoloDetectionNetwork(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId)
YoloDetectionNetwork(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId, std::unique_ptr<Properties> props)
void setNumClasses(int numClasses)

Set num classes.

void setCoordinateSize(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.

Got questions?

We’re always happy to help with code or other questions you might have.