Replies: 4 comments 9 replies
-
Hi! You can use the Python bindings to get just the vertices of the mesh (without adjacency data) and then use a Python .ply module to export that. Cheers! |
Beta Was this translation helpful? Give feedback.
-
I found this method for getting vertices: import numpy as np
args = np.array([testbed.aabb.min,testbed.aabb.max])
testbed.aabb.get_vertices(args) but I receive this error:
|
Beta Was this translation helpful? Give feedback.
-
@bonfry i got it working
import pyngp as ngp
import numpy as np
from plyfile import PlyData, PlyElement
mode = ngp.TestbedMode.Nerf
testbed = ngp.Testbed(mode)
testbed.load_snapshot("../data/room_dslr/base.msgpack")
mc = testbed.compute_marching_cubes_mesh()
vertex = np.array(list(zip(*mc["V"].T)), dtype=[('x', 'f4'), ('y', 'f4'), ('z', 'f4')])
vertex_color = np.array(list(zip(*((mc["C"] * 255).T))), dtype=[('red', 'u1'), ('green', 'u1'), ('blue', 'u1')])
n = len(vertex)
assert len(vertex_color) == n
vertex_all = np.empty(n, vertex.dtype.descr + vertex_color.dtype.descr)
for prop in vertex.dtype.names:
vertex_all[prop] = vertex[prop]
for prop in vertex_color.dtype.names:
vertex_all[prop] = vertex_color[prop]
ply = PlyData([PlyElement.describe(vertex_all, 'vertex')], text=False)
ply.write('nerf_pc.ply') now you can open it with something like |
Beta Was this translation helpful? Give feedback.
-
Update: the resolution can be computed like this def round_up_to_base(x, base=10):
return x + (base - x) % base
def get_marching_cubes_res(res_1d: int, aabb: ngp.BoundingBox ) -> np.ndarray:
scale = res_1d / (aabb.max - aabb.min).max()
res3d = (aabb.max - aabb.min) * scale + 0.5
res3d = round_up_to_base(res3d.astype(np.int32), 16)
return res3d
mc = testbed.compute_marching_cubes_mesh(resolution=get_marching_cubes_res(512, testbed.aabb), aabb=testbed.aabb, thresh=2) |
Beta Was this translation helpful? Give feedback.
-
Hey,
Is there any possibility of adding .ply point cloud export of the NeRF as it is shown in the viewport, without meshing?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions