Download data_tool/pcd_process.py from vegagoto123/gha: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/vegagoto123/gha/resolve/main/data_tool/pcd_process.py
- Command line
-
hf download hf://vegagoto123/gha/data_tool/pcd_process.py
-
curl -L -o pcd_process.py https://huggingface.co/vegagoto123/gha/resolve/main/data_tool/pcd_process.py
2.07 kB
| # import open3d as o3d | |
| # # 加载点云数据 | |
| # pcd = o3d.io.read_point_cloud("/data_160TB/2021/yangkun/gaussian-splatting-main-copy/eg3d_human/train/person_0/point_cloud/iteration_12000/point_cloud.ply") | |
| # # 基于统计距离滤波 | |
| # # cl, ind = pcd.remove_statistical_outlier(nb_neighbors=20, std_ratio=2.0) | |
| # # 设置体素的大小 | |
| # voxel_size = 0.01 | |
| # # 进行体素化 | |
| # voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd, voxel_size) | |
| # # 可视化滤波后的点云 | |
| # # inlier_cloud = pcd.select_by_index(ind) | |
| # # o3d.visualization.draw_geometries([inlier_cloud]) | |
| # # 保存滤波后的点云为PLY格式 | |
| # o3d.io.write_point_cloud("/data_160TB/2021/yangkun/gaussian-splatting-main-copy/eg3d_human/train/person_0/point_cloud/iteration_12000/point_cloud0.ply", voxel_grid) | |
| import open3d as o3d | |
| # 加载点云数据 | |
| point_cloud = o3d.io.read_point_cloud("/data_160TB/2021/yangkun/gaussian-splatting-main-copy/eg3d_human/train/person_0/point_cloud/iteration_12000/point_cloud.ply") | |
| # 将点云数据转换为 CPU 模式 | |
| point_cloud_cpu = point_cloud.to_legacy_pointcloud() | |
| # 计算法向量 | |
| point_cloud_cpu.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.1, max_nn=30)) | |
| # 获取法向量和曲率 | |
| normals = point_cloud_cpu.normals | |
| curvatures = point_cloud_cpu.compute_curvature() | |
| # 设置曲率阈值 | |
| curvature_threshold = 0.05 # 根据具体情况调整阈值 | |
| # 根据曲率进行剔除 | |
| filtered_points = [] | |
| for i in range(len(point_cloud_cpu.points)): | |
| if curvatures[i] < curvature_threshold: | |
| filtered_points.append(point_cloud_cpu.points[i]) | |
| # 创建剔除后的点云 | |
| filtered_point_cloud = o3d.geometry.PointCloud() | |
| filtered_point_cloud.points = o3d.utility.Vector3dVector(filtered_points) | |
| # 保存稠密化后的点云为PLY文件 | |
| o3d.io.write_point_cloud("/data_160TB/2021/yangkun/gaussian-splatting-main-copy/eg3d_human/train/person_0/point_cloud/iteration_12000/point_cloud0.ply", filtered_point_cloud) | |
| print("Point cloud densification completed and saved as output_dense_point_cloud.ply") |