好友
阅读权限 10
听众
最后登录 1970-1-1
[Python] 纯文本查看 复制代码
import open3d as o3d
# 加载点云数据
pcd = o3d.io.read_point_cloud("bunny.pcd")
# 对点云进行下采样和去噪
pcd_downsampled = pcd.voxel_down_sample(voxel_size=0.05)
pcd_denoised = pcd_downsampled.remove_statistical_outlier(nb_neighbors=20, std_ratio=2.0)
# print(pcd_denoised)
# 分割平面
plane_model, inliers =pcd_denoised.segment_plane(distance_threshold=0.1, ransac_n=3, num_iterations=1000)
plane_cloud = pcd_denoised.select_by_index(inliers)
# 分段圆柱体
cylinder_model, inliers = plane_cloud.segment_cylinder(radius=0.1, height=0.5)
cylinder_cloud = plane_cloud.select_by_index(inliers)
# 将结果可视化
o3d.visualization.draw_geometries([plane_cloud, cylinder_cloud])
报错提示
File "E:/pycharm/pythonproject/点云语义分割/分割圆柱案例2.py", line 9, in <module>
pcd_denoised.segment_plane(distance_threshold=0.1, ransac_n=3, num_iterations=1000)
AttributeError: 'tuple' object has no attribute 'segment_plane'
运行结果
发帖前要善用【论坛搜索 】 功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。