单应矩阵H,及图像仿射变换warpPerspectiveK为内参,R为旋转矩阵

import sys
import math
ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages'
if ros_path in sys.path:
    sys.path.remove(ros_path)
import cv2
sys.path.append('/opt/ros/kinetic/lib/python2.7/dist-packages')
import numpy as np
K1=np.matrix([[1504.72958809729,0,965.092514870106],
[0,1407.38572229267,569.748552278095],
[0,0,1]])
K3=np.matrix([[1501.83680551596,0,813.810666146807],
[0,1398.24220677846,560.287775632716],
[0,0,1]])
R1=np.matrix([[1,0,0],
[0,1,0],
[0,0,1]])

R3=np.matrix([[0.8560 ,   0.0170 ,  -0.5167],
   [-0.0351   , 0.9991   ,-0.0253],
    [0.5158  ,  0.0398  ,  0.8558]])
img=cv2.imread("/home/XXX/F/image/3/3.jpg")
H=K3*R1*R3.I*K1.I
res = cv2.warpPerspective(img,H,(4000,2000))
cv2.namedWindow("1",0)
cv2.imshow("1",res)
cv2.waitKey(0)

相关文章: