kornia.geometry.pointcloud#

kornia.geometry.pointcloud.save_pointcloud_ply(filename, pointcloud)[source]#

Save to disk a pointcloud in ASCII PLY format.

Convention:
  • The file holds one vertex per row of pointcloud.reshape(-1, 3), in order and with none dropped, and declares the properties x, y and z in that order as double. Each value is printed as the shortest text that parses back to the same float64, a non-finite one as nan / inf.

  • pointcloud is channels-last. Apply permute(0, 2, 3, 1) to a depth_to_3d() result or use depth_to_3d_v2(): a channels-first tensor whose width is 3 passes the shape check and is written scrambled.

  • The PLY writers and loaders take filename as a str or os.PathLike[str] ending in .ply (any case); another suffix raises TypeError.

Parameters:
  • filename (str | PathLike[str]) – path of the .ply file to write, a str or os.PathLike[str].

  • pointcloud (Tensor) – tensor of shape \((*, 3)\) with at least two dimensions, where the last dimension is the point \((X, Y, Z)\).

Return type:

None

kornia.geometry.pointcloud.load_pointcloud_ply(filename, header_size=None)[source]#

Load from disk a pointcloud in ASCII PLY format.

The header is parsed up to end_header; the number of points comes from the element vertex N declaration and the coordinates from the x, y and z properties, whatever other properties (normals, colours) or elements (faces) the file carries. A list property among the vertex properties is rejected, since it spans a variable number of tokens and would shift every column after it. See the Convention block on save_pointcloud_ply().

Parameters:
  • filename (str | PathLike[str]) – path of an existing .ply file, a str or os.PathLike[str].

  • header_size (Optional[int], optional) – deprecated and ignored; the header is parsed instead of skipped. Default: None

Return type:

Tensor

Returns:

tensor containing the loaded points with shape \((N, 3)\) in float32, where \(N\) is the declared vertex count.

kornia.geometry.pointcloud.save_pointcloud_ply_binary(filename, pointcloud)[source]#

Save to disk a pointcloud in binary PLY format.

See the Convention block on save_pointcloud_ply(); the payload is little-endian float64.

Parameters:
  • filename (str | PathLike[str]) – path of the .ply file to write, a str or os.PathLike[str].

  • pointcloud (Tensor) – tensor of shape \((*, 3)\) with at least two dimensions, where the last dimension is the point \((X, Y, Z)\).

Return type:

None

kornia.geometry.pointcloud.load_pointcloud_ply_binary(filename, header_size=None)[source]#

Load from disk a pointcloud in binary PLY format.

The header is parsed up to end_header; the number of points comes from the element vertex N declaration and the coordinates from the x, y and z properties, whatever their scalar type. Extra vertex properties (normals, colours) are skipped, and so are elements that follow the vertices (faces). Both little- and big-endian payloads are read. A list property is only supported in elements that follow the vertices. Among the vertex properties, or in an element that precedes them, its byte length is unknown without parsing it, so such a file is rejected. See the Convention block on save_pointcloud_ply().

Parameters:
  • filename (str | PathLike[str]) – path of an existing .ply file, a str or os.PathLike[str].

  • header_size (Optional[int], optional) – deprecated and ignored; the header is parsed instead of skipped. Default: None

Return type:

Tensor

Returns:

tensor containing the loaded points with shape \((N, 3)\) in float32, where \(N\) is the declared vertex count.