Skip to content

Commit a05a2a6

Browse files
authored
Merge pull request #1513 from luxonis/dev/update_rvc2_detection_parser
Add host implementation of Detection parser
2 parents e55a31c + f5a149f commit a05a2a6

File tree

17 files changed

+1430
-15
lines changed

17 files changed

+1430
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ set(TARGET_CORE_SOURCES
311311
src/pipeline/node/ImageAlign.cpp
312312
src/pipeline/node/ToF.cpp
313313
src/pipeline/node/DetectionParser.cpp
314+
src/pipeline/utilities/DetectionParser/DetectionParserUtils.cpp
314315
src/pipeline/node/test/MyProducer.cpp
315316
src/pipeline/node/test/MyConsumer.cpp
316317
src/pipeline/node/UVC.cpp

bindings/python/src/pipeline/node/DetectionParserBindings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack) {
6565
DOC(dai, node, DetectionParser, setAnchors, 2))
6666
.def("setAnchorMasks", &DetectionParser::setAnchorMasks, py::arg("anchorMasks"), DOC(dai, node, DetectionParser, setAnchorMasks))
6767
.def("setIouThreshold", &DetectionParser::setIouThreshold, py::arg("thresh"), DOC(dai, node, DetectionParser, setIouThreshold))
68+
.def("setRunOnHost", &DetectionParser::setRunOnHost, py::arg("runOnHost"), DOC(dai, node, DetectionParser, setRunOnHost))
6869
.def("setSubtype", &DetectionParser::setSubtype, py::arg("subtype"), DOC(dai, node, DetectionParser, setSubtype))
6970
.def("setDecodeKeypoints", &DetectionParser::setDecodeKeypoints, py::arg("decode"), DOC(dai, node, DetectionParser, setDecodeKeypoints))
7071
.def("setDecodeSegmentation", &DetectionParser::setDecodeSegmentation, py::arg("decode"), DOC(dai, node, DetectionParser, setDecodeSegmentation))
@@ -78,6 +79,7 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack) {
7879
.def("getAnchors", &DetectionParser::getAnchors, DOC(dai, node, DetectionParser, getAnchors))
7980
.def("getAnchorMasks", &DetectionParser::getAnchorMasks, DOC(dai, node, DetectionParser, getAnchorMasks))
8081
.def("getIouThreshold", &DetectionParser::getIouThreshold, DOC(dai, node, DetectionParser, getIouThreshold))
82+
.def("runOnHost", &DetectionParser::runOnHost, DOC(dai, node, DetectionParser, runOnHost))
8183
.def("getSubtype", &DetectionParser::getSubtype, DOC(dai, node, DetectionParser, getSubtype))
8284
.def("getNkeypoints", &DetectionParser::getNKeypoints, DOC(dai, node, DetectionParser, getNKeypoints))
8385
.def("getDecodeKeypoints", &DetectionParser::getDecodeKeypoints, DOC(dai, node, DetectionParser, getDecodeKeypoints))

cmake/Depthai/DepthaiDeviceRVC4Config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot")
44

55
# "version if applicable"
6-
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+ccb59dd506392110b0c85abee0d82e28c7d91f9e")
6+
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+098f664d24dc72bce0589a9f81f18ceb285b0f8f")

cmake/Depthai/DepthaiDeviceSideConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")
33

44
# "full commit hash of device side binary"
5-
set(DEPTHAI_DEVICE_SIDE_COMMIT "0f9a7793654b8f2fbed64759c162425eab2c8541")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "621e48a2a0375f4594f7f8875661c50d3d5950c9")
66

77
# "version if applicable"
88
set(DEPTHAI_DEVICE_SIDE_VERSION "")

examples/cpp/DetectionNetwork/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ dai_set_example_test_labels(detection_network ondevice rvc2_all rvc4 rvc4rgb ci)
2323
dai_add_example(detection_network_remap detection_network_remap.cpp ON OFF)
2424
dai_set_example_test_labels(detection_network_remap ondevice rvc2_all rvc4 ci)
2525

26-
dai_add_example(detection_and_segmentation RVC4/detection_and_segmentation.cpp ON OFF)
27-
dai_set_example_test_labels(detection_and_segmentation rvc4)
26+
dai_add_example(detection_and_segmentation detection_and_segmentation.cpp ON OFF)
27+
dai_set_example_test_labels(detection_and_segmentation rvc2_all rvc4 ci)
2828

29-
dai_add_example(detection_and_keypoints RVC4/detection_and_keypoints.cpp ON OFF)
30-
dai_set_example_test_labels(detection_and_keypoints rvc4)
29+
dai_add_example(detection_and_keypoints detection_and_keypoints.cpp ON OFF)
30+
dai_set_example_test_labels(detection_and_keypoints rvc2_all rvc4 ci)

examples/cpp/DetectionNetwork/RVC4/detection_and_keypoints.cpp renamed to examples/cpp/DetectionNetwork/detection_and_keypoints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int main() {
2222
auto detectionNetwork = pipeline.create<dai::node::DetectionNetwork>();
2323

2424
dai::NNModelDescription modelDescription;
25-
modelDescription.model = "luxonis/yolov8-large-pose-estimation:coco-640x352:1868e39";
25+
modelDescription.model = "luxonis/yolov8-nano-pose-estimation:coco-512x288";
2626
detectionNetwork->build(cameraNode, modelDescription);
2727

2828
// Create output queues

examples/cpp/DetectionNetwork/RVC4/detection_and_segmentation.cpp renamed to examples/cpp/DetectionNetwork/detection_and_segmentation.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <cstdio>
66
#include <iostream>
77
#include <map>
8+
#include <memory>
89
#include <opencv2/core.hpp>
910
#include <opencv2/opencv.hpp>
1011

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

1920
int main() {
21+
std::string modelName = "luxonis/yolov8-instance-segmentation-large:coco-640x352";
22+
bool setRunOnHost = false;
23+
auto device = std::make_shared<dai::Device>();
24+
25+
if(device->getPlatform() == dai::Platform::RVC2) {
26+
modelName = "luxonis/yolov8-instance-segmentation-nano:coco-512x288";
27+
setRunOnHost = true;
28+
}
2029
// Create pipeline
21-
dai::Pipeline pipeline;
30+
dai::Pipeline pipeline{device};
2231

2332
// Create and configure camera node
2433
auto cameraNode = pipeline.create<dai::node::Camera>();
@@ -28,8 +37,10 @@ int main() {
2837
auto detectionNetwork = pipeline.create<dai::node::DetectionNetwork>();
2938

3039
dai::NNModelDescription modelDescription;
31-
modelDescription.model = "luxonis/yolov8-instance-segmentation-large:coco-640x480";
40+
41+
modelDescription.model = modelName;
3242
detectionNetwork->build(cameraNode, modelDescription);
43+
detectionNetwork->detectionParser->setRunOnHost(setRunOnHost);
3344

3445
// Create output queues
3546
auto qRgb = detectionNetwork->passthrough.createOutputQueue();

examples/python/DetectionNetwork/RVC4/detection_and_keypoints.py renamed to examples/python/DetectionNetwork/detection_and_keypoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

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

1414
qRgb = detectionNetwork.passthrough.createOutputQueue()

examples/python/DetectionNetwork/RVC4/detection_and_segmentation.py renamed to examples/python/DetectionNetwork/detection_and_segmentation.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@
55
import numpy as np
66
import time
77

8+
model_name = "luxonis/yolov8-instance-segmentation-large:coco-640x480"
9+
setRunOnHost = False
10+
device = dai.Device()
11+
if device.getPlatform() == dai.Platform.RVC2:
12+
model_name = "luxonis/yolov8-instance-segmentation-nano:coco-512x288"
13+
setRunOnHost = True
14+
815
# Create pipeline
9-
with dai.Pipeline() as pipeline:
16+
with dai.Pipeline(device) as pipeline:
1017
cameraNode = pipeline.create(dai.node.Camera).build()
11-
detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(cameraNode, dai.NNModelDescription("luxonis/yolov8-instance-segmentation-large:coco-640x480"))
18+
19+
detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(cameraNode, dai.NNModelDescription(model_name))
20+
detectionNetwork.detectionParser.setRunOnHost(setRunOnHost)
1221
labelMap = detectionNetwork.getClasses()
1322
assert labelMap is not None
1423
qRgb = detectionNetwork.passthrough.createOutputQueue()

0 commit comments

Comments
 (0)