C. Zitnick and T. Kanade proposed an algorithm  to compute the depth (or disparity) maps for stereo version. The source code was released for non-commercial usage, and there is a modified version by K. Sokolova and B. Shilo. I suggest you go for the modified version which gives some practical and straightforward descriptions and examples. Also, the modified version offers a complete set to be compiled and executed. However, the source code needs some more minor modifications to be compiled using g++ in Ubuntu 10.04.
10c10 < #include
--- > #include 11a12,13 > #include > #include 270,271d271
20a21 > #include
I combined the output images into the following gif animation (in loop).
 Charles Zitnick and Takeo Kanade, "A Cooperative Algorithm for Stereo Matching and Occlusion Detection," tech. report CMU-RI-TR-99-35, Robotics Institute, Carnegie Mellon University, October, 1999