From 2c9f2094f238abe3fa216acd92772df49e2ac996 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Thu, 26 Sep 2024 11:20:37 +0000 Subject: [PATCH 01/10] 2.10.2 --- depthai-ros/CHANGELOG.rst | 4 ++++ depthai-ros/CMakeLists.txt | 2 +- depthai-ros/package.xml | 2 +- depthai_bridge/CMakeLists.txt | 2 +- depthai_bridge/package.xml | 2 +- depthai_descriptions/CMakeLists.txt | 2 +- depthai_descriptions/package.xml | 2 +- depthai_examples/CMakeLists.txt | 2 +- depthai_examples/package.xml | 2 +- depthai_filters/CMakeLists.txt | 2 +- depthai_filters/package.xml | 2 +- depthai_ros_driver/CMakeLists.txt | 2 +- depthai_ros_driver/package.xml | 2 +- depthai_ros_driver/src/dai_nodes/sensors/sensor_wrapper.cpp | 2 +- .../src/param_handlers/sensor_param_handler.cpp | 2 +- depthai_ros_msgs/CMakeLists.txt | 2 +- depthai_ros_msgs/package.xml | 2 +- 17 files changed, 20 insertions(+), 16 deletions(-) diff --git a/depthai-ros/CHANGELOG.rst b/depthai-ros/CHANGELOG.rst index 053db04b..9ea65db0 100644 --- a/depthai-ros/CHANGELOG.rst +++ b/depthai-ros/CHANGELOG.rst @@ -1,6 +1,10 @@ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package depthai-ros ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2.10.2 (2024-09-26) +* Fix Stereo K matrix publishing +* Fix socket ID for NN detections +* Remove catching errors when starting the device since it introduced undefined behavior 2.10.1 (2024-09-18) ------------------- diff --git a/depthai-ros/CMakeLists.txt b/depthai-ros/CMakeLists.txt index 3913f5ac..f5b93b25 100644 --- a/depthai-ros/CMakeLists.txt +++ b/depthai-ros/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS -project(depthai-ros VERSION 2.10.1 LANGUAGES CXX C) +project(depthai-ros VERSION 2.10.2 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) diff --git a/depthai-ros/package.xml b/depthai-ros/package.xml index e6993e2d..1a1cbd01 100644 --- a/depthai-ros/package.xml +++ b/depthai-ros/package.xml @@ -1,7 +1,7 @@ depthai-ros - 2.10.1 + 2.10.2 The depthai-ros package Adam Serafin diff --git a/depthai_bridge/CMakeLists.txt b/depthai_bridge/CMakeLists.txt index f9b6e51c..a4380d74 100644 --- a/depthai_bridge/CMakeLists.txt +++ b/depthai_bridge/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS set (CMAKE_POSITION_INDEPENDENT_CODE ON) -project(depthai_bridge VERSION 2.10.1 LANGUAGES CXX C) +project(depthai_bridge VERSION 2.10.2 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/depthai_bridge/package.xml b/depthai_bridge/package.xml index 472f02e9..65a45643 100644 --- a/depthai_bridge/package.xml +++ b/depthai_bridge/package.xml @@ -1,7 +1,7 @@ depthai_bridge - 2.10.1 + 2.10.2 The depthai_bridge package Adam Serafin diff --git a/depthai_descriptions/CMakeLists.txt b/depthai_descriptions/CMakeLists.txt index cabcef61..ef7a8f0e 100644 --- a/depthai_descriptions/CMakeLists.txt +++ b/depthai_descriptions/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10.2) -project(depthai_descriptions VERSION 2.10.1 LANGUAGES CXX C) +project(depthai_descriptions VERSION 2.10.2 LANGUAGES CXX C) find_package(catkin REQUIRED diff --git a/depthai_descriptions/package.xml b/depthai_descriptions/package.xml index 13a68388..11b77fff 100644 --- a/depthai_descriptions/package.xml +++ b/depthai_descriptions/package.xml @@ -1,7 +1,7 @@ depthai_descriptions - 2.10.1 + 2.10.2 The depthai_descriptions package Adam Serafin diff --git a/depthai_examples/CMakeLists.txt b/depthai_examples/CMakeLists.txt index e3861e33..a7c3a632 100644 --- a/depthai_examples/CMakeLists.txt +++ b/depthai_examples/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS -project(depthai_examples VERSION 2.10.1 LANGUAGES CXX C) +project(depthai_examples VERSION 2.10.2 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/depthai_examples/package.xml b/depthai_examples/package.xml index 7e0f988c..e0db793a 100644 --- a/depthai_examples/package.xml +++ b/depthai_examples/package.xml @@ -1,7 +1,7 @@ depthai_examples - 2.10.1 + 2.10.2 The depthai_examples package Adam Serafin diff --git a/depthai_filters/CMakeLists.txt b/depthai_filters/CMakeLists.txt index a2d330a1..21e175f7 100644 --- a/depthai_filters/CMakeLists.txt +++ b/depthai_filters/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10.2) -project(depthai_filters VERSION 2.10.1 LANGUAGES CXX C) +project(depthai_filters VERSION 2.10.2 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/depthai_filters/package.xml b/depthai_filters/package.xml index 3ff34453..f8676528 100644 --- a/depthai_filters/package.xml +++ b/depthai_filters/package.xml @@ -1,7 +1,7 @@ depthai_filters - 2.10.1 + 2.10.2 The depthai_filters package Adam Serafin diff --git a/depthai_ros_driver/CMakeLists.txt b/depthai_ros_driver/CMakeLists.txt index 7c2b9924..9261e511 100644 --- a/depthai_ros_driver/CMakeLists.txt +++ b/depthai_ros_driver/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16.3) -project(depthai_ros_driver VERSION 2.10.1) +project(depthai_ros_driver VERSION 2.10.2) if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif() diff --git a/depthai_ros_driver/package.xml b/depthai_ros_driver/package.xml index 59e50067..98185ad7 100644 --- a/depthai_ros_driver/package.xml +++ b/depthai_ros_driver/package.xml @@ -2,7 +2,7 @@ depthai_ros_driver - 2.10.1 + 2.10.2 Depthai ROS Monolithic node. Adam Serafin Adam Serafin diff --git a/depthai_ros_driver/src/dai_nodes/sensors/sensor_wrapper.cpp b/depthai_ros_driver/src/dai_nodes/sensors/sensor_wrapper.cpp index db82948c..44113907 100644 --- a/depthai_ros_driver/src/dai_nodes/sensors/sensor_wrapper.cpp +++ b/depthai_ros_driver/src/dai_nodes/sensors/sensor_wrapper.cpp @@ -33,8 +33,8 @@ SensorWrapper::SensorWrapper(const std::string& daiNodeName, converter = std::make_unique(true); setNames(); setXinXout(pipeline); - socketID = ph->getParam("i_board_socket_id"); } + socketID = ph->getParam("i_board_socket_id"); if(ph->getParam("i_disable_node") && ph->getParam("i_simulate_from_topic")) { ROS_INFO("Disabling node %s, pipeline data taken from topic.", getName().c_str()); } else { diff --git a/depthai_ros_driver/src/param_handlers/sensor_param_handler.cpp b/depthai_ros_driver/src/param_handlers/sensor_param_handler.cpp index 6c395281..c8cd16a6 100644 --- a/depthai_ros_driver/src/param_handlers/sensor_param_handler.cpp +++ b/depthai_ros_driver/src/param_handlers/sensor_param_handler.cpp @@ -28,7 +28,7 @@ void SensorParamHandler::declareCommonParams(dai::CameraBoardSocket socket) { declareAndLogParam("i_simulated_topic_name", ""); declareAndLogParam("i_disable_node", false); declareAndLogParam("i_get_base_device_timestamp", false); - socketID = static_cast(declareAndLogParam("i_board_socket_id", static_cast(socket), 0)); + socketID = static_cast(declareAndLogParam("i_board_socket_id", static_cast(socket), false)); declareAndLogParam("i_update_ros_base_time_on_ros_msg", false); declareAndLogParam("i_enable_feature_tracker", false); declareAndLogParam("i_enable_nn", false); diff --git a/depthai_ros_msgs/CMakeLists.txt b/depthai_ros_msgs/CMakeLists.txt index b70af73a..ffb2d352 100644 --- a/depthai_ros_msgs/CMakeLists.txt +++ b/depthai_ros_msgs/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS -project (depthai_ros_msgs VERSION 2.10.1) +project (depthai_ros_msgs VERSION 2.10.2) if(POLICY CMP0057) cmake_policy(SET CMP0057 NEW) diff --git a/depthai_ros_msgs/package.xml b/depthai_ros_msgs/package.xml index ccccce4f..3981cb7b 100644 --- a/depthai_ros_msgs/package.xml +++ b/depthai_ros_msgs/package.xml @@ -1,7 +1,7 @@ depthai_ros_msgs - 2.10.1 + 2.10.2 Package to keep interface independent of the driver Adam Serafin From a1e15be3f09b4ace43ef913252aa41cc479eec20 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Thu, 26 Sep 2024 12:45:33 +0000 Subject: [PATCH 02/10] remove try catch in start --- depthai_ros_driver/src/camera.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/depthai_ros_driver/src/camera.cpp b/depthai_ros_driver/src/camera.cpp index f8c36b93..bf227d38 100644 --- a/depthai_ros_driver/src/camera.cpp +++ b/depthai_ros_driver/src/camera.cpp @@ -68,20 +68,11 @@ void Camera::diagCB(const diagnostic_msgs::DiagnosticArray::ConstPtr& msg) { } void Camera::start() { - bool success = false; - while(!success) { - try { - ROS_INFO("Starting camera."); - if(!camRunning) { - onConfigure(); - } else { - ROS_INFO("Camera already running!."); - } - success = true; - } catch(const std::exception& e) { - ROS_ERROR("Exception occurred: %s. Retry", e.what()); - camRunning = false; - } + ROS_INFO("Starting camera."); + if(!camRunning) { + onConfigure(); + } else { + ROS_INFO("Camera already running!."); } } void Camera::stop() { From 93b29b9011c9bce9be15763b65b3dc2b06702632 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Thu, 26 Sep 2024 12:52:16 +0000 Subject: [PATCH 03/10] img_pub change --- depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp b/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp index 763c0e33..59faba5c 100644 --- a/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp +++ b/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp @@ -116,7 +116,6 @@ void ImagePublisher::createInfoManager(std::shared_ptr device) { auto info = sensor_helpers::getCalibInfo(converter, device, pubConfig.socket, pubConfig.width, pubConfig.height); if(pubConfig.rectified) { std::fill(info.D.begin(), info.D.end(), 0.0); - std::fill(info.K.begin(), info.K.end(), 0.0); info.R[0] = info.R[4] = info.R[8] = 1.0; } infoManager->setCameraInfo(info); From f803ecd1ca19d368c02db98152089fdcba3bd65a Mon Sep 17 00:00:00 2001 From: Serafadam Date: Fri, 27 Sep 2024 14:46:09 +0000 Subject: [PATCH 04/10] detection overlay update --- depthai_filters/CMakeLists.txt | 1 + .../depthai_filters/detection2d_overlay.hpp | 9 +++-- depthai_filters/src/detection2d_overlay.cpp | 36 +++++++++++++++++-- .../dai_nodes/nn/detection.hpp | 4 ++- .../dai_nodes/nn/spatial_detection.hpp | 2 +- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/depthai_filters/CMakeLists.txt b/depthai_filters/CMakeLists.txt index 21e175f7..9997b58a 100644 --- a/depthai_filters/CMakeLists.txt +++ b/depthai_filters/CMakeLists.txt @@ -4,6 +4,7 @@ project(depthai_filters VERSION 2.10.2 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_compile_options(-g) add_definitions(-std=c++14) diff --git a/depthai_filters/include/depthai_filters/detection2d_overlay.hpp b/depthai_filters/include/depthai_filters/detection2d_overlay.hpp index 2c3f26e2..b1f6ed39 100644 --- a/depthai_filters/include/depthai_filters/detection2d_overlay.hpp +++ b/depthai_filters/include/depthai_filters/detection2d_overlay.hpp @@ -7,6 +7,7 @@ #include "nodelet/nodelet.h" #include "ros/ros.h" #include "sensor_msgs/Image.h" +#include "sensor_msgs/CameraInfo.h" #include "vision_msgs/Detection2DArray.h" namespace depthai_filters { @@ -14,16 +15,18 @@ class Detection2DOverlay : public nodelet::Nodelet { public: void onInit() override; - void overlayCB(const sensor_msgs::ImageConstPtr& preview, const vision_msgs::Detection2DArrayConstPtr& detections); + void overlayCB(const sensor_msgs::ImageConstPtr& preview, const sensor_msgs::CameraInfoConstPtr& info, const vision_msgs::Detection2DArrayConstPtr& detections); message_filters::Subscriber previewSub; + message_filters::Subscriber infoSub; message_filters::Subscriber detSub; - typedef message_filters::sync_policies::ApproximateTime syncPolicy; + typedef message_filters::sync_policies::ApproximateTime syncPolicy; std::unique_ptr> sync; ros::Publisher overlayPub; std::vector labelMap = {"background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"}; + bool desqueeze = false; }; -} // namespace depthai_filters \ No newline at end of file +} // namespace depthai_filters diff --git a/depthai_filters/src/detection2d_overlay.cpp b/depthai_filters/src/detection2d_overlay.cpp index dbc1876a..2b7a042b 100644 --- a/depthai_filters/src/detection2d_overlay.cpp +++ b/depthai_filters/src/detection2d_overlay.cpp @@ -7,24 +7,50 @@ #include "depthai_filters/utils.hpp" #include "nodelet/nodelet.h" #include "pluginlib/class_list_macros.h" +#include "sensor_msgs/CameraInfo.h" namespace depthai_filters { void Detection2DOverlay::onInit() { auto pNH = getPrivateNodeHandle(); previewSub.subscribe(pNH, "/rgb/preview/image_raw", 1); detSub.subscribe(pNH, "/nn/detections", 1); - sync = std::make_unique>(syncPolicy(10), previewSub, detSub); + infoSub.subscribe(pNH, "rgb/preview/camera_info", 1); + sync = std::make_unique>(syncPolicy(10), previewSub, infoSub, detSub); pNH.getParam("label_map", labelMap); - sync->registerCallback(std::bind(&Detection2DOverlay::overlayCB, this, std::placeholders::_1, std::placeholders::_2)); + pNH.getParam("desqueeze", desqueeze); + sync->registerCallback(std::bind(&Detection2DOverlay::overlayCB, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); overlayPub = pNH.advertise("overlay", 10); } -void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, const vision_msgs::Detection2DArrayConstPtr& detections) { +void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, + const sensor_msgs::CameraInfoConstPtr& info, + const vision_msgs::Detection2DArrayConstPtr& detections) { cv::Mat previewMat = utils::msgToMat(preview, sensor_msgs::image_encodings::BGR8); auto white = cv::Scalar(255, 255, 255); auto black = cv::Scalar(0, 0, 0); auto blue = cv::Scalar(255, 0, 0); + double ratioX = 1.0; + double ratioY = 1.0; + int offsetX = 0; + double offsetY = 0; + // if preview size is less than camera info size + if(previewMat.rows < info->height || previewMat.cols < info->width) { + ratioY = double(info->height) / double(previewMat.rows); + if(desqueeze) { + ratioX = double(info->width) / double(previewMat.cols); + } else { + ratioX = ratioY; + offsetX = (info->width - info->height) / 2.0; + } + } else { + ratioY = double(previewMat.rows) / double(info->height); + if(desqueeze) { + ratioX = double(previewMat.cols) / double(info->width); + } else { + ratioX = double(previewMat.cols) / double(info->width); + } + } for(auto& detection : detections->detections) { auto x1 = detection.bbox.center.x - detections->detections[0].bbox.size_x / 2.0; auto x2 = detection.bbox.center.x + detections->detections[0].bbox.size_x / 2.0; @@ -32,6 +58,10 @@ void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, co auto y2 = detection.bbox.center.y + detections->detections[0].bbox.size_y / 2.0; auto labelStr = labelMap[detection.results[0].id]; auto confidence = detection.results[0].score; + x1 = x1 * ratioX + offsetX; + x2 = x2 * ratioX + offsetX; + y1 = y1 * ratioY + offsetY; + y2 = y2 * ratioY + offsetY; cv::putText(previewMat, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, white, 3); cv::putText(previewMat, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, black); std::stringstream confStr; diff --git a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp index 8adab488..531b4cde 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp @@ -86,9 +86,11 @@ class Detection : public BaseNode { convConf.updateROSBaseTimeOnRosMsg = ph->getParam("i_update_ros_base_time_on_ros_msg"); utils::ImgPublisherConfig pubConf; + pubConf.width = width; + pubConf.height = height; pubConf.daiNodeName = getName(); pubConf.topicName = "~/" + getName(); - pubConf.topicSuffix = "passthrough"; + pubConf.topicSuffix = "/passthrough"; pubConf.socket = static_cast(ph->getParam("i_board_socket_id")); ptPub->setup(device, convConf, pubConf); diff --git a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp index 1729ea5b..710f1f31 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp @@ -80,7 +80,7 @@ class SpatialDetection : public BaseNode { pubConf.height = height; pubConf.daiNodeName = getName(); pubConf.topicName = "~/" + getName(); - pubConf.topicSuffix = "passthrough"; + pubConf.topicSuffix = "/passthrough"; pubConf.socket = static_cast(ph->getParam("i_board_socket_id")); ptPub->setup(device, convConf, pubConf); From 37f4c4ba0eb59b33f72b0fe3f992b21c80854a99 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Mon, 30 Sep 2024 13:36:02 +0000 Subject: [PATCH 05/10] detection overlay update --- depthai_filters/config/detection.yaml | 2 ++ depthai_filters/launch/example_det2d_overlay.launch | 3 ++- depthai_filters/src/detection2d_overlay.cpp | 2 +- .../depthai_ros_driver/dai_nodes/nn/detection.hpp | 5 +++-- .../dai_nodes/nn/spatial_detection.hpp | 10 ++++++---- .../include/depthai_ros_driver/utils.hpp | 1 + depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp | 4 ++-- depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp | 3 ++- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/depthai_filters/config/detection.yaml b/depthai_filters/config/detection.yaml index d4e911dc..ef4640d8 100644 --- a/depthai_filters/config/detection.yaml +++ b/depthai_filters/config/detection.yaml @@ -2,3 +2,5 @@ camera_i_nn_type: rgb rgb_i_enable_preview: true nn_i_enable_passthrough: true +/detection_overlay: + desqueeze: true diff --git a/depthai_filters/launch/example_det2d_overlay.launch b/depthai_filters/launch/example_det2d_overlay.launch index 0b997d8a..64716818 100644 --- a/depthai_filters/launch/example_det2d_overlay.launch +++ b/depthai_filters/launch/example_det2d_overlay.launch @@ -11,7 +11,8 @@ + - \ No newline at end of file + diff --git a/depthai_filters/src/detection2d_overlay.cpp b/depthai_filters/src/detection2d_overlay.cpp index 2b7a042b..7cd2532f 100644 --- a/depthai_filters/src/detection2d_overlay.cpp +++ b/depthai_filters/src/detection2d_overlay.cpp @@ -14,7 +14,7 @@ void Detection2DOverlay::onInit() { auto pNH = getPrivateNodeHandle(); previewSub.subscribe(pNH, "/rgb/preview/image_raw", 1); detSub.subscribe(pNH, "/nn/detections", 1); - infoSub.subscribe(pNH, "rgb/preview/camera_info", 1); + infoSub.subscribe(pNH, "/rgb/preview/camera_info", 1); sync = std::make_unique>(syncPolicy(10), previewSub, infoSub, detSub); pNH.getParam("label_map", labelMap); pNH.getParam("desqueeze", desqueeze); diff --git a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp index 531b4cde..f9d14b92 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp @@ -89,8 +89,9 @@ class Detection : public BaseNode { pubConf.width = width; pubConf.height = height; pubConf.daiNodeName = getName(); - pubConf.topicName = "~/" + getName(); - pubConf.topicSuffix = "/passthrough"; + pubConf.topicName = getName() + "/passthrough"; + pubConf.infoSuffix = "/passthrough"; + pubConf.infoMgrSuffix = "/passthrough"; pubConf.socket = static_cast(ph->getParam("i_board_socket_id")); ptPub->setup(device, convConf, pubConf); diff --git a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp index 710f1f31..adb21a8b 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp @@ -79,8 +79,9 @@ class SpatialDetection : public BaseNode { pubConf.width = width; pubConf.height = height; pubConf.daiNodeName = getName(); - pubConf.topicName = "~/" + getName(); - pubConf.topicSuffix = "/passthrough"; + pubConf.topicName = getName() + "/passthrough"; + pubConf.infoSuffix = "/passthrough"; + pubConf.infoMgrSuffix = "/passthrough"; pubConf.socket = static_cast(ph->getParam("i_board_socket_id")); ptPub->setup(device, convConf, pubConf); @@ -100,8 +101,9 @@ class SpatialDetection : public BaseNode { pubConf.width = ph->getOtherNodeParam(sensor_helpers::getNodeName(getROSNode(), sensor_helpers::NodeNameEnum::Stereo), "i_width"); pubConf.height = ph->getOtherNodeParam(sensor_helpers::getNodeName(getROSNode(), sensor_helpers::NodeNameEnum::Stereo), "i_height"); pubConf.daiNodeName = getName(); - pubConf.topicName = "~/" + getName(); - pubConf.topicSuffix = "/passthrough_depth"; + pubConf.topicName = getName() + "/passthrough_depth"; + pubConf.infoSuffix = "/passthrough_depth"; + pubConf.infoMgrSuffix = "/passthrough_depth"; pubConf.socket = socket; ptDepthPub->setup(device, convConf, pubConf); diff --git a/depthai_ros_driver/include/depthai_ros_driver/utils.hpp b/depthai_ros_driver/include/depthai_ros_driver/utils.hpp index 59f67fb0..28edf7cf 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/utils.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/utils.hpp @@ -66,6 +66,7 @@ struct ImgPublisherConfig { dai::CameraBoardSocket rightSocket = dai::CameraBoardSocket::CAM_C; std::string calibrationFile = ""; std::string topicSuffix = "/image_raw"; + std::string infoSuffix = ""; std::string compressedTopicSuffix = "/image_raw/compressed"; std::string infoMgrSuffix = ""; bool rectified = false; diff --git a/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp b/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp index 59faba5c..811aebdf 100644 --- a/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp +++ b/depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp @@ -64,7 +64,7 @@ void ImagePublisher::setup(std::shared_ptr device, const utils::Img } else { ffmpegPub = node.advertise(pubConfig.topicName + pubConfig.compressedTopicSuffix, 10); } - infoPub = node.advertise(pubConfig.topicName + "/camera_info", 10); + infoPub = node.advertise(pubConfig.topicName + pubConfig.infoSuffix + "/camera_info", 10); } else { imgPubIT = it.advertiseCamera(pubConfig.topicName + pubConfig.topicSuffix, 10); } @@ -110,7 +110,7 @@ std::shared_ptr ImagePublisher::createEncoder(std::shar return enc; } void ImagePublisher::createInfoManager(std::shared_ptr device) { - infoManager = std::make_shared(ros::NodeHandle(node, pubConfig.daiNodeName), + infoManager = std::make_shared(ros::NodeHandle(node, pubConfig.daiNodeName + pubConfig.infoMgrSuffix), "/" + pubConfig.daiNodeName + pubConfig.infoMgrSuffix); if(pubConfig.calibrationFile.empty()) { auto info = sensor_helpers::getCalibInfo(converter, device, pubConfig.socket, pubConfig.width, pubConfig.height); diff --git a/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp b/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp index 673dd2de..54617ba2 100644 --- a/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp +++ b/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp @@ -99,7 +99,7 @@ void RGB::setupQueues(std::shared_ptr device) { utils::ImgPublisherConfig pubConfig; pubConfig.daiNodeName = getName(); - pubConfig.topicName = "~/" + getName(); + pubConfig.topicName = getName(); pubConfig.lazyPub = ph->getParam("i_enable_lazy_publisher"); pubConfig.socket = static_cast(ph->getParam("i_board_socket_id")); pubConfig.calibrationFile = ph->getParam("i_calibration_file"); @@ -108,6 +108,7 @@ void RGB::setupQueues(std::shared_ptr device) { pubConfig.height = ph->getParam("i_preview_height"); pubConfig.maxQSize = ph->getParam("i_max_q_size"); pubConfig.topicSuffix = "/preview/image_raw"; + pubConfig.infoMgrSuffix = "/preview"; previewPub->setup(device, convConfig, pubConfig); }; From d8d1b99830f9ccf837f19677acddab3e1af0a969 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Wed, 2 Oct 2024 09:59:36 +0000 Subject: [PATCH 06/10] add desqueeze output to nn --- depthai_filters/config/detection.yaml | 2 -- .../depthai_filters/detection2d_overlay.hpp | 7 ++-- .../launch/example_det2d_overlay.launch | 1 - depthai_filters/src/detection2d_overlay.cpp | 32 ++----------------- .../dai_nodes/nn/detection.hpp | 9 ++++-- .../param_handlers/nn_param_handler.hpp | 3 +- .../src/dai_nodes/nn/nn_wrapper.cpp | 6 ++-- .../src/dai_nodes/nn/spatial_nn_wrapper.cpp | 4 +-- 8 files changed, 17 insertions(+), 47 deletions(-) diff --git a/depthai_filters/config/detection.yaml b/depthai_filters/config/detection.yaml index ef4640d8..d4e911dc 100644 --- a/depthai_filters/config/detection.yaml +++ b/depthai_filters/config/detection.yaml @@ -2,5 +2,3 @@ camera_i_nn_type: rgb rgb_i_enable_preview: true nn_i_enable_passthrough: true -/detection_overlay: - desqueeze: true diff --git a/depthai_filters/include/depthai_filters/detection2d_overlay.hpp b/depthai_filters/include/depthai_filters/detection2d_overlay.hpp index b1f6ed39..866946e8 100644 --- a/depthai_filters/include/depthai_filters/detection2d_overlay.hpp +++ b/depthai_filters/include/depthai_filters/detection2d_overlay.hpp @@ -7,7 +7,6 @@ #include "nodelet/nodelet.h" #include "ros/ros.h" #include "sensor_msgs/Image.h" -#include "sensor_msgs/CameraInfo.h" #include "vision_msgs/Detection2DArray.h" namespace depthai_filters { @@ -15,18 +14,16 @@ class Detection2DOverlay : public nodelet::Nodelet { public: void onInit() override; - void overlayCB(const sensor_msgs::ImageConstPtr& preview, const sensor_msgs::CameraInfoConstPtr& info, const vision_msgs::Detection2DArrayConstPtr& detections); + void overlayCB(const sensor_msgs::ImageConstPtr& preview, const vision_msgs::Detection2DArrayConstPtr& detections); message_filters::Subscriber previewSub; - message_filters::Subscriber infoSub; message_filters::Subscriber detSub; - typedef message_filters::sync_policies::ApproximateTime syncPolicy; + typedef message_filters::sync_policies::ApproximateTime syncPolicy; std::unique_ptr> sync; ros::Publisher overlayPub; std::vector labelMap = {"background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"}; - bool desqueeze = false; }; } // namespace depthai_filters diff --git a/depthai_filters/launch/example_det2d_overlay.launch b/depthai_filters/launch/example_det2d_overlay.launch index 64716818..8a84e971 100644 --- a/depthai_filters/launch/example_det2d_overlay.launch +++ b/depthai_filters/launch/example_det2d_overlay.launch @@ -11,7 +11,6 @@ - diff --git a/depthai_filters/src/detection2d_overlay.cpp b/depthai_filters/src/detection2d_overlay.cpp index 7cd2532f..2d3934d0 100644 --- a/depthai_filters/src/detection2d_overlay.cpp +++ b/depthai_filters/src/detection2d_overlay.cpp @@ -14,43 +14,19 @@ void Detection2DOverlay::onInit() { auto pNH = getPrivateNodeHandle(); previewSub.subscribe(pNH, "/rgb/preview/image_raw", 1); detSub.subscribe(pNH, "/nn/detections", 1); - infoSub.subscribe(pNH, "/rgb/preview/camera_info", 1); - sync = std::make_unique>(syncPolicy(10), previewSub, infoSub, detSub); + sync = std::make_unique>(syncPolicy(10), previewSub, detSub); pNH.getParam("label_map", labelMap); - pNH.getParam("desqueeze", desqueeze); - sync->registerCallback(std::bind(&Detection2DOverlay::overlayCB, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + sync->registerCallback(std::bind(&Detection2DOverlay::overlayCB, this, std::placeholders::_1, std::placeholders::_2)); overlayPub = pNH.advertise("overlay", 10); } void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, - const sensor_msgs::CameraInfoConstPtr& info, const vision_msgs::Detection2DArrayConstPtr& detections) { cv::Mat previewMat = utils::msgToMat(preview, sensor_msgs::image_encodings::BGR8); auto white = cv::Scalar(255, 255, 255); auto black = cv::Scalar(0, 0, 0); auto blue = cv::Scalar(255, 0, 0); - double ratioX = 1.0; - double ratioY = 1.0; - int offsetX = 0; - double offsetY = 0; - // if preview size is less than camera info size - if(previewMat.rows < info->height || previewMat.cols < info->width) { - ratioY = double(info->height) / double(previewMat.rows); - if(desqueeze) { - ratioX = double(info->width) / double(previewMat.cols); - } else { - ratioX = ratioY; - offsetX = (info->width - info->height) / 2.0; - } - } else { - ratioY = double(previewMat.rows) / double(info->height); - if(desqueeze) { - ratioX = double(previewMat.cols) / double(info->width); - } else { - ratioX = double(previewMat.cols) / double(info->width); - } - } for(auto& detection : detections->detections) { auto x1 = detection.bbox.center.x - detections->detections[0].bbox.size_x / 2.0; auto x2 = detection.bbox.center.x + detections->detections[0].bbox.size_x / 2.0; @@ -58,10 +34,6 @@ void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, auto y2 = detection.bbox.center.y + detections->detections[0].bbox.size_y / 2.0; auto labelStr = labelMap[detection.results[0].id]; auto confidence = detection.results[0].score; - x1 = x1 * ratioX + offsetX; - x2 = x2 * ratioX + offsetX; - y1 = y1 * ratioY + offsetY; - y2 = y2 * ratioY + offsetY; cv::putText(previewMat, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, white, 3); cv::putText(previewMat, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, black); std::stringstream confStr; diff --git a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp index f9d14b92..3467856c 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp @@ -70,6 +70,9 @@ class Detection : public BaseNode { if(ph->getParam("i_disable_resize")) { width = ph->getOtherNodeParam(socketName, "i_preview_width"); height = ph->getOtherNodeParam(socketName, "i_preview_height"); + } else if(ph->getParam("i_desqueeze_output")) { + width = ph->getOtherNodeParam(socketName, "i_width"); + height = ph->getOtherNodeParam(socketName, "i_height"); } else { width = imageManip->initialConfig.getResizeConfig().width; height = imageManip->initialConfig.getResizeConfig().height; @@ -86,12 +89,12 @@ class Detection : public BaseNode { convConf.updateROSBaseTimeOnRosMsg = ph->getParam("i_update_ros_base_time_on_ros_msg"); utils::ImgPublisherConfig pubConf; - pubConf.width = width; - pubConf.height = height; + pubConf.width = width; + pubConf.height = height; pubConf.daiNodeName = getName(); pubConf.topicName = getName() + "/passthrough"; pubConf.infoSuffix = "/passthrough"; - pubConf.infoMgrSuffix = "/passthrough"; + pubConf.infoMgrSuffix = "/passthrough"; pubConf.socket = static_cast(ph->getParam("i_board_socket_id")); ptPub->setup(device, convConf, pubConf); diff --git a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp index 4d91c053..6c95f5e9 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp @@ -40,6 +40,7 @@ class NNParamHandler : public BaseParamHandler { template void declareParams(std::shared_ptr nn, std::shared_ptr imageManip) { declareAndLogParam("i_disable_resize", false); + declareAndLogParam("i_desqueeze_output", false); declareAndLogParam("i_enable_passthrough", false); declareAndLogParam("i_enable_passthrough_depth", false); declareAndLogParam("i_get_base_device_timestamp", false); @@ -124,4 +125,4 @@ class NNParamHandler : public BaseParamHandler { std::vector labels; }; } // namespace param_handlers -} // namespace depthai_ros_driver \ No newline at end of file +} // namespace depthai_ros_driver diff --git a/depthai_ros_driver/src/dai_nodes/nn/nn_wrapper.cpp b/depthai_ros_driver/src/dai_nodes/nn/nn_wrapper.cpp index 3c2754cc..af0a1a9e 100644 --- a/depthai_ros_driver/src/dai_nodes/nn/nn_wrapper.cpp +++ b/depthai_ros_driver/src/dai_nodes/nn/nn_wrapper.cpp @@ -17,15 +17,15 @@ NNWrapper::NNWrapper(const std::string& daiNodeName, ros::NodeHandle node, std:: auto family = ph->getNNFamily(); switch(family) { case param_handlers::nn::NNFamily::Yolo: { - nnNode = std::make_unique>(getName(), getROSNode(), pipeline); + nnNode = std::make_unique>(getName(), getROSNode(), pipeline, socket); break; } case param_handlers::nn::NNFamily::Mobilenet: { - nnNode = std::make_unique>(getName(), getROSNode(), pipeline); + nnNode = std::make_unique>(getName(), getROSNode(), pipeline, socket); break; } case param_handlers::nn::NNFamily::Segmentation: { - nnNode = std::make_unique(getName(), getROSNode(), pipeline); + nnNode = std::make_unique(getName(), getROSNode(), pipeline, socket); break; } } diff --git a/depthai_ros_driver/src/dai_nodes/nn/spatial_nn_wrapper.cpp b/depthai_ros_driver/src/dai_nodes/nn/spatial_nn_wrapper.cpp index 83513d04..e855b41c 100644 --- a/depthai_ros_driver/src/dai_nodes/nn/spatial_nn_wrapper.cpp +++ b/depthai_ros_driver/src/dai_nodes/nn/spatial_nn_wrapper.cpp @@ -19,11 +19,11 @@ SpatialNNWrapper::SpatialNNWrapper(const std::string& daiNodeName, auto family = ph->getNNFamily(); switch(family) { case param_handlers::nn::NNFamily::Yolo: { - nnNode = std::make_unique>(getName(), getROSNode(), pipeline); + nnNode = std::make_unique>(getName(), getROSNode(), pipeline, socket); break; } case param_handlers::nn::NNFamily::Mobilenet: { - nnNode = std::make_unique>(getName(), getROSNode(), pipeline); + nnNode = std::make_unique>(getName(), getROSNode(), pipeline, socket); break; } case param_handlers::nn::NNFamily::Segmentation: { From 30af6f00bf45149f16f2f65c7be1027b1026da1a Mon Sep 17 00:00:00 2001 From: Serafadam Date: Wed, 2 Oct 2024 11:49:27 +0000 Subject: [PATCH 07/10] format --- depthai_filters/src/detection2d_overlay.cpp | 5 ++--- .../depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp | 4 ++-- .../depthai_ros_driver/param_handlers/nn_param_handler.hpp | 2 +- depthai_ros_driver/include/depthai_ros_driver/utils.hpp | 2 +- depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/depthai_filters/src/detection2d_overlay.cpp b/depthai_filters/src/detection2d_overlay.cpp index 2d3934d0..b45d4e2a 100644 --- a/depthai_filters/src/detection2d_overlay.cpp +++ b/depthai_filters/src/detection2d_overlay.cpp @@ -14,14 +14,13 @@ void Detection2DOverlay::onInit() { auto pNH = getPrivateNodeHandle(); previewSub.subscribe(pNH, "/rgb/preview/image_raw", 1); detSub.subscribe(pNH, "/nn/detections", 1); - sync = std::make_unique>(syncPolicy(10), previewSub, detSub); + sync = std::make_unique>(syncPolicy(10), previewSub, detSub); pNH.getParam("label_map", labelMap); sync->registerCallback(std::bind(&Detection2DOverlay::overlayCB, this, std::placeholders::_1, std::placeholders::_2)); overlayPub = pNH.advertise("overlay", 10); } -void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, - const vision_msgs::Detection2DArrayConstPtr& detections) { +void Detection2DOverlay::overlayCB(const sensor_msgs::ImageConstPtr& preview, const vision_msgs::Detection2DArrayConstPtr& detections) { cv::Mat previewMat = utils::msgToMat(preview, sensor_msgs::image_encodings::BGR8); auto white = cv::Scalar(255, 255, 255); auto black = cv::Scalar(0, 0, 0); diff --git a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp index adb21a8b..c6095d3a 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/spatial_detection.hpp @@ -81,7 +81,7 @@ class SpatialDetection : public BaseNode { pubConf.daiNodeName = getName(); pubConf.topicName = getName() + "/passthrough"; pubConf.infoSuffix = "/passthrough"; - pubConf.infoMgrSuffix = "/passthrough"; + pubConf.infoMgrSuffix = "/passthrough"; pubConf.socket = static_cast(ph->getParam("i_board_socket_id")); ptPub->setup(device, convConf, pubConf); @@ -103,7 +103,7 @@ class SpatialDetection : public BaseNode { pubConf.daiNodeName = getName(); pubConf.topicName = getName() + "/passthrough_depth"; pubConf.infoSuffix = "/passthrough_depth"; - pubConf.infoMgrSuffix = "/passthrough_depth"; + pubConf.infoMgrSuffix = "/passthrough_depth"; pubConf.socket = socket; ptDepthPub->setup(device, convConf, pubConf); diff --git a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp index 6c95f5e9..8f8c7a8b 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp @@ -40,7 +40,7 @@ class NNParamHandler : public BaseParamHandler { template void declareParams(std::shared_ptr nn, std::shared_ptr imageManip) { declareAndLogParam("i_disable_resize", false); - declareAndLogParam("i_desqueeze_output", false); + declareAndLogParam("i_desqueeze_output", false); declareAndLogParam("i_enable_passthrough", false); declareAndLogParam("i_enable_passthrough_depth", false); declareAndLogParam("i_get_base_device_timestamp", false); diff --git a/depthai_ros_driver/include/depthai_ros_driver/utils.hpp b/depthai_ros_driver/include/depthai_ros_driver/utils.hpp index 28edf7cf..0dbcfa00 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/utils.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/utils.hpp @@ -66,7 +66,7 @@ struct ImgPublisherConfig { dai::CameraBoardSocket rightSocket = dai::CameraBoardSocket::CAM_C; std::string calibrationFile = ""; std::string topicSuffix = "/image_raw"; - std::string infoSuffix = ""; + std::string infoSuffix = ""; std::string compressedTopicSuffix = "/image_raw/compressed"; std::string infoMgrSuffix = ""; bool rectified = false; diff --git a/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp b/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp index 54617ba2..03f2ef81 100644 --- a/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp +++ b/depthai_ros_driver/src/dai_nodes/sensors/rgb.cpp @@ -108,7 +108,7 @@ void RGB::setupQueues(std::shared_ptr device) { pubConfig.height = ph->getParam("i_preview_height"); pubConfig.maxQSize = ph->getParam("i_max_q_size"); pubConfig.topicSuffix = "/preview/image_raw"; - pubConfig.infoMgrSuffix = "/preview"; + pubConfig.infoMgrSuffix = "/preview"; previewPub->setup(device, convConfig, pubConfig); }; From 76e2b66afa6e9c0e21d3c1e6a2bc1edab1d5d359 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Wed, 2 Oct 2024 12:33:06 +0000 Subject: [PATCH 08/10] update changelog --- depthai-ros/CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/depthai-ros/CHANGELOG.rst b/depthai-ros/CHANGELOG.rst index 9ea65db0..ae93e0c7 100644 --- a/depthai-ros/CHANGELOG.rst +++ b/depthai-ros/CHANGELOG.rst @@ -2,9 +2,11 @@ Changelog for package depthai-ros ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2.10.2 (2024-09-26) +------------------- * Fix Stereo K matrix publishing * Fix socket ID for NN detections * Remove catching errors when starting the device since it introduced undefined behavior +* Add desqueeze to NN node 2.10.1 (2024-09-18) ------------------- From 47de5abfa9594c1bb9ce124a4331c796ae9d2eee Mon Sep 17 00:00:00 2001 From: Serafadam Date: Fri, 4 Oct 2024 06:49:02 +0000 Subject: [PATCH 09/10] update nn params --- .../param_handlers/nn_param_handler.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp index 8f8c7a8b..b9f6f45e 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp @@ -107,11 +107,15 @@ class NNParamHandler : public BaseParamHandler { json data = json::parse(f); if(data.contains("model") && data.contains("nn_config")) { auto modelPath = getModelPath(data); - setImageManip(modelPath, imageManip); + modelPath = declareAndLogParam("i_model_path", modelPath); + if(!getParam("i_disable_resize")) { + setImageManip(modelPath, imageManip); + } nn->setBlobPath(modelPath); - nn->setNumPoolFrames(4); - nn->setNumInferenceThreads(2); + nn->setNumPoolFrames(declareAndLogParam("i_num_pool_frames", 4)); + nn->setNumInferenceThreads(declareAndLogParam("i_num_inference_threads", 2)); nn->input.setBlocking(false); + declareAndLogParam("i_max_q_size", 30); setNNParams(data, nn); } } From d09b19e50436878f3ae9e8965b1aeedea6b82090 Mon Sep 17 00:00:00 2001 From: Serafadam Date: Fri, 4 Oct 2024 12:25:44 +0000 Subject: [PATCH 10/10] format --- .../param_handlers/nn_param_handler.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp index b9f6f45e..c8720b62 100644 --- a/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp +++ b/depthai_ros_driver/include/depthai_ros_driver/param_handlers/nn_param_handler.hpp @@ -107,15 +107,15 @@ class NNParamHandler : public BaseParamHandler { json data = json::parse(f); if(data.contains("model") && data.contains("nn_config")) { auto modelPath = getModelPath(data); - modelPath = declareAndLogParam("i_model_path", modelPath); - if(!getParam("i_disable_resize")) { - setImageManip(modelPath, imageManip); - } + modelPath = declareAndLogParam("i_model_path", modelPath); + if(!getParam("i_disable_resize")) { + setImageManip(modelPath, imageManip); + } nn->setBlobPath(modelPath); nn->setNumPoolFrames(declareAndLogParam("i_num_pool_frames", 4)); nn->setNumInferenceThreads(declareAndLogParam("i_num_inference_threads", 2)); nn->input.setBlocking(false); - declareAndLogParam("i_max_q_size", 30); + declareAndLogParam("i_max_q_size", 30); setNNParams(data, nn); } }