[英]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?如何将保存在 rosbag 中的点云以 sensor_msgs/PointCloud2 格式转换为 KITTI 格式的.bin 文件?
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.我知道可以转换为 .pcd ( http://wiki.ros.org/pcl_ros#pointcloud_to_pcd )所以也许即使是 pcd 到 bin 转换器就足够了。
Is there any available tool to do this?有没有可用的工具来做到这一点?
I've found this , but it needs ROS kinetic (legacy ROS version).我找到了这个,但它需要 ROS 动力学(旧版 ROS 版本)。
A python script to do it:执行此操作的 python 脚本:
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.其中 x,y,z 和强度是 arrays 对于单个点云。 It's not strictly needed to use pypcd.并非严格需要使用 pypcd。 ( Source ) (来源)
Also this conversion tool can actually be used without ROS, using another tool for the conversion to pcd file.此外,这个转换工具实际上可以在没有 ROS 的情况下使用,使用另一个工具转换为 pcd 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.