Deep3DFaceReconstruction icon indicating copy to clipboard operation
Deep3DFaceReconstruction copied to clipboard

How to get UV texture?

Open heury opened this issue 4 years ago • 0 comments

I modified BFM_UV.mat using select_vertex_id.mat and save it as "BFM_UV_mod.mat" I tried to get UV map using following source code, but I got black image. This source code come from face3d - https://github.com/YadiraF/face3d/blob/master/examples/7_generate_uv_map.py I guess I made mistake in colors variable. Would you guide me how to get UV texture map? I attached source code and BFM_UV_mod.mat file

gentexture.zip

# --load mesh data
C = sio.loadmat('output/000002.mat')

triangles = C['face_shape']
colors = C['face_texture']
colors = colors/np.max(colors)
# --load uv coords
uv_coords = face3d.morphable_model.load.load_uv_coords('BFM_UV_mod.mat') 
uv_h = uv_w = 256
image_h = image_w = 256
uv_coords = process_uv(uv_coords, uv_h, uv_w)

#-- 1. uv texture map
attribute = colors
uv_texture_map = mesh.render.render_colors(uv_coords, triangles, attribute, uv_h, uv_w, c=3)
io.imsave('{}/uv_texture_map.jpg'.format(save_folder), np.squeeze(uv_texture_map))

heury avatar Apr 08 '21 04:04 heury