ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# How to combine a camera image and a laser pointcloud to create a color pointcloud?

Hey all,

I have a point cloud from my laser LMS100 and an Image from a camera both can be transformed to the same tf. How can I combine both image and a laser point cloud to create a colourful point cloud.

edit retag close merge delete

Sort by ยป oldest newest most voted

Yes, it is very much possible to combine DEPTH data from laser and RGB data from image to form a rgbd/color pointcloud using pcl library.

I hope you can define a x and y correspondence between each voxel of laser pointcloud and pixel from the image using tf. Given that laser pointcloud size and image size are same in x,y direction ..like in case of kinect it is 640X480. While writing the combined pointcloud, use PointXYZRGB structure Following is a small example code:

  pcl::PointCloud<pcl::PointXYZRGB> cloud;
uint8_t r = 255, g = 0, b = 0;    // Example: Red color
uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b);
cloud.points[0].rgb = *reinterpret_cast<float*>(&rgb);


About how to write a simple pcd file, you can find it here

more

Thanks for the quick reply. How can I correspond between the laser and the camera. I believe I need to calibrate them. Is there any instructions for such calibration?

( 2013-11-11 11:04:07 -0600 )edit

There are no such standard instructions available to calibrate as far as I know. I can explain how I would do such task: Suppose i have image of size 640X480 and laser pointcloud of the same size in xy direction, (min. Requirement). It is same in kinect data. . . The depth pointcloud is available as a matrix of dimension [cloud.SIZE()] x 1. i.e. height is 1 and length is equal to the total no. of points. . . . Through manual matrix handling (converting the pointcloud matrix to 640X480 matrix) I can trace the XYZ values from laser pointcloud and RGB values from image to the output color pointcloud of format PointXYZRGB.

( 2013-11-11 11:59:36 -0600 )edit

@sudhanshu_mittal: Could you elaborate on this "Through manual matrix handling (converting the pointcloud matrix to 640X480 matrix)". From the depth pcd I have the cartesian coordinates (say 260 x-y points). What values would the 640x480 matrix elements have?

( 2015-05-21 14:56:01 -0600 )edit

I am looking into doing something similar. Except I am using Velodyne VLP16 LiDAR. The laser point cloud and the image have different sizes. Do you have any pointers on how to calibration camera and LiDAR in such setup?

( 2016-07-12 19:20:35 -0600 )edit