transform.py 文件源码

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

项目:Face-Recognition 作者: irmowan 项目源码 文件源码
def point_trans(ori_point, angle, ori_shape, new_shape):
    """ Transfrom the point from original to rotated image.
    Args:
        ori_point: Point coordinates in original image.
        angle: Rotate angle.
        ori_shape: The shape of original image.
        new_shape: The shape of rotated image.

    Returns:
        Numpy array of new point coordinates in rotated image.
    """
    dx = ori_point[0] - ori_shape[1] / 2.0
    dy = ori_point[1] - ori_shape[0] / 2.0

    t_x = round(dx * math.cos(angle) - dy * math.sin(angle) + new_shape[1] / 2.0)
    t_y = round(dx * math.sin(angle) + dy * math.cos(angle) + new_shape[0] / 2.0)
    return np.array((int(t_x), int(t_y)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号