Outputting mesh as .obj
martindisley opened this issue · comments
Martin Disley commented
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?
Cho-Ying Wu commented
Sorry for the late reply. Yes, you can do this.
prediction in this line is 3D points
Cross-Modal-Perceptionist/demo_mic.py
Line 139 in d105c07
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)