Convert filtered PointCloud2 to Image
Hi everyone,
I'm looking for a way to convert a filtered PointCloud2 from an RGBD camera (i.e. background removed, limited range etc.) back to an image as it might have be seen by the camera. The points that have been removed shall be black in the resulting image. I know that I need the camera_info and the exact pose of the camera for this purpose. I do of course have both.
Is there already a node or (even better) nodelet that can do that?
Thanks a lot
update 1:
I've tried to use convert_pointcloud_to_image
and it does not work as expected. I feed in a filtered point cloud (passthrough filter, z reduced). In the visualization it's clearly visible that the background is cut away. The reconstructed image however still contains the pixels even though they are removed from the point cloud. The passthrough filter got the parameter keep_organized = true
. Otherwise the resulting point cloud would be unorganized and thus unsuitable for convert_pointcloud_to_image
which requires an organized point cloud. convert_pointcloud_to_image
internally does nothing more than calling pcl::toROSMsg which itself just memcpy
the points from the PCL one after another into a ROS sensor_msgs/Image message. I'm fine with that and it should work as expected... but doesn't. I don't know where it gets the pixel data from even when fed a filtered PCL.
update 2:
Sorry, I haven't been clear enough about what kind of image I want to get out. The mention of camera_info
was a bit misleading. I'm fine with a rectified image! It does not have to be distorted! I don't remember why I mentioned camera_info
in the first place.