This is the MATLAB implementation of the paper:
Simultaneous Video Defogging and Stereo Reconstruction. Zhuwen Li, Ping Tan, Robby T. Tan, Danping Zou, Steven Zhiying Zhou and Loong-Fah Cheong. In CVPR, 2015.
The code has been tested on MATLAB 2014a, If you encounter any problems, please contact elelizh@nus.edu.sg

To have a try and get a rough idea of this code package, please start with "estFogDepthLong.m". It will construct a folder "results" under the folder of the data and put results inside. Note that the bundle optimization (BO) code is not released in this package and this piece of code only generates results without BO. To get BO involved, a alternative solution is to refer to
Guofeng Zhang, Jiaya Jia, Tien-Tsin Wong, and Hujun Bao. Consistent Depth Maps Recovery from a Video Sequence. IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI), 31(6):974-988, 2009.
and get the executable programme ACTS from
http://www.zjucvg.net/acts/acts.html
Then one can transfer the output of this package as an input of their software. The necessary code are provided: "result2acts.m" will construct a folder "acts" under folder "results" and convert the results to the format of ACTS. One can use these as the initial input of ACTS and perform depth recovery -> bundle optimization. Note the only parameter need to change is the depth range. In this way, one can generate close results, since high weights will be given to BO when it is involved. 
One can generate the final results as images by "acts_BO2png.m" with the ".raw" data as input.

To run on the other data, please change the names of "infolder" and "outfolder" in file "estFogDepthLong.m" accordingly. And there are some parameters that one should change as provided in each data:

To run on your own data, one should use some SfM package to get the camera poses. Some recommended packages are:
visual SfM: http://ccwu.me/vsfm/
linear SfM: http://www.zhpcui.org/ICCV2013_SfM/
The camera model used in this package is the same as the one used in these SfM packages. "bundler2fstereo_VSfM.m" can be used to extract the information from the results of Visual SfM and  the information will be saved as "campt.mat" under the folder of the data. Also "camlist.txt" will be generated to record the names of the images.

PS1: For the underwater data, since distortion exists, the projection function "proj4Bundler_dist.m" and "reproj4Bundler_dist.m" should be used.

