想在点云上做一些标识,发现画直线比较方便,下面是我画了一个三角形。可以根据自己的情况改变坐标画出不同的形状
pcd.translate(np.array([0,0,20]))
points = np.asarray(pcd.points)
centroid = points.mean(axis=0)
x1 = length1[1]
y1 = centroid[1]
z1 = centroid[2]+2x2 = length1[2]
y2 = centroid[1]
z2 = centroid[2]+2logger.debug(f"断面坐标 x1= {x1} y1= {y1} z1= {z1} X2= {x2} y2= {y2} z2= {z2} " )
#triangle_points = np.array([[2,0,0,],[0,2,0],[0,2,4]],dtype=np.float32)
triangle_points = np.array([[x1,y1,z1],[x2,y2,z2],[0,2,140]],dtype=np.float32)
lines =[[0,1],[1,2],[2,0]]
colors = np.array([[np.random.uniform(), np.random.uniform(), np.random.uniform()] for j in range(len(lines))])
print(colors)
line_set = o3d.geometry.LineSet()
line_set.lines = o3d.utility.Vector2iVector(lines)
line_set.colors = o3d.utility.Vector3dVector(colors)
line_set.points = o3d.utility.Vector3dVector(triangle_points)if(isShowForm):o3d.visualization.draw_geometries([line_set],window_name="zhixian")
下图是我在点云上画出来的三角形直线的效果