一、ply转pcd
import open3d as o3d
def convert_ply_to_pcd(ply_file, pcd_file):
# 读取 PLY 文件
pcd = o3d.io.read_point_cloud(ply_file)
# 保存为 PCD 文件
o3d.io.write_point_cloud(pcd_file, pcd)
if __name__ == "__main__":
# 替换为你的 PLY 文件路径和目标 PCD 文件路径
ply_file_path = "F:/24.10.181/1.ply"
pcd_file_path = "F:/24.10.181/1.pcd"
convert_ply_to_pcd(ply_file_path, pcd_file_path)
二、pcd转ply
import open3d as o3d
def pcd_to_ply(input_file, output_file):
# 读取 .pcd 文件
pcd = o3d.io.read_point_cloud(input_file)
# 将点云数据保存为 .ply 文件
o3d.io.write_point_cloud(output_file, pcd)
print(f"Successfully converted {input_file} to {output_file}")
# 使用函数
if __name__ == "__main__":
input_pcd = "F:/24.10.181/1.pcd"
output_ply = "F:/24.10.181/11.ply"
pcd_to_ply(input_pcd, output_ply)