akanazawa / hmr

Project page for End-to-end Recovery of Human Shape and Pose
Other
1.55k stars 395 forks source link

Save output 3D model. #26

Closed sree3333 closed 6 years ago

sree3333 commented 6 years ago

Hi Thanks for this brilliant Project. I am having issue with saving the 3D model from the project. Could you please tell me steps how to save the resulted 3D model.

Thanks

hejinying commented 6 years ago

save mesh

face_path = './src/tf_smpl/smpl_faces.npy'
faces = np.load(face_path)
obj_mesh_name = './test.obj'
with open(obj_mesh_name, 'w') as fp:
    for v in verts[0]:
        fp.write( 'v %f %f %f\n' % ( v[0], v[1], v[2]) )

    for f in faces: # Faces are 1-based, not 0-based in obj files
        fp.write( 'f %d %d %d\n' %  (f[0] + 1, f[1] + 1, f[2] + 1) )
akanazawa commented 6 years ago

Thanks for your interest! The command above works great, but another approach is to use packages like pymesh and its save mesh utilities, which will let you save in different file types.