import cv2 import numpy as np img = cv2.imread(‘D:\pycharm project\cameraCalibration\chang.jpg’) H_rows, W_cols= img.shape[:2] print(img.shape[0]) print(H_rows, W_cols) 原图中书本的四个角点(左上、右上、左下、右下),与变换后矩阵位置 pts1 = np.float32([[71, 617], [711, 411], [265, 1315], [1079, 963]]) pts2 = np.float32([[0, 0],[1080,0],[0, 1080],[1080, 1080]]) 生成透视变换矩阵;进行透视变换 M = cv2.getPerspectiveTransform(pts1, pts2) dst = cv2.warpPerspective(img, M, (1080,1080)) cv2.imshow(“original_img”,img) cv2.imshow(“result”,dst) cv2.waitKey(0) cv2.destroyAllWindows() #include <opencv2\opencv.hpp> #include using namespace cv; using