Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtudela committed Dec 13, 2022
1 parent ec3c07d commit 6220d78
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

################################################
Expand Down Expand Up @@ -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}/
)
Expand Down
7 changes: 6 additions & 1 deletion include/object_detection_openvino/detectionObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion params/default_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/objectDetectionVPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/objectDetectionVPU_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
int main(int argc, char** argv){
rclcpp::init(argc, argv);

auto node = std::make_shared<ObjectDetectionVPU>("object_detection_vpu");
auto node = std::make_shared<ObjectDetectionVPU>("object_detection");
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/openvino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ std::vector<DetectionObject> Openvino::get_detection_objects(size_t height,

// Filtering overlapping boxes
std::sort(objects.begin(), objects.end(), std::greater<DetectionObject>());
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;
}
Expand Down

0 comments on commit 6220d78

Please sign in to comment.