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)))
评论列表
文章目录