def warpFace3D(im, oldMesh, pose, newMesh, accurate=False, fitter=None):
oldVerts2d = projectMeshTo2D(oldMesh, pose, im)
newVerts2d = projectMeshTo2D(newMesh, pose, im)
if not accurate and fitter is not None:
ALL_FACE_MESH_VERTS = fitter.landmarks_2_vert_indices[ALL_FACE_LANDMARKS]
ALL_FACE_MESH_VERTS = np.delete(ALL_FACE_MESH_VERTS, np.where(ALL_FACE_MESH_VERTS == -1)).tolist()
oldConvexHullIndexs = cv2.convexHull(oldVerts2d.astype(np.float32), returnPoints=False)
warpPointIndexs = oldConvexHullIndexs.flatten().tolist() + ALL_FACE_MESH_VERTS
oldVerts2d = oldVerts2d[warpPointIndexs]
newVerts2d = newVerts2d[warpPointIndexs]
warpedIm = warpFace(im, oldVerts2d, newVerts2d)
return warpedIm
评论列表
文章目录