Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save preditcion on .obj / .fbx formats #2

Closed
oljikeboost opened this issue Jan 21, 2022 · 2 comments
Closed

Save preditcion on .obj / .fbx formats #2

oljikeboost opened this issue Jan 21, 2022 · 2 comments

Comments

@oljikeboost
Copy link

Hi! Thanks for your work. How can I save the output prediction of the body on .obj / .fbx formats?

@akashsengupta1997
Copy link
Owner

Hi, the output vertex mesh can be saved as a .obj file using the following short function:

def save_mesh_as_obj(out_path, vertices, faces):
    """
    Saves vertex mesh as obj file.
    :param out_path: path to save obj file.
    :param vertices: (num vertices, 3) numpy array of 3D vertices
    :param faces: (num faces, 3) numpy array, each row contains ordered
    indices of vertices belonging to that face.
    """
    with open(out_path, 'w') as fp:
        for v in vertices:
            fp.write('v %f %f %f\n' % (v[0], v[1], v[2]))
        if not(faces is None):
            for f in faces + 1:
                fp.write('f %d %d %d\n' % (f[0], f[1], f[2]))

or you can use trimesh's export function - see details here https://files.is.tue.mpg.de/black/talks/SMPL-made-simple-FAQs.pdf

You may also consider saving the mesh in the .ply file format, since you can additionally save per-vertex variance as a per-vertex property (or "colour" using some colour map), if this is desired. (I guess this is possible with .obj too, but I am not super knowledgeable about this).

@AhmadNashaat0
Copy link

how to extract faces and vertices from smpl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants