Data-Driven 3D Primitives for Single Image Understanding
(Prediction Code)


The Important Stuff

      [Code (2.9MB .zip), version 1.02, updated 8/14/2014]
      Data (926MB .tar.gz)
      [Model for standard train/test (1.5GB zip)]
      David Fouhey (please note that we cannot provide support)

This is a prediction-only version of the code for Data-Driven 3D Primitives.
It contains a model pre-trained on one our 4x cross-validation splits on the NYU Dataset.

Important: This data must not be used for prediction on the NYU dataset.


  1. Download the code and the data and unpack each in their own directory ($code and $data respectively).
  2. You will have to update the code to match the location of the data. Edit getResourcePath.m and set dataPath to ${data}/.
  3. You may have to recompile the feature computation code; run compile.m. This distribution includes mex files for linux x86_64, but even if you're using that, recompiling may be a good idea.
At this point, the system should work. Look at demo.m, which will demonstrate how to run the code and give some reasonable options for the inference procedure.

Important parameters

The code is encapsulated with a single function run3DP.m that can run everything described in the paper, and is controlled by an options structure much like MATLAB's optimset. Here are the important options (other options are either internal parameters or have to do with data formats):
  1. options.sparseThresholds: a set of thresholds (in [0,1]) to use for the sparse algorithm (one result is returned per threshold)
  2. options.denseThresholds:a set of thresholds to use for the dense algorithm (one result is returned per threshold)
  3. options.makeRectifiedCopies: whether to run a Manhattan-world vanishing point detector (from Hedau, Hoiem and Forsyth) on the input image and snap the results to the vanishing points.
And the results for varying thresholds:
0.350.450.55 0.650.750.85 0.95
Sparse Results
Dense Results
Sparse Results (Rectified)
Dense Results (Rectified)


The data in this package comes from the NYU Depth v2 Dataset available here and collected by Nathan Silberman, Pushmeet Kohli, Derek Hoiem and Rob Fergus.

This code builds off of the following other code-bases, subsets of which are bundled into the code:

  1. Unsupervised Discovery of Mid-Level Discriminative Patches, S. Singh, A. Gupta, and A.A. Efros.
  2. Discriminatively trained deformable part models, R.B. Girshick, P.F. Felzenszwalb, and D. McAllester.
  3. Recovering the Spatial Layout of Cluttered Rooms, V. Hedau, D. Hoiem, D. Forsyth.
  4. Geometric Reasoning for Single Image Structure Recovery, D.C. Lee, M. Hebert, T. Kanade.