Updated by Alexander Shishkov about 13 years ago

As stated in the Learning OpenCV [[OpenCV]] book, the reprojection matrix element Q(3, 2) should be -1/T_x, but it currently returns 1/Tx. I believe -1/T_x is the correct value.

code from stereoRectify:
double q[] =
{
1, 0, 0, -cc_newr0.x,
0, 1, 0, -cc_newr0.y,
0, 0, 0, fc_new,
0, 0, 1./_t[idx], <---- incorrect
(idx == 0 ? cc_newr0.x - cc_newr1.x : cc_newr0.y - cc_newr1.y)/_t[idx]
};

To verify, I'm attaching a Matlab script which projects a 3D point into both cameras, and then uses Q to reproject to 3D. As expected, the resulting 3D point lies behind the camera. I am assuming that disparity is defined as d=u_L - u_R, i.e disparity values are positive for stereo pairs where the left & right principal points are identical.

Back