Skip to content
Switch branches/tags


Failed to load latest commit information.
Latest commit message
Commit time

Hybrid CNN-CRF Stereo

This repository provides software for our publication "End-to-End Training of Hybrid CNN-CRF Models for Stereo", which is going to be presented at CVPR 2017.

If you use this code please cite the following publication:

  author = {Patrick Knöbelreiter and Christian Reinbacher and Alexander Shekhovtsov and Thomas Pock},
  title = {{End-to-End Training of Hybrid CNN-CRF Models for Stereo}},
  booktitle = {2017 Computer Vision and Pattern Recognition (CVPR)},
  year = {2017},

Repository Structure

The repository is structured as follows:

  • stereo contains the C++/CUDA code of our CNN-CRF model -> this needs to be compiled to use our model for disparity computation
  • undistort contains python code for rectifying the Middlebury images
  • eval contains python code for reproducing the numbers presented in the paper
  • data contains the learned model parameters


For your convenience, the required libraries that are on Github are added as submodules. So clone this repository with --recursive or do a

git submodule update --init --recursive

after cloning. All dependencies will be located in the dependency folder like



This software requies:

Image Utilities

Compile and install imageutilities: Follow the instructions on Make sure you set the environment variable IMAGEUTILITIES_ROOT correctly. This is necessary to find the compiled library automatically with CMake.


Compile and install cnpy by executing the following commands:

cd dependencies/cnpy
mkdir build
cd build
cmake ..
(sudo) make install
cd ../../

More information can be found at


Compile SlackProp using the following commands:

cd dependencies/slackprop
mkdir build
cd build
cmake ..
cd ../../


At this point you should have compiled all the dependencies successfully. Please also double-check you have set the environment variable IMAGEUTILITIES_ROOT correctly.

Compiling our stereo model:

mkdir build
cd build
cmake ../stereo

If everything worked correctly, you should see an executeable called stereo_img in your build directory. The following simple test will print the usage information



In order to demonstrate the usage of our code we put a rectified stereo-pair into the data directory. You can compute the disparity map using

./stereo_img --im0 ../data/im0.png --im1 ../data/im1.png

This will create a file called output.png in the same directory. Otherwise, download the Middlebury data as described below. Then you can test the algorithm using

./stereo_img --im0 ../data/middlebury-2014/MiddEval3/trainingQ/Adirondack/im0.png  --im1 ../data/middlebury-2014/MiddEval3/trainingQ/Adirondack/im1.png --parameter-file ../data/parameters/middlebury-2014/7-layer/cnn+crf+full/params --config-file ../data/parameters/middlebury-2014/7-layer/cnn+crf+full/config_mb_cnn7_crf_full.cfg

Reproduce the numbers in the paper



First you must download the data from the respective benchmark and then you can use the provided evaluation scripts to reproduce the numbers in the paper.

Create the two directories middlebury-2014 and kitti-2015 in the data directory, such that the structure of the data directory is


Middlebury Stereo Evaluation - Version 3

  1. Download the Middlebury 2014 data from ( You will will need Input Data as well as Ground truth for left view for quarter (Q), half (H) and full (F) resolution.
  2. Download the Middlebury evaluation SDK (
  3. Extract all downloaded files to the data folder. Your data folder should look like
|--- middlebury-2014/
    |--- MiddEval3/
        |--- trainingQ/
        |--- trainingH/
        |--- testQ/
        |--- testH/
        |--- runevalF
        |--- ...
  1. Compile the Middlebury evaluation SDK like described in
  2. Rectify train/test images using the provided script
cd undistort
python ../data/middlebury-2014/MiddEval3/trainingH/
python ../data/middlebury-2014/MiddEval3/testH/

This command will warp im1 such that corresponding pixels are located in the same row. The rectified images are saved as im1_rectified.png in the appropriate folder.

  1. Compute results for Middlebury
cd eval
  1. Compute Errors

Kitti Stereo Evaluation 2015

  1. Download the Kitti 2015 data from (
  2. Make a folder kitti-2015 in the data folder and extract all downloaded files there Your data folder should look like
|--- kitti-2015
    |--- testing/
    |--- training/
  1. Compute results for Kitti
cd eval
  1. Compute Errors


No description, website, or topics provided.




No releases published


No packages published