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.
|
|
|
|
import sys
|
|
|
|
|
import cv2
|
|
|
|
|
import numpy as np
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def warpAffine(img_path, matSrc, matDst):
|
|
|
|
|
img = cv2.imread(img_path, 1)
|
|
|
|
|
height, width = img.shape[:2]
|
|
|
|
|
M = cv2.getAffineTransform(np.float32(matSrc), np.float32(matDst)) # 生成矩阵
|
|
|
|
|
result = cv2.warpAffine(img, M, (width, height))
|
|
|
|
|
cv2.imwrite('./output/warpAffine.jpg', result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
输入:一张图片,旋转前三个点的坐标matSrc,旋转后三个点的坐标matDst
|
|
|
|
|
输出:仿射变换后的图片
|
|
|
|
|
'''
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
warpAffine(sys.argv[1], eval(sys.argv[2]), eval(sys.argv[3]))
|