MCPcopy Create free account
hub / github.com/Pixel-Talk/EHM-Tracker / extract_texture

Method extract_texture

src/modules/pixie/visualizer.py:158–174  ·  view source on GitHub ↗

extract face texture from given cropped face image

(self, opdict, images)

Source from the content-addressed store, hash-verified

156 opdict['texture'] = uv_texture
157
158 def extract_texture(self, opdict, images):
159 '''extract face texture from given cropped face image
160 '''
161 if 'texture' not in opdict.keys():
162 self.light_albedo(opdict)
163 uv_texture = opdict['texture']
164 trans_verts = opdict['transformed_vertices']
165 uv_pverts = self.render.world2uv(trans_verts)
166 uv_gt = F.grid_sample(images, uv_pverts.permute(
167 0, 2, 3, 1)[:, :, :, :2], mode='bilinear')
168 # TODO: poisson blending should give better-looking results
169 # extract face only
170 uv_texture_gt = uv_gt[:, :3, :, :]*self.smplx_face_eye_mask + \
171 (uv_texture[:, :3, :, :]*(1-self.smplx_face_eye_mask))
172 # use this to extract whole texture from image
173 # uv_texture_gt = uv_gt[:,:3,:,:]
174 opdict['texture'] = uv_texture_gt
175
176 def recover_position(self, opdict, batch, tform, original_image):
177 ''' transofrm mesh back to original image space

Callers

nothing calls this directly

Calls 3

light_albedoMethod · 0.95
world2uvMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected