MATLAB: Aligning 3D stereo co-ordinate system along local vertical and local horizontal

Computer Vision Toolboxcoordinate systemimage processingImage Processing Toolboximage reconstructionmathematicsMATLABstereo vision

Using stereo vision, I am able to reconstruct the object under inspection.
After calibration, I know the co-ordinate system which stereo setup uses is mentioned here (it is wrt optical centre of Camera 1).
I have noticed that the same co-ordinate system may not be followed in real world 3D. For example, the local vertical (of a place, which can be found using a spirit level) need not align with the vertical axis (y-axis) of my stereo setup's co-ordinate system.
Suppose I move my object only along the local vertical, without any change in its x position (i.e. local horizontal of that place), according to the stereo co-ordinate system used by the cameras, my object would have moved along y axis (obviously), and also along the x-axis of camera (which is not right, since according to the real world, my object hasn't been moved along local horizontal at all!).
How can I tackle this issue? I am aligning the stereo setup according to the local vertical and local horizontal (using a spirit level), as well as my object. Still, when I move it along local vertical only, there is a few mm change in x-coordinate reading as well. Any inputs regarding this would be appreciated.

Best Answer

Hi Meghana,
Please keep in mind that in the camera-based coordinates the X-Y plane is the image plane, which is inside the camera. It may well not be precisely aligned with the camera's outer casing.
If you need a world coordinate system not tied to the camera, then you can define one by placing a checkerboard in your scene. You can then use the extrinsics function to compute the transformation from the checkerboard's coordinates into the camera's coordinates.