def rotate_points(image, obj_list, angle):
'''
Rotates the points of the given objects by the given angle. The points will be translated
into absolute coordinates. Therefore the image (resp. its shape) is needed.
'''
rotated_obj_list = []
cosOfAngle = np.cos(2 * np.pi / 360 * -angle)
sinOfAngle = np.sin(2 * np.pi / 360 * -angle)
image_shape = np.array(np.atleast_3d(image).shape[0:2][::-1])
rot_mat = np.array([[cosOfAngle, -sinOfAngle], [sinOfAngle, cosOfAngle]])
for obj in obj_list:
obj_name = obj[0]
point = obj[1] * image_shape
rotated_point = AugmentationCreator._rotate_vector_around_point(image_shape/2, point, rot_mat) / image_shape
rotated_obj_list.append((obj_name, (rotated_point[0], rotated_point[1])))
return rotated_obj_list
评论列表
文章目录