MCPcopy Create free account
hub / github.com/dcharatan/flowmap / write_ply

Function write_ply

flowmap/export/colmap.py:30–53  ·  view source on GitHub ↗
(
    path: Path,
    xyz: Float[np.ndarray, "point 3"],
    rgb: Float[np.ndarray, "point 3"],
)

Source from the content-addressed store, hash-verified

28
29
30def write_ply(
31 path: Path,
32 xyz: Float[np.ndarray, "point 3"],
33 rgb: Float[np.ndarray, "point 3"],
34) -> None:
35 # Adapted from https://github.com/graphdeco-inria/gaussian-splatting/blob/2eee0e26d2d5fd00ec462df47752223952f6bf4e/scene/dataset_readers.py#L115
36 dtype = [
37 ("x", "f4"),
38 ("y", "f4"),
39 ("z", "f4"),
40 ("nx", "f4"),
41 ("ny", "f4"),
42 ("nz", "f4"),
43 ("red", "u1"),
44 ("green", "u1"),
45 ("blue", "u1"),
46 ]
47 normals = np.zeros_like(xyz)
48 elements = np.empty(xyz.shape[0], dtype=dtype)
49 attributes = np.concatenate((xyz, normals, rgb * 255), axis=1)
50 elements[:] = list(map(tuple, attributes))
51 vertex_element = PlyElement.describe(elements, "vertex")
52 ply_data = PlyData([vertex_element])
53 ply_data.write(path)
54
55
56def export_to_colmap(

Callers 1

export_to_colmapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected