Skip to content

point_cloud

point_cloud #

The point-cloud file scalar; a loaded PointCloud is the file path.

It carries a cloud.point_count() reader that parses self. A point cloud is a non-core extension scalar (dotted reverse-DNS name), so its schema self-describes with kind + extensions and a reader without a PLY decoder can still store or skip the bytes. The format is PLY (Polygon File Format): each vertex carries x/y/z in metres and may carry red/green/blue colour and a confidence quality channel — a loaded value is the standard .ply path, ready for Open3D, trimesh, or MeshLab.

PointCloud #

Bases: FileScalar

A 3D point cloud as a PLY file; a loaded value is its file Path.

Source code in capturegraph-lib/capturegraph/types/scalars/geometry/point_cloud.py
class PointCloud(FileScalar, name="edu.cornell.point_cloud", extensions=("ply",)):
    """A 3D point cloud as a PLY file; a loaded value is its file ``Path``."""

    __slots__ = ()

    def point_count(self) -> int:
        """The number of vertices, read from the PLY header (no decode of the body).

        Raises:
            ValueError: If the header declares no vertex element.
        """
        with open(self, "rb") as handle:
            for raw in handle:
                line = raw.decode("ascii", "replace").strip()
                if line.startswith("element vertex"):
                    return int(line.split()[-1])
                if line == "end_header":
                    break
        raise ValueError(f"{self}: PLY header declares no 'element vertex'")

point_count() #

The number of vertices, read from the PLY header (no decode of the body).

Raises:

Type Description
ValueError

If the header declares no vertex element.

Source code in capturegraph-lib/capturegraph/types/scalars/geometry/point_cloud.py
def point_count(self) -> int:
    """The number of vertices, read from the PLY header (no decode of the body).

    Raises:
        ValueError: If the header declares no vertex element.
    """
    with open(self, "rb") as handle:
        for raw in handle:
            line = raw.decode("ascii", "replace").strip()
            if line.startswith("element vertex"):
                return int(line.split()[-1])
            if line == "end_header":
                break
    raise ValueError(f"{self}: PLY header declares no 'element vertex'")