From 6220d780a8581868e6ad2977f2656a0740b24866 Mon Sep 17 00:00:00 2001 From: Alberto Tudela Date: Tue, 13 Dec 2022 10:59:30 +0100 Subject: [PATCH] Minor fixes --- CMakeLists.txt | 6 +++++- .../object_detection_openvino/detectionObject.hpp | 7 ++++++- params/default_params.yaml | 2 +- src/objectDetectionVPU.cpp | 15 +++++++++++++++ src/objectDetectionVPU_node.cpp | 2 +- src/openvino.cpp | 4 ++-- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64af17b..edb902e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ if(NOT CMAKE_CXX_STANDARD) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - #add_compile_options(-Wall -Wextra -Wpedantic) + add_compile_options(-Wall -Wextra -Wpedantic) endif() ################################################ @@ -110,6 +110,10 @@ install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/ ) +install(DIRECTORY models + DESTINATION share/${PROJECT_NAME}/ +) + install(DIRECTORY params DESTINATION share/${PROJECT_NAME}/ ) diff --git a/include/object_detection_openvino/detectionObject.hpp b/include/object_detection_openvino/detectionObject.hpp index a3c2121..93a91ec 100644 --- a/include/object_detection_openvino/detectionObject.hpp +++ b/include/object_detection_openvino/detectionObject.hpp @@ -118,7 +118,12 @@ struct DetectionObject{ } /** - * @brief Relational operator of OBJECT_DETECTION_OPENVINO__YOLO_PARAMS_HPP_bject &s2) const { + * @brief Relational operator of the confidence of the detected object. + * + * @param s2 Object to compare to. + * @return True if the left object has lower confidence than the right one. False, otherwise. + */ + bool operator<(const DetectionObject &s2) const { return this->confidence < s2.confidence; } diff --git a/params/default_params.yaml b/params/default_params.yaml index feeae36..abb283a 100644 --- a/params/default_params.yaml +++ b/params/default_params.yaml @@ -11,7 +11,7 @@ object_detection: detections_3d_topic: detections_3d # Thresholds parameters model_thresh: 0.4 - model_iou_thresh: 0. 4 + model_iou_thresh: 0.4 # Model parameters model_xml: model.xml model_bin: model.bin diff --git a/src/objectDetectionVPU.cpp b/src/objectDetectionVPU.cpp index be770b4..40a312c 100644 --- a/src/objectDetectionVPU.cpp +++ b/src/objectDetectionVPU.cpp @@ -94,40 +94,55 @@ void ObjectDetectionVPU::get_params(){ // Model parameters this->declare_parameter("model_thresh", 0.3); this->get_parameter("model_thresh", thresh_); + RCLCPP_INFO(this->get_logger(), "The parameter model_thresh is set to: [%f]", thresh_); this->declare_parameter("model_iou_thresh", 0.4); this->get_parameter("model_iou_thresh", iou_thresh_); + RCLCPP_INFO(this->get_logger(), "The parameter model_iou_thresh is set to: [%f]", iou_thresh_); // Network parameters this->declare_parameter("model_xml", ""); this->get_parameter("model_xml", model_filename_); + RCLCPP_INFO(this->get_logger(), "The parameter model_xml is set to: [%s]", model_filename_.c_str()); this->declare_parameter("model_bin", ""); this->get_parameter("model_bin", bin_filename_); + RCLCPP_INFO(this->get_logger(), "The parameter model_bin is set to: [%s]", bin_filename_.c_str()); this->declare_parameter("model_labels", ""); this->get_parameter("model_labels", label_filename_); + RCLCPP_INFO(this->get_logger(), "The parameter model_labels is set to: [%s]", label_filename_.c_str()); this->declare_parameter("model_type", ""); this->get_parameter("model_type", network_type_); + RCLCPP_INFO(this->get_logger(), "The parameter model_type is set to: [%s]", network_type_.c_str()); this->declare_parameter("device_target", "CPU"); this->get_parameter("device_target", device_target_); + RCLCPP_INFO(this->get_logger(), "The parameter device_target is set to: [%s]", device_target_.c_str()); this->declare_parameter("camera_frame", "camera_link"); this->get_parameter("camera_frame", camera_frame_); + RCLCPP_INFO(this->get_logger(), "The parameter camera_frame is set to: [%s]", camera_frame_.c_str()); // Topics this->declare_parameter("color_topic", "/camera/color/image_raw"); this->get_parameter("color_topic", color_topic_); + RCLCPP_INFO(this->get_logger(), "The parameter color_topic is set to: [%s]", color_topic_.c_str()); this->declare_parameter("points_topic", ""); this->get_parameter("points_topic", pointcloud_topic_); + RCLCPP_INFO(this->get_logger(), "The parameter points_topic is set to: [%s]", pointcloud_topic_.c_str()); this->declare_parameter("detection_info_topic", "/detection_info"); this->get_parameter("detection_info_topic", detection_info_topic_); + RCLCPP_INFO(this->get_logger(), "The parameter detection_info_topic is set to: [%s]", detection_info_topic_.c_str()); this->declare_parameter("detection_image_topic", "/detection_image"); this->get_parameter("detection_image_topic", detection_image_topic_); + RCLCPP_INFO(this->get_logger(), "The parameter detection_image_topic is set to: [%s]", detection_image_topic_.c_str()); this->declare_parameter("detections_2d_topic", "/detections_2d"); this->get_parameter("detections_2d_topic", detections_2d_topic_); + RCLCPP_INFO(this->get_logger(), "The parameter detections_2d_topic is set to: [%s]", detections_2d_topic_.c_str()); this->declare_parameter("detections_3d_topic", "/detections_3d"); this->get_parameter("detections_3d_topic", detections_3d_topic_); + RCLCPP_INFO(this->get_logger(), "The parameter detections_3d_topic is set to: [%s]", detections_3d_topic_.c_str()); this->declare_parameter("show_fps", false); this->get_parameter("show_fps", show_fps_); + RCLCPP_INFO(this->get_logger(), "The parameter show_fps is set to: [%s]", show_fps_ ? "true" : "false"); } // TODO(ros2) Implement when SubscriberStatusCallback is available diff --git a/src/objectDetectionVPU_node.cpp b/src/objectDetectionVPU_node.cpp index a755cf8..39049d5 100644 --- a/src/objectDetectionVPU_node.cpp +++ b/src/objectDetectionVPU_node.cpp @@ -16,7 +16,7 @@ int main(int argc, char** argv){ rclcpp::init(argc, argv); - auto node = std::make_shared("object_detection_vpu"); + auto node = std::make_shared("object_detection"); rclcpp::spin(node); rclcpp::shutdown(); return 0; diff --git a/src/openvino.cpp b/src/openvino.cpp index 9395454..6f3cd3a 100644 --- a/src/openvino.cpp +++ b/src/openvino.cpp @@ -201,10 +201,10 @@ std::vector Openvino::get_detection_objects(size_t height, // Filtering overlapping boxes std::sort(objects.begin(), objects.end(), std::greater()); - for (int i = 0; i < objects.size(); ++i){ + for (unsigned int i = 0; i < objects.size(); ++i){ if (objects[i].confidence == 0) continue; - for (int j = i + 1; j < objects.size(); ++j) { + for (unsigned int j = i + 1; j < objects.size(); ++j) { if (intersection_over_union(objects[i], objects[j]) >= iou_threshold) { objects[j].confidence = 0; }