本文目录导读:

使用CloudCompare(推荐)
# 通过命令行批量转换 cloudcompare.CloudCompare -SILENT -O *.las -C_EXPORT_FMT PLY -SAVE_CLOUDS FILE
Python + laspy/pyntcloud
import laspy
import numpy as np
import open3d as o3d
from pathlib import Path
def batch_convert_pointclouds(input_dir, output_dir, input_format='.las', output_format='.ply'):
"""批量转换点云格式"""
input_dir = Path(input_dir)
output_dir = Path(output_dir)
output_dir.mkdir(exist_ok=True)
# 获取所有输入文件
files = list(input_dir.glob(f'*{input_format}'))
for file in files:
# 读取点云
if input_format in ['.las', '.laz']:
las = laspy.read(file)
points = np.vstack((las.x, las.y, las.z)).T
colors = np.vstack((las.red, las.green, las.blue)).T / 65535.0
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
if colors.any():
pcd.colors = o3d.utility.Vector3dVector(colors)
else:
pcd = o3d.io.read_point_cloud(str(file))
# 保存为新格式
output_file = output_dir / f"{file.stem}{output_format}"
o3d.io.write_point_cloud(str(output_file), pcd)
print(f"Converted: {file.name} -> {output_file.name}")
# 使用示例
batch_convert_pointclouds("input_folder", "output_folder", ".las", ".ply")
使用PDAL(专业点云处理库)
import pdal
import json
from pathlib import Path
def batch_convert_pdal(input_dir, output_dir):
"""使用PDAL批量转换点云"""
input_files = list(Path(input_dir).glob('*.las'))
for las_file in input_files:
output_file = Path(output_dir) / f"{las_file.stem}.ply"
# 创建PDAL pipeline
pipeline_json = {
"pipeline": [
str(las_file),
{
"type": "writers.ply",
"filename": str(output_file)
}
]
}
# 执行转换
pipeline = pdal.Pipeline(json.dumps(pipeline_json))
pipeline.execute()
print(f"Converted: {las_file.name}")
# 常用格式转换
# las/ laz -> ply
# las/ laz -> txt/csv
# las/ laz -> xyz
使用LASTools命令行工具
# 批量转换LAS到PLY
for file in *.las; do
las2txt -i "$file" -o "${file%.las}.ply"
done
# 或使用las2las转换格式
las2las -i *.las -o output_directory -target_ply
综合转换脚本(支持多种格式)
import argparse
import glob
import os
import numpy as np
def convert_pointcloud_format(input_file, output_file, input_format, output_format):
"""转换单个点云文件"""
if input_format == 'las' and output_format == 'txt':
import laspy
las = laspy.read(input_file)
points = np.column_stack((las.x, las.y, las.z,
las.red, las.green, las.blue))
np.savetxt(output_file, points, fmt='%.6f %.6f %.6f %d %d %d')
elif input_format == 'txt' and output_format == 'las':
import laspy
data = np.loadtxt(input_file)
header = laspy.LasHeader(point_format=3, version="1.2")
las = laspy.LasData(header)
las.x = data[:, 0]
las.y = data[:, 1]
las.z = data[:, 2]
las.write(output_file)
# 添加更多格式转换...
def batch_converter(input_dir, output_dir, input_ext, output_ext):
"""批量转换主函数"""
os.makedirs(output_dir, exist_ok=True)
pattern = os.path.join(input_dir, f"*.{input_ext}")
for input_file in glob.glob(pattern):
basename = os.path.basename(input_file)
output_file = os.path.join(output_dir,
f"{os.path.splitext(basename)[0]}.{output_ext}")
convert_pointcloud_format(input_file, output_file, input_ext, output_ext)
print(f"Converted: {basename}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='批量转换点云格式')
parser.add_argument('--input_dir', required=True, help='输入目录')
parser.add_argument('--output_dir', required=True, help='输出目录')
parser.add_argument('--input_ext', default='las', help='输入格式')
parser.add_argument('--output_ext', default='ply', help='输出格式')
args = parser.parse_args()
batch_converter(args.input_dir, args.output_dir,
args.input_ext, args.output_ext)
支持的常见格式转换
- .las/.laz → .ply, .txt, .xyz, .pcd
- .ply → .las, .txt, .xyz
- .pcd → .ply, .las, .txt
- .xyz → .las, .ply, .pcd
选择哪种方法取决于您的具体需求:
- CloudCompare:最适合可视化验证
- PDAL:最专业的点云处理
- Open3D:最适合Python集成
- LASTools:最快速的批量处理
版权声明:NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
足球直播
足球直播
足球直播
篮球直播
篮球直播
篮球直播
NBA直播
NBA直播
NBA直播
CBA直播
CBA直播
CBA直播
亚冠直播
亚冠直播
亚冠直播
欧冠直播
欧冠直播
欧冠直播
英超直播
英超直播
英超直播
西甲直播
西甲直播
西甲直播
中超直播
中超直播
中超直播
足球直播
足球直播
足球直播
篮球直播
篮球直播
篮球直播
NBA直播
NBA直播
NBA直播
CBA直播
CBA直播
CBA直播
亚冠直播
亚冠直播
亚冠直播
欧冠直播
欧冠直播
欧冠直播
英超直播
英超直播
英超直播
西甲直播
西甲直播
西甲直播
中超直播
中超直播
中超直播
足球直播
足球直播
足球直播
篮球直播
篮球直播
篮球直播
NBA直播
NBA直播
NBA直播
CBA直播
CBA直播
CBA直播
亚冠直播
亚冠直播
亚冠直播
欧冠直播
欧冠直播
欧冠直播
英超直播
英超直播
英超直播
西甲直播
西甲直播
西甲直播
中超直播
中超直播
中超直播
足球直播
足球直播
足球直播
篮球直播
篮球直播
篮球直播
NBA直播
NBA直播
NBA直播
CBA直播
CBA直播
CBA直播
亚冠直播
亚冠直播
亚冠直播
欧冠直播
欧冠直播
欧冠直播
英超直播
英超直播
英超直播
西甲直播
西甲直播
西甲直播
中超直播
中超直播
中超直播
曼联直播
曼联直播
曼联直播
日职联直播
日职联直播
日职联直播
澳超直播
澳超直播
澳超直播
阿森纳直播
阿森纳直播
阿森纳直播
足球直播
足球直播
足球直播
NBA直播
NBA直播
NBA直播
曼联直播
曼联直播
曼联直播
日职联直播
日职联直播
日职联直播
澳超直播
澳超直播
澳超直播
阿森纳直播
阿森纳直播
阿森纳直播
足球直播
足球直播
足球直播
NBA直播
NBA直播
NBA直播
曼联直播
曼联直播
曼联直播
日职联直播
日职联直播
日职联直播
澳超直播
澳超直播
澳超直播
阿森纳直播
阿森纳直播
阿森纳直播
足球直播
足球直播
足球直播
NBA直播
NBA直播
NBA直播
曼联直播
曼联直播
曼联直播
日职联直播
日职联直播
日职联直播
澳超直播
澳超直播
澳超直播
阿森纳直播
阿森纳直播
阿森纳直播
足球直播
足球直播
足球直播
NBA直播
NBA直播
NBA直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
欧冠直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
足球直播
足球直播
足球直播
足球直播
足球直播
英超直播
英超直播
英超直播
英超直播
英超直播
篮球直播
篮球直播
篮球直播
篮球直播
篮球直播
CBA直播
CBA直播
CBA直播
CBA直播
CBA直播
中超直播
中超直播
中超直播
中超直播
中超直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
足球直播
足球直播
足球直播
足球直播
足球直播
英超直播
英超直播
英超直播
英超直播
英超直播
篮球直播
篮球直播
篮球直播
篮球直播
篮球直播
CBA直播
CBA直播
CBA直播
CBA直播
CBA直播
中超直播
中超直播
中超直播
中超直播
中超直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
NBA直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播
中超直播