MATLAB: When using the Computer Vision Toolbox and the “stereoParameters” object how to transform points in camera 1 coordinates to camera 2 coordinates

calibrationComputer Vision Toolboxcosinedirectionframeinstrinsicmatrixopencvstereovision

When using the Computer Vision Toolbox and the "stereoParameters" object how do I transform points in camera 1 coordinates to camera 2 coordinates?

Best Answer

The equation to go from camera 1 coordinates to camera 2 coordinates is:
R = stereoParameters.RotationOfCamera2;
t = stereoParameters.TranslationOfCamera2;
xyzNew = [x,y,z] *R + t;
Assuming you are using the "estimateCameraParameters()" function to construct the "stereoParameters" object, you can inspect the source code for the construction of "stereoParameters" by typing in the MATLAB command window:
>> edit estimateCameraParameters.m
And then clicking the link on the line error to open the source code.