paralleldomain.model.annotation.surface_normals_3d¶
- class SurfaceNormals3D(normals)¶
Represents a mask of surface normals for a point cloud.
- Parameters:
normals (
ndarray
) –SurfaceNormals3D.normals
- normals¶
Matrix of shape (N x 3), where N is the number of points of the corresponding point cloud. The second axis contains the x, y and z normal direction of the surface the corresponding point was sampled from.
Example
Using the Surface Normal mask in combination with
PointCloud.xyz
to visualize the normals of each point:>>> lidar_frame: LidarSensorFrame = ... # get any lidar's SensorFrame >>> >>> sur_normals = lidar_frame.get_annotations(AnnotationTypes.SurfaceNormals3D) >>> xyz = lidar_frame.point_cloud.xyz >>> normal_points = xyz + sur_normals.normals >>> normal_line_points = np.concatenate([xyz, normal_points], axis=-1).reshape((2 * len(xyz), 3)) >>> line_connections = np.arange(2 * len(xyz)).reshape((-1, 2)) >>> >>> import open3d as o3d >>> pcd = o3d.geometry.PointCloud() >>> pcd.points = o3d.utility.Vector3dVector(xyz) >>> >>> colors = [[1, 0, 0] for i in range(len(line_connections))] >>> line_set = o3d.geometry.LineSet( >>> points=o3d.utility.Vector3dVector(normal_line_points), >>> lines=o3d.utility.Vector2iVector(line_connections), >>> ) >>> line_set.colors = o3d.utility.Vector3dVector(colors) >>> >>> o3d.visualization.draw_geometries([pcd, line_set])