faces.py 文件源码

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

项目:iffse 作者: kendricktan 项目源码 文件源码
def align_face_to_template(img, facial_landmarks, output_dim, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP):
    """
    Aligns image by warping it to fit the landmarks on
    the image (src) to the landmarks on the template (dst)

    Args:
        img: src image to be aligned
        facial_landmarks: list of 68 landmarks (obtained from dlib)
        output_dim: image output dimension
    """
    np_landmarks = np.float32(facial_landmarks)
    np_landmarks_idx = np.array(landmarkIndices)

    H = cv2.getAffineTransform(np_landmarks[np_landmarks_idx],
                               output_dim * SCALED_LANDMARKS[np_landmarks_idx])
    warped = cv2.warpAffine(img, H, (output_dim, output_dim))

    return warped
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号