简体   繁体   中英

Convert point cloud from pointcloud2 (rosbag) to bin (KITTI)

How can I convert a point cloud saved in rosbag, in format sensor_msgs/PointCloud2, to.bin files in KITTI format?

I know that it is possible to convert to.pcd ( http://wiki.ros.org/pcl_ros#pointcloud_to_pcd ) so perhaps even a pcd to bin converter would be enough.

Is there any available tool to do this?

I've found this , but it needs ROS kinetic (legacy ROS version).

A python script to do it:

  pc = pypcd.PointCloud.from_msg(msg)
  x = pc.pc_data['x']
  y = pc.pc_data['y']
  z = pc.pc_data['z']
  intensity = pc.pc_data['intensity']
  arr = np.zeros(x.shape[0] + y.shape[0] + z.shape[0] + intensity.shape[0], dtype=np.float32)
  arr[::4] = x
  arr[1::4] = y
  arr[2::4] = z
  arr[3::4] = intensity
  arr.astype('float32').tofile('filename.bin')

Where x,y,z and intensity are arrays for a single point cloud. It's not strictly needed to use pypcd. ( Source )

Also this conversion tool can actually be used without ROS, using another tool for the conversion to pcd file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM