You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
549 B

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]))