1.关于透视变换原理不赘述
2.已知原图img一像素点坐标p(x,y),变换前矩阵坐标pts1,变换后矩阵坐标pts2,求变换后p点对应坐标
3.程序
# p pts1 pts2#求变换矩阵MM = cv2.getPerspectiveTransform(pts1, pts2)# 坐标转换def cvt_pos(pos, cvt_mat_t):u = pos[0]v = pos[1]x = (cvt_mat_t[0][0]*u+cvt_mat_t[0][1]*v+cvt_mat_t[0][2])/(cvt_mat_t[2][0]*u+cvt_mat_t[2][1]*v+cvt_mat_t[2][2])y = (cvt_mat_t[1][0]*u+cvt_mat_t[1][1]*v+cvt_mat_t[1][2])/(cvt_mat_t[2][0]*u+cvt_mat_t[2][1]*v+cvt_mat_t[2][2])return (int(x), int(y))# 调用函数newpoint = cvt_pos(p, M)