Search code examples
computer-visiondisparity-mapping

FInding the Z coordinate using disparity map


I have found Disparity map of two stereoscopic images. And now I have to write an OpenGL code to visualize it for 3D reconstruction.

OpenGL has function vertex3f() for which three co-ordinates are to mentioned.

Two dimension are points on image.

So how to find z dimension using Disparity map?

Please suggest something on this.


Solution

  • Since, you have found disparity mapping, I assume that you are working with rectified images. In that case, the Z coordinate is given by simple similar triangle formulation,

    z=Bf/d, where f if the focal length of the camera used (in pixels), d is the obtained disparity value for the pixel of interest and B is the baseline between the two stereo images. Note, the unit of z would be the same as that of B.