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

converting PointCloud2 to pcl::PointCloud is slow with RGB field

asked 2014-05-20 19:14:53 -0500

Ryohei Ueda gravatar image

I measured a time to convert sensor_msgs::PointCloud2, pcl::PointCloud and pcl::PCLPointCloud2 . https://github.com/garaemon/pcl_ros_c...

I found that converting from pcl::PCLPointCloud2 to pcl::PointCloud takes a long time when the input data had RGB field. Is there any way to speed up this conversion?

image description

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-05-20 23:32:14 -0500

My best guess is that when transforming from PCL2 to PCL you need to get rid of the RGB field.

If I am not mistaken, the representation in memory of the point cloud for PCL2 is something like:

[X0, Y0, Z0, RGB0, X1, Y1, Z1, RGB1, ... Xn, Yn, Zn, RGBn]

and for PCL is:

[X0, Y0, Z0, X1, Y1, Z1, ... Xn, Yn, Zn]

So the only way to transform from PCL2 to PCL is by iterating over the data on PCL2 and ignoring each 4th component (the RGB component) and this takes time, because you can not do a simple memcpy.

Inside the implementation of fromPCLPointCloud2 between lines 202 and 217 you will see what I mean.

edit flag offensive delete link more

Comments

Thanks! you are correct. When I use `pcl::PointXYZRGBA`, the conversion time decreases.

Ryohei Ueda gravatar image Ryohei Ueda  ( 2014-05-21 04:27:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-20 19:14:53 -0500

Seen: 1,321 times

Last updated: May 20 '14