Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In response to @disha 's request, I am sharing my insight to solve such problem\, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the rgb and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

What I got stuck is the fact that there is a lack of texts to back up how to convert PointCloudXYZRGB into cv::Mat depth image.

Another alternative that I tried (in vain) is to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out on how sensor_msgs::Image store depth information and how to convert it from sensor::msgs::PointCloud2 to the depth image, which involves transforming from 32-bit floating point depth to mono8 integer encoding pixels, this solution could be the way to go. What I did in this regard was to reverse-engineer depth_image_proc and pcl::toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image) but so far haven't work out the last part of conversion, but may serve as the launch pad if someone else what to give another try.

Reference: [1] c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow (https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] Converting OpenCV images to ROS image messages (http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

In response to @disha 's request, I am sharing my insight to solve such problem\, problem, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the rgb RGB and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

What I got stuck is the fact that there is a lack of texts to back up how to convert a proper conversion from PointCloudXYZRGB into to cv::Mat depth image.

Another alternative that I tried (in vain) is was to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out on how sensor_msgs::Image store depth information and how to convert it from sensor::msgs::PointCloud2 to the depth image, which involves transforming from 32-bit floating point depth to mono8 integer encoding pixels, this solution could be the way to go. What I did in this regard was to reverse-engineer depth_image_proc and pcl::toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image) [pcl::toROSMsg but so far haven't work sorted out the last part of conversion, conversion but may serve as the launch pad a hint if someone else what wants to give another it a try.

Reference: Reference:

[1] c++ [c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow (https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)Overflow](https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] Converting [Converting OpenCV images to ROS image messages (http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

messages](http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

In response to @disha 's request, I am sharing my insight to solve such problem, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the RGB and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

What I got stuck is the fact that there is a lack of texts to back up a proper conversion from PointCloudXYZRGB to cv::Mat depth image.

Another alternative that I tried (in vain) was to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out on how sensor_msgs::Image store depth information and how to convert it depth measurements from sensor::msgs::PointCloud2 to the depth image, depth images, which involves transforming depth values from 32-bit floating point depth to mono8 integer encoding intensity pixels, this solution could be the way to go.

What I did in this regard was to reverse-engineer depth_image_proc and [pcl::toROSMsg pcl::toROSMsg but so far haven't sorted out the last part of conversion but may serve as a hint if someone else wants to give it a try.

Reference:

[1] [c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow](https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] [Converting OpenCV images to ROS image messages](http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

In response to @disha 's request, I am sharing my insight to solve such problem, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the RGB and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

What I got stuck is the fact that there is a lack of texts to back up a proper conversion from PointCloudXYZRGB to cv::Mat depth image.

Another alternative that I tried (in vain) was to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out how sensor_msgs::Image store depth information and how to convert depth measurements from sensor::msgs::PointCloud2 to depth images, which involves transforming depth values from 32-bit floating point depth to mono8 integer encoding intensity pixels, this solution could be the way to go.

What I did in this regard was to reverse-engineer depth_image_proc and pcl::toROSMsg but so far haven't sorted out the last part of conversion but may serve as a hint if someone else wants to give it a try.

Reference:

[1] [c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow](https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] [Converting OpenCV images to ROS image messages](http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

In response to @disha 's request, I am sharing my insight to solve such problem, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the RGB and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

What I got stuck is the fact that there is a lack of texts to back up a proper conversion from PointCloudXYZRGB to cv::Mat depth image.

Another alternative that I tried (in vain) was to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out how sensor_msgs::Image store depth information and how to convert depth measurements from sensor::msgs::PointCloud2 to depth images, which involves transforming depth values from 32-bit floating point depth to mono8 integer encoding intensity pixels, this solution could be the way to go.

What Where I did in this regard was to reverse-engineer depth_image_proc and pcl::toROSMsg but so far haven't sorted out the last part of conversion but may serve as a hint if someone else wants to give it a try.

Reference:

[1] [c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow](https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] [Converting OpenCV images to ROS image messages](http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

In response to @disha 's request, I am sharing my insight to solve such problem, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the RGB and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

What Where I got stuck is the fact that there is a lack of texts to back up a proper conversion from PointCloudXYZRGB to cv::Mat depth image.

Another alternative that I tried (in vain) was to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out how sensor_msgs::Image store depth information and how to convert depth measurements from sensor::msgs::PointCloud2 to depth images, which involves transforming depth values from 32-bit floating point depth to mono8 integer encoding intensity pixels, this solution could be the way to go.

Where What I did in this regard was to reverse-engineer depth_image_proc and pcl::toROSMsg but so far haven't sorted out the last part of conversion but may serve as a hint if someone else wants to give it a try.

Reference:

[1] [c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow](https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] [Converting OpenCV images to ROS image messages](http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)

In response to @disha 's request, I am sharing my insight to solve such problem, since it is not a trivial one and there isn't much reference to be found on the internet. In order to pull the RGB and depth sensor_msgs::Image topics out of PCL Pointcloud, the conversion involves a two-fold process.

As per the depth image conversion from PCL's PointCloud, we need to first convert PCL pointcloud to cv::Mat for depth image. Please refer to REP 118 for depth image format. Notice that the row and height convention of both libraries are opposite to each other [1].

Then, once we have the depth values expressed in cv::Mat, convert the OpenCV format to sensor_msgs::Image using cv_bridge refering to [2].

Where I got stuck is the fact that there is a lack of texts to back up a proper conversion from PointCloudXYZRGB to cv::Mat depth image.

Another alternative that I tried (in vain) was to convert the PCL PointCloud to its sensor_msgs::PointCloud2 counterpart. Since we are working with depth image, pcl::toROSMsg could do little since it works with RGB channels instead of depth. If we could figure out how sensor_msgs::Image store depth information and how to convert depth measurements from sensor::msgs::PointCloud2 to depth images, which involves transforming depth values from 32-bit floating point depth to mono8 integer encoding intensity pixels, this solution could be the way to go.

What I did in this regard was to reverse-engineer depth_image_proc and pcl::toROSMsg but so far haven't sorted out the last part of conversion but may serve as a hint if someone else wants to give it a try.

So there you have it. Maybe the above insight is already suitable to solve your problem or at least serves as a launching pad to explore it even further. Thank you for asking and keep safe and healthy!

Reference:

[1] [c++ - pcl::Pointcloud to cv::Mat depth image - Stack Overflow](https://stackoverflow.com/questions/46717428/pclpointcloud-to-cvmat-depth-image)

[2] [Converting OpenCV images to ROS image messages](http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython#Converting_OpenCV_images_to_ROS_image_messages)