warpFace3D.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:FaceAnalysis 作者: ElliotSalisbury 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号