import sys import cv2 import numpy as np import matplotlib.pyplot as plt def rotate(img_path, center, angle, scale): img = cv2.imread(img_path, 1) M = cv2.getRotationMatrix2D(center, angle, scale) # 使用内置函数构建矩阵 result = cv2.warpAffine(img, M, (img.shape[1], img.shape[0])) cv2.imwrite('./output/rotate.jpg', result) ''' 输入:一张图片,旋转中心,旋转角 输出:旋转后的图片 ''' if __name__ == '__main__': rotate(sys.argv[1], eval(sys.argv[2]), eval(sys.argv[3]), eval(sys.argv[4]))