@DoDoM Since you have calibrated your cameras, you should use the focal length given by the stereo calibration function.
Edit: as you mentioned in another thread, stereoCalibrate
gives you a value of f_x in pixels and not in millimeters. But it turns out that this is exactly what you need to compute Z. If you look at the formula mentioned in my previous comment:
- the baseline B is expressed in metric units
- the disparity (x - c_x) - (x' - c'_x) is in pixels (since x is the pixel coordinate of the point and c_x the coordinate of the principal point).
Therefore, f has to be expressed in pixels for the formula to be consistent. You actually don’t need to know the size of a pixel or the focal length in metric units, but only the ratio between these two quantities (i.e. the focal length in pixels).