import cv2 as cv
import numpy as np img = cv.imread('../images/face.jpg')
h, w = img.shape[:2]
mat_src = np.float32([[0, 0], [0, h-1], [w-1, 0]])
mat_dst = np.float32([[50, 50], [100, h-50], [w-50, 100]])
matAffine = cv.getAffineTransform(mat_src, mat_dst)
dst = cv.warpAffine(img, matAffine, (w, h))
cv.imshow('dst', dst)
cv.waitKey(0)
原图
效果