Compute P from K,D,R,T using StereoRectify

Hello,

I have the following stereo calibration data, which is provided from a file:

Left camera:
K1 = [500.68330 0 318.57250
0  500.25257 247.11452
0 0 1]
D1 = [ -0.22225   0.10381   0.0000 0 ] --> Distortion parameters
R1 = [ 1 0 0
0 1 0
0 0 1]
T1 = [ 0 0 0 ]

Right camera:
K2 = [ 500.80696 0 307.20573
0  500.39406 233.52064
0 0 1]
D2 = [ -0.22738   0.11823  0 0 ]
R2 = [  0.994584465424537   0.008137584213299   0.103612358622704
-0.008733820371460   0.999947802720680   0.005302095416238
-0.103563804091524  -0.006178313463662   0.994603623020164]
T2 = [ -399.96195   -22.45476 0.66913 ]


I use the following code in order the get the P1 and P2 matrices:

cv.StereoRectify(K1, K2, D1, D2, (height, width), R2, T2, R1, R2, P1, P2, np.zeros((4, 4), float)), 0)


The obtained output is the following, but when I apply this calibration I can observe it is not good:

R1  [[ 0.99270276  0.06418606  0.10208517]
[-0.06433084  0.99792686 -0.00187686]
[-0.10199401 -0.00470406  0.99477389]]

R2  [[ 0.99842635  0.05605389 -0.00167035]
[-0.0560562   0.99842668 -0.00136989]
[ 0.00159094  0.00146137  0.99999767]]

P1  [[ 427.68975971    0.          255.76326752    0.        ]
[   0.          427.68975971  237.85540771    0.        ]
[   0.            0.            1.            0.        ]]

P2  [[  4.27689760e+02   0.00000000e+00   3.00858452e+02  -1.71329243e+05]
[  0.00000000e+00   4.27689760e+02   2.37855408e+02   0.00000000e+00]
[  0.00000000e+00   0.00000000e+00   1.00000000e+00   0.00000000e+00]]


Can anyone notice what am I doing wrong? Thanks in advance.

edit retag close merge delete