Created
February 16, 2019 11:42
-
-
Save walsvid/62d496b90170dddd0c1b1fc8dbfddd86 to your computer and use it in GitHub Desktop.
3DR2N2 voxel to Mesh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from skimage import measure | |
vox = np.load('prediction.npy') | |
vox2 = np.pad(vox, ((1,1),(1,1),(1,1)),'constant', constant_values=0) | |
verts, faces, normals, values = measure.marching_cubes_lewiner(vox2, 0.0) | |
with open('3d.obj','w') as d: | |
for v in verts: | |
d.write('v {} {} {}\n'.format(v[0],v[1],v[2])) | |
for f in faces: | |
d.write('f {} {} {}\n'.format(f[0]+1,f[1]+1,f[2]+1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment