1import numpy as np
2import cv2
3
4def rotate_image(image, angle):
5 image_center = tuple(np.array(image.shape[1::-1]) / 2)
6 rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0)
7 result = cv2.warpAffine(image, rot_mat, image.shape[1::-1], flags=cv2.INTER_LINEAR)
8 return result
9