SarahWeiii / diso

Differentiable Iso-Surface Extraction Package (DISO)
Other
203 stars 15 forks source link

strange box when trying to convert tensoRF to mesh #6

Closed brabbitdousha closed 6 months ago

brabbitdousha commented 6 months ago

Hi, I tried to convert tensoRF to mesh using:

verts, faces = diffmc_worker(pytorch_3d_sdf_tensor - level, None)

    verts_numpy = verts.cpu().numpy()
    mesh_points = np.zeros_like(verts_numpy)
    mesh_points[:, 0] = bbox[0,0] + verts_numpy[:, 0] * (bbox[1,0] - bbox[0,0])
    mesh_points[:, 1] = bbox[0,1] + verts_numpy[:, 1] * (bbox[1,1] - bbox[0,1])
    mesh_points[:, 2] = bbox[0,2] + verts_numpy[:, 2] * (bbox[1,2] - bbox[0,2])

    # try writing to the obj file
    mesh = trimesh.Trimesh(vertices=mesh_points, faces=faces.cpu().numpy(), process=False)
    print("saving mesh to %s" % (ply_filename_out))
    mesh.export(ply_filename_out)

However, I get strange result like a lego inside a box: image is there any modification I need inorder to make it right?

SarahWeiii commented 6 months ago

Hi this is because in my definition, the level set values > 0 are defined as outside and values < 0 are defined as inside. You can flip the TensoRF density values to fix the problem.

brabbitdousha commented 6 months ago

That helps, thanks