ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

What you need it is solved in the depth_image_proc package

http://wiki.ros.org/depth_image_proc

What you need it is solved in the depth_image_proc package

http://wiki.ros.org/depth_image_proc

You have to use the node: point_cloud_xyz that takes as input a depth image and provides as output a point cloud.

What If you need it is solved to generate a sensor_msg/Image:

From what you say in your question you should use the depth_image_proc packagesensor_msgs::image_encodings::TYPE_64FC1.

However in your question also looks like you are using a matrix of byte (instead of a matrix of float) so then you would have to use the type sensor_msgs::image_encodings::TYPE_8UC1.

In any case you can check more of the possible types in: http://docs.ros.org/jade/api/sensor_msgs/html/namespacesensor__msgs_1_1image__encodings.html

#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>

cv_bridge::CvImage out_msg;
out_msg.header   = in_msg->header; // Same timestamp and tf frame as input image
out_msg.encoding = sensor_msgs::image_encodings::TYPE_64FC1; // Or whatever
out_msg.image    = sal_float_image; // Your cv::Mat

saliency_img_pub.publish(out_msg.toImageMsg());

If you need to generate the point cloud:

http://wiki.ros.org/depth_image_proc

You have to use the node: point_cloud_xyz that takes as input a depth image and provides as output a point cloud.