Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
115c3d1
Move example
aljazkonec1 Nov 4, 2025
bb3204e
Add host parsing option
aljazkonec1 Nov 4, 2025
1392154
Merge remote-tracking branch 'origin/develop' into dev/update_rvc2_de…
aljazkonec1 Nov 4, 2025
96a92f5
Add host side implementation
aljazkonec1 Nov 5, 2025
a0dd29a
bump device
aljazkonec1 Nov 5, 2025
d0d07bf
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 5, 2025
33752f1
bump rvc4
aljazkonec1 Nov 5, 2025
7a25242
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 10, 2025
3f53b11
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 10, 2025
d50cb15
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 11, 2025
16a147e
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 11, 2025
8cd5d7b
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 11, 2025
bf0307c
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 11, 2025
1bfe31a
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 11, 2025
255a882
update parser
aljazkonec1 Nov 11, 2025
831232c
update example
aljazkonec1 Nov 11, 2025
ad653f5
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 11, 2025
39fcbd0
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 12, 2025
3f4d628
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 12, 2025
cc2f5a6
Merge branch 'dev_update_detection_parser' into dev/update_rvc2_detec…
aljazkonec1 Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ set(TARGET_CORE_SOURCES
src/pipeline/node/ImageAlign.cpp
src/pipeline/node/ToF.cpp
src/pipeline/node/DetectionParser.cpp
src/pipeline/utilities/DetectionParser/DetectionParserUtils.cpp
src/pipeline/node/test/MyProducer.cpp
src/pipeline/node/test/MyConsumer.cpp
src/pipeline/node/UVC.cpp
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/src/pipeline/node/DetectionParserBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack) {
DOC(dai, node, DetectionParser, setAnchors, 2))
.def("setAnchorMasks", &DetectionParser::setAnchorMasks, py::arg("anchorMasks"), DOC(dai, node, DetectionParser, setAnchorMasks))
.def("setIouThreshold", &DetectionParser::setIouThreshold, py::arg("thresh"), DOC(dai, node, DetectionParser, setIouThreshold))
.def("setRunOnHost", &DetectionParser::setRunOnHost, py::arg("runOnHost"), DOC(dai, node, DetectionParser, setRunOnHost))
.def("setSubtype", &DetectionParser::setSubtype, py::arg("subtype"), DOC(dai, node, DetectionParser, setSubtype))
.def("setDecodeKeypoints", &DetectionParser::setDecodeKeypoints, py::arg("decode"), DOC(dai, node, DetectionParser, setDecodeKeypoints))
.def("setDecodeSegmentation", &DetectionParser::setDecodeSegmentation, py::arg("decode"), DOC(dai, node, DetectionParser, setDecodeSegmentation))
Expand All @@ -78,6 +79,7 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack) {
.def("getAnchors", &DetectionParser::getAnchors, DOC(dai, node, DetectionParser, getAnchors))
.def("getAnchorMasks", &DetectionParser::getAnchorMasks, DOC(dai, node, DetectionParser, getAnchorMasks))
.def("getIouThreshold", &DetectionParser::getIouThreshold, DOC(dai, node, DetectionParser, getIouThreshold))
.def("runOnHost", &DetectionParser::runOnHost, DOC(dai, node, DetectionParser, runOnHost))
.def("getSubtype", &DetectionParser::getSubtype, DOC(dai, node, DetectionParser, getSubtype))
.def("getNkeypoints", &DetectionParser::getNKeypoints, DOC(dai, node, DetectionParser, getNKeypoints))
.def("getDecodeKeypoints", &DetectionParser::getDecodeKeypoints, DOC(dai, node, DetectionParser, getDecodeKeypoints))
Expand Down
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceRVC4Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot")

# "version if applicable"
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+777a261c32c4daf6a0b31093701d6f930f6b8caf")
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+62ce59c3c4a4a53a9b0773fe83dabbecdc4553e9")
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "b18d476e0adba7541664251cce8c1ba71db16daa")
set(DEPTHAI_DEVICE_SIDE_COMMIT "8741ce89206d2a5299acc3382c7496e1ee205fcb")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
4 changes: 2 additions & 2 deletions examples/cpp/DetectionNetwork/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ dai_set_example_test_labels(detection_network ondevice rvc2_all rvc4 rvc4rgb ci)
dai_add_example(detection_network_remap detection_network_remap.cpp ON OFF)
dai_set_example_test_labels(detection_network_remap ondevice rvc2_all rvc4 ci)

dai_add_example(detection_and_segmentation RVC4/detection_and_segmentation.cpp ON OFF)
dai_add_example(detection_and_segmentation detection_and_segmentation.cpp ON OFF)
dai_set_example_test_labels(detection_and_segmentation rvc4)

dai_add_example(detection_and_keypoints RVC4/detection_and_keypoints.cpp ON OFF)
dai_add_example(detection_and_keypoints detection_and_keypoints.cpp ON OFF)
dai_set_example_test_labels(detection_and_keypoints rvc4)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main() {
auto detectionNetwork = pipeline.create<dai::node::DetectionNetwork>();

dai::NNModelDescription modelDescription;
modelDescription.model = "luxonis/yolov8-large-pose-estimation:coco-640x352:1868e39";
modelDescription.model = "luxonis/yolov8-nano-pose-estimation:coco-512x288";
detectionNetwork->build(cameraNode, modelDescription);
auto labelMap = detectionNetwork->getClasses();

Expand Down Expand Up @@ -94,7 +94,6 @@ int main() {

auto currentTime = std::chrono::steady_clock::now();
float fps = counter / std::chrono::duration<float>(currentTime - startTime).count();
std::cout << "FPS: " << fps << std::endl;
}

if(cv::waitKey(1) == 'q') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstddef>
#include <cstdio>
#include <iostream>
#include <memory>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>

Expand All @@ -16,8 +17,16 @@ cv::Rect frameNorm(const cv::Mat& frame, const dai::Point2f& topLeft, const dai:
}

int main() {
std::string modelName = "luxonis/yolov8-instance-segmentation-large:coco-640x352";
bool setRunOnHost = false;
auto device = std::make_shared<dai::Device>();

if(device->getPlatformAsString() == "RVC2") {
modelName = "luxonis/yolov8-instance-segmentation-nano:coco-512x288";
setRunOnHost = true;
}
// Create pipeline
dai::Pipeline pipeline;
dai::Pipeline pipeline{device};

// Create and configure camera node
auto cameraNode = pipeline.create<dai::node::Camera>();
Expand All @@ -27,8 +36,10 @@ int main() {
auto detectionNetwork = pipeline.create<dai::node::DetectionNetwork>();

dai::NNModelDescription modelDescription;
modelDescription.model = "luxonis/yolov8-instance-segmentation-large:coco-640x480";

modelDescription.model = modelName;
detectionNetwork->build(cameraNode, modelDescription);
detectionNetwork->detectionParser->setRunOnHost(setRunOnHost);
auto labelMap = detectionNetwork->getClasses();

// Create output queues
Expand Down Expand Up @@ -120,10 +131,10 @@ int main() {
detections.begin(), detections.end(), [filteredLabel](const dai::ImgDetection& det) { return det.label != filteredLabel; }),
detections.end());
}

if(segmentationMask) {
cv::Mat lut(1, 256, CV_8U);
for(int i = 0; i < 256; ++i) lut.at<uchar>(i) = (i == 255) ? 255 : cv::saturate_cast<uchar>(i * 25);
for(int i = 0; i < 256; ++i) lut.at<uchar>(i) = (i >= 255) ? 255 : cv::saturate_cast<uchar>(i * 25);

cv::Mat scaledMask;
cv::LUT(*segmentationMask, lut, scaledMask);

Expand Down Expand Up @@ -158,8 +169,6 @@ int main() {
cv::imshow("rgb", frame);

auto currentTime = std::chrono::steady_clock::now();
float fps = counter / std::chrono::duration<float>(currentTime - startTime).count();
std::cout << "FPS: " << fps << std::endl;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

# Create pipeline
with dai.Pipeline() as pipeline:
cameraNode = pipeline.create(dai.node.Camera).build()
detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(cameraNode, dai.NNModelDescription("luxonis/yolov8-large-pose-estimation:coco-640x352:1868e39"))
cameraNode = pipeline.create(dai.node.Camera).build(sensorFps=12)
detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(cameraNode, dai.NNModelDescription("luxonis/yolov8-nano-pose-estimation:coco-512x288"))
labelMap = detectionNetwork.getClasses()

qRgb = detectionNetwork.passthrough.createOutputQueue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
import numpy as np
import time

model_name = "luxonis/yolov8-instance-segmentation-large:coco-640x480"
setRunOnHost = False
device = dai.Device()
if device.getPlatformAsString() == "RVC2":
model_name = "luxonis/yolov8-instance-segmentation-nano:coco-512x288"
setRunOnHost = True

# Create pipeline
with dai.Pipeline() as pipeline:
with dai.Pipeline(device) as pipeline:
cameraNode = pipeline.create(dai.node.Camera).build()
detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(cameraNode, dai.NNModelDescription("luxonis/yolov8-instance-segmentation-large:coco-640x480"))

detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(cameraNode, dai.NNModelDescription(model_name))
detectionNetwork.detectionParser.setRunOnHost(setRunOnHost)
labelMap = detectionNetwork.getClasses()

qRgb = detectionNetwork.passthrough.createOutputQueue()
Expand Down
29 changes: 28 additions & 1 deletion include/depthai/pipeline/node/DetectionParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <string>

#include "depthai/common/YoloDecodingFamily.hpp"
#include "depthai/pipeline/datatype/ImgDetections.hpp"
#include "depthai/pipeline/datatype/NNData.hpp"

namespace dai {
namespace node {
Expand All @@ -20,7 +22,7 @@ namespace node {
* @brief DetectionParser node. Parses detection results from different neural networks and is being used internally by MobileNetDetectionNetwork and
* YoloDetectionNetwork.
*/
class DetectionParser : public DeviceNodeCRTP<DeviceNode, DetectionParser, DetectionParserProperties> {
class DetectionParser : public DeviceNodeCRTP<DeviceNode, DetectionParser, DetectionParserProperties>, public HostRunnable {
public:
constexpr static const char* NAME = "DetectionParser";
using DeviceNodeCRTP::DeviceNodeCRTP;
Expand Down Expand Up @@ -268,14 +270,39 @@ class DetectionParser : public DeviceNodeCRTP<DeviceNode, DetectionParser, Detec
*/
const NNArchiveVersionedConfig& getNNArchiveVersionedConfig() const;

/**
* Specify whether to run on host or device
* By default, the node will run on device.
*/
void setRunOnHost(bool runOnHost);

/**
* Check if the node is set to run on host
*/
bool runOnHost() const override;

void run() override;

std::vector<dai::ImgDetection> decodeMobilenet(std::shared_ptr<dai::NNData> nnData, float confidenceThr);

private:
bool runOnHostVar = false;
void setNNArchiveBlob(const NNArchive& nnArchive);
void setNNArchiveSuperblob(const NNArchive& nnArchive, int numShaves);
void setNNArchiveOther(const NNArchive& nnArchive);
void setConfig(const dai::NNArchiveVersionedConfig& config);
YoloDecodingFamily yoloDecodingFamilyResolver(const std::string& subtype);
bool decodeSegmentationResolver(const std::vector<std::string>& outputs);

// host runnable requirements
void buildStage1() override;
void decodeYolo(std::shared_ptr<dai::NNData> nnData, std::shared_ptr<dai::ImgDetections> outDetections);
std::vector<dai::TensorInfo> inTensorInfo;
uint32_t imgWidth;
uint32_t imgHeight;
uint32_t imgSizesSet = false;
//

std::optional<NNArchive> mArchive;

std::optional<NNArchiveVersionedConfig> archiveConfig;
Expand Down
Loading