Open3d入门 不同点云数据格式转换

点云数据之间的格式转换是将点云数据从一种文件格式转换为另一种文件格式的过程。点云数据通常用于表示物体表面的三维点的集合,这些数据在计算机图形学、计算机视觉、3D建模等领域有广泛应用。常见的点云文件格式包括PLY、PCD、BIN、TXT、OBJ等。接下来将介绍不同点云格式之间的转换方法。

PLY转其他格式

PLY转PCD

图片

我们以斯坦福三维扫描数据库中的bunny.ply为例进行介绍,首先是在网上获取该数据并将其保存到同级目录中。

import os
import urllib.request
import tarfile
import open3d as o3d
import shutil

# 下载并解压Stanford Bunny数据集
url = "http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz"
download_path = "bunny.tar.gz"
extract_folder = "bunny"
target_ply_file = "bunny.ply"

# 下载数据集
if not os.path.exists(download_path):
    print("Downloading Stanford Bunny dataset...")
    urllib.request.urlretrieve(url, download_path)
    print("Download complete.")

# 解压数据集
if not os.path.exists(extract_folder):
    print("Extracting Stanford Bunny dataset...")
    with tarfile.open(download_path, "r:gz") as tar:
        tar.extractall(path=extract_folder)
    print("Extraction complete.")

# 查找点云文件
point_cloud_file = None
for root, dirs, files in os.walk(extract_folder):
    for file in files:
        if file.endswith(".ply"):
            point_cloud_file = os.path.join(root, file)
            break

if point_cloud_file:
    print(f"Point cloud file found: {point_cloud
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值