import cv2 import numpy as np image = cv2.imread("example.png") rows, cols, _ = image.shape center = (cols // 2, rows // 2) for angle in range(0, 360, 5): # 获取旋转矩阵 M = cv2.getRotationMatrix2D(center, angle, 1) # 对图像进行旋转 rotated_image = cv2.warpAffine(image, M, (cols, rows)) cv2.imshow("Rotated", rotated_image) cv2.waitKey(50) cv2.destroyAllWindows()