Skip to content

cloud

cloud #

cloud — a seed as a PointCloud: per-frame positions and colours, thinned to one size.

cloud(message, positions, colors) #

The thinned cloud of positions and colors, its point count logged as message.

Source code in capturegraph-recipes/capturegraph_recipes/splats/seeds/cloud.py
def cloud(message: str, positions: list[np.ndarray], colors: list[np.ndarray]) -> cg.PointCloud:
    """The thinned cloud of ``positions`` and ``colors``, its point count logged as ``message``."""
    if positions:
        points, shades = thinned(np.concatenate(positions), np.concatenate(colors))
    else:
        points, shades = np.zeros((0, 3), np.float32), np.zeros((0, 3), np.uint8)
    cg.logging.info(message, points=len(points))
    return cg.PointCloud.of_points(points, shades)

frame_colors(frame, width, height) #

frame's image as an RGB array at width by height, one colour per pixel.

Source code in capturegraph-recipes/capturegraph_recipes/splats/seeds/cloud.py
def frame_colors(frame: PosedImage, width: int, height: int) -> np.ndarray:
    """``frame``'s image as an RGB array at ``width`` by ``height``, one colour per pixel."""
    return np.asarray(frame.image.pil().convert("RGB").resize((width, height)))

thinned(positions, colors) #

positions and colors evenly thinned to at most MAX_POINTS.

Source code in capturegraph-recipes/capturegraph_recipes/splats/seeds/cloud.py
def thinned(positions: np.ndarray, colors: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
    """``positions`` and ``colors`` evenly thinned to at most ``MAX_POINTS``."""
    if len(positions) <= MAX_POINTS:
        return positions, colors
    keep = np.linspace(0, len(positions) - 1, MAX_POINTS).astype(np.int64)
    return positions[keep], colors[keep]