Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(image_projection_based_fusion): add run length decoding for segmentation_pointcloud_fusion #7909

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@

# the maximum distance of pointcloud to be applied filter
filter_distance_threshold: 60.0
is_publish_debug_mask: false
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "autoware/image_projection_based_fusion/fusion_node.hpp"

#include <autoware/image_projection_based_fusion/utils/utils.hpp>
#include <image_transport/image_transport.hpp>

#include <string>
#include <utility>
Expand All @@ -44,6 +45,9 @@ class SegmentPointCloudFusionNode : public FusionNode<PointCloud2, PointCloud2,
{"BIKE", false}, {"ROAD", false}, {"SIDEWALK", false}, {"ROAD_PAINT", false},
{"CURBSTONE", false}, {"CROSSWALK", false}, {"VEGETATION", false}, {"SKY", false}};

image_transport::Publisher pub_debug_mask_ptr_;
bool is_publish_debug_mask_;

public:
explicit SegmentPointCloudFusionNode(const rclcpp::NodeOptions & options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<depend>autoware_lidar_centerpoint</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_point_types</depend>
<depend>autoware_tensorrt_yolox</depend>
<depend>autoware_universe_utils</depend>
<depend>cv_bridge</depend>
<depend>image_geometry</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@
"description": "A maximum distance of pointcloud to apply filter [m].",
"default": 60.0,
"minimum": 0.0
},
"is_publish_debug_mask": {
"type": "boolean",
"description": "If true, debug mask image will be published.",
"default": false
}
},
"required": ["filter_semantic_label_target", "filter_distance_threshold"]
"required": [
"filter_semantic_label_target",
"filter_distance_threshold",
"is_publish_debug_mask"
]
}
},
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "autoware/image_projection_based_fusion/utils/geometry.hpp"
#include "autoware/image_projection_based_fusion/utils/utils.hpp"
#include "autoware/tensorrt_yolox/utils.hpp"

#ifdef ROS_DISTRO_GALACTIC
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
Expand All @@ -38,6 +39,8 @@ SegmentPointCloudFusionNode::SegmentPointCloudFusionNode(const rclcpp::NodeOptio
RCLCPP_INFO(
this->get_logger(), "filter_semantic_label_target: %s %d", item.first.c_str(), item.second);
}
is_publish_debug_mask_ = declare_parameter<bool>("is_publish_debug_mask");
pub_debug_mask_ptr_ = image_transport::create_publisher(this, "debug/mask");
}

void SegmentPointCloudFusionNode::preprocess(__attribute__((unused)) PointCloud2 & pointcloud_msg)
Expand All @@ -57,19 +60,23 @@ void SegmentPointCloudFusionNode::fuseOnSingleImage(
if (input_pointcloud_msg.data.empty()) {
return;
}
cv_bridge::CvImagePtr in_image_ptr;
try {
in_image_ptr = cv_bridge::toCvCopy(
std::make_shared<sensor_msgs::msg::Image>(input_mask), input_mask.encoding);
} catch (const std::exception & e) {
RCLCPP_ERROR(this->get_logger(), "cv_bridge exception:%s", e.what());
if (input_mask.height == 0 || input_mask.width == 0) {
return;
}

cv::Mat mask = in_image_ptr->image;
if (mask.cols == 0 || mask.rows == 0) {
return;
cv::Mat mask = autoware::tensorrt_yolox::runLengthDecoder(
input_mask.data, input_mask.height, input_mask.width);
// publish debug mask
if (is_publish_debug_mask_) {
sensor_msgs::msg::Image::SharedPtr debug_mask_msg =
cv_bridge::CvImage(std_msgs::msg::Header(), "mono8", mask).toImageMsg();
debug_mask_msg->header = input_mask.header;
pub_debug_mask_ptr_.publish(debug_mask_msg);
}
Eigen::Matrix4d projection;
projection << camera_info.p.at(0), camera_info.p.at(1), camera_info.p.at(2), camera_info.p.at(3),
camera_info.p.at(4), camera_info.p.at(5), camera_info.p.at(6), camera_info.p.at(7),
camera_info.p.at(8), camera_info.p.at(9), camera_info.p.at(10), camera_info.p.at(11), 0.0, 0.0,
0.0, 1.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kminoda thank you for you comment. I my mistake when rebased branch. I fixed t b8abe57

const int orig_width = camera_info.width;
const int orig_height = camera_info.height;
// resize mask to the same size as the camera image
Expand Down
Loading