choyingw / Cross-Modal-Perceptionist

CVPR 2022: Cross-Modal Perceptionist: Can Face Geometry be Gleaned from Voices?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Outputting mesh as .obj

martindisley opened this issue · comments

Hi,

I was wondering, since you reference [3DDFA-V2] if it's possible to output the mesh generated from demo_mic.py as an .obj file?

Sorry for the late reply. Yes, you can do this.

prediction in this line is 3D points

prediction = R @ prediction_fr + off

You can output mesh by writing out vertices (3D points) and triangles (connectivity, you can find this file in BFM of 3DDFA-V2 or my other work SynergyNet). Here is a pseudo code

def write_obj(obj_name, vertices, triangles):
    # write obj
    with open(obj_name, 'w') as f:
        # write vertices
        for i in range(vertices.shape[1]):
            s = 'v {} {} {}\n'.format(vertices[0, i], vertices[1, i], vertices[2, i])
            f.write(s)
        # write triangles
        for i in range(triangles.shape[1]):
            s = 'f {} {} {}\n'.format(triangles[0, i], triangles[1, i], triangles[2, i])
            f.write(s)