如何将 open3d 几何点云输出为 .pcd 文件?

How can I output the open3d geometry PointCloud as .pcd file?

我正在使用以下代码将激光雷达数据(.bin 格式)转换为 .pcd 格式

with open ("lidar_velodyne64.bin", "rb") as f:
    byte = f.read(size_float*4)
    while byte:
        x,y,z,intensity = struct.unpack("ffff", byte)
        list_pcd.append([x, y, z])
        byte = f.read(size_float*4)
np_pcd = np.asarray(list_pcd)
pcd = o3d.geometry.PointCloud()
v3d = o3d.utility.Vector3dVector
pcd.points = v3d(np_pcd)

并尝试将 'pcd' 输出为 .pcd 文件:

with open("pcd_output.pcd", "wb") as pcd2:
    pickle.dump(pcd,pcd2)

但是,我收到以下错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-cde8b419d929> in <module>
      1 with open("pcd_output.pcd", "wb") as pcd2:
----> 2     pickle.dump(pcd,pcd2)

TypeError: can't pickle open3d.open3d.geometry.PointCloud objects

如何将 open3d 几何点云输出为 .pcd 文件?

您是否尝试过默认的 open3d.io.write_point_cloud() 功能?

根据例子here,您可以如下使用:

import open3d as o3d
o3d.io.write_point_cloud("copy_of_fragment.pcd", pcd)