17
17
#include " image_projection_based_fusion/utils/geometry.hpp"
18
18
#include " image_projection_based_fusion/utils/utils.hpp"
19
19
20
+ #include < perception_utils/run_length_encoder.hpp>
21
+
20
22
#ifdef ROS_DISTRO_GALACTIC
21
23
#include < tf2_geometry_msgs/tf2_geometry_msgs.h>
22
24
#include < tf2_sensor_msgs/tf2_sensor_msgs.h>
@@ -38,6 +40,8 @@ SegmentPointCloudFusionNode::SegmentPointCloudFusionNode(const rclcpp::NodeOptio
38
40
RCLCPP_INFO (
39
41
this ->get_logger (), " filter_semantic_label_target: %s %d" , item.first .c_str (), item.second );
40
42
}
43
+ is_publish_debug_mask_ = declare_parameter<bool >(" is_publish_debug_mask" );
44
+ pub_debug_mask_ptr_ = image_transport::create_publisher (this , " ~/debug/mask" );
41
45
}
42
46
43
47
void SegmentPointCloudFusionNode::preprocess (__attribute__((unused)) PointCloud2 & pointcloud_msg)
@@ -57,6 +61,8 @@ void SegmentPointCloudFusionNode::fuseOnSingleImage(
57
61
if (input_pointcloud_msg.data .empty ()) {
58
62
return ;
59
63
}
64
+ if (!checkCameraInfo (camera_info)) return ;
65
+
60
66
cv_bridge::CvImagePtr in_image_ptr;
61
67
try {
62
68
in_image_ptr = cv_bridge::toCvCopy (
@@ -65,10 +71,15 @@ void SegmentPointCloudFusionNode::fuseOnSingleImage(
65
71
RCLCPP_ERROR (this ->get_logger (), " cv_bridge exception:%s" , e.what ());
66
72
return ;
67
73
}
74
+ std::vector<uint8_t > mask_data (input_mask.data .begin (), input_mask.data .end ());
75
+ cv::Mat mask = perception_utils::runLengthDecoder (mask_data, input_mask.height , input_mask.width );
68
76
69
- cv::Mat mask = in_image_ptr->image ;
70
- if (mask.cols == 0 || mask.rows == 0 ) {
71
- return ;
77
+ // publish debug mask
78
+ if (is_publish_debug_mask_) {
79
+ sensor_msgs::msg::Image::SharedPtr debug_mask_msg =
80
+ cv_bridge::CvImage (std_msgs::msg::Header (), " mono8" , mask).toImageMsg ();
81
+ debug_mask_msg->header = input_mask.header ;
82
+ pub_debug_mask_ptr_.publish (debug_mask_msg);
72
83
}
73
84
const int orig_width = camera_info.width ;
74
85
const int orig_height = camera_info.height ;
0 commit comments