案例:Fu Xianjun. All Rights Reserved.
import cv2
import numpy as np
img = cv2,imread('lianxi.png')
h,w,a = img.shape
pts1 = np.float32([[50,180],[220,80],[60,290],[270,190]])
pts2 = np.float([[0,0],[210,0],[0,150],[210,150]])
M = cv2.getPerspectiveTransform(pts1,pts2)
dst = cv2.warpPerspective(img,M,(w,h))
cv2.imshow("img",img)
cv2.imshow("dst",dst)
cv2.waitKey(0)
cv2.destroyAllWindows()