写在前面
-
本文内容
计算点到平面的距离 -
平台/环境
python open3d -
转载请注明出处:
https://blog.csdn.net/qq_41102371/article/details/121482246
目录
- 写在前面
- 准备Open3D
- 代码
- 完
准备Open3D
pip install open3d
代码
import open3d as o3ddef compute_points2plane_distance(pcd, plane_model):a, b, c, d = plane_modelpoints = np.asarray(pcd.points)distance = np.abs(a * points[:, 0] + b * points[:, 1] + c * points[:, 2] + d) / np.sqrt(a**2 + b**2 + c**2)return distanceif __name__ == "__main__":pcd = o3d.io.read_point_cloud("xxx.ply")plane_model = [0,0,1,0]# z=0的平面# 或者通过平面拟合得到一个平面参数# plane_model, inliers = pcd.segment_plane(# distance_threshold=0.001, ransac_n=3, num_iterations=100# )distance = compute_points2plane_distance(pcd,[0,0,1,0])
完
主要做激光/影像三维重建,配准、分割等常用点云算法,熟悉open3d、pcl等开源点云库,技术交流、咨询可私信