Citation: 
@inproceedings{suwajanakorn2015depth,
  title={Depth from Focus with Your Mobile Phone},
  author={Suwajanakorn, Supasorn and Hernandez, Carlos and Seitz, Steven M},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={3497--3506},
  year={2015}
}


Our auto-calibration does not solve the inverse-depth ambiguity mentioned in the paper, so everything will be up to that scale.

In each folder, there are 
calibrated.txt
  each line is focal depths / aperture 
  last line is focal length

depth_var.bin
  contains the output depth (double) of size height * width.

scaleMatrix.bin
  contains scaling for each image. 

To read depth_var.bin, scaleMatrix.bin, use the following OpenCV snippet. It should say enough about the binary stored in those files in case you use other languages.

int sizeOfType(int type) {
  uchar depth = type & CV_MAT_DEPTH_MASK;
  switch ( depth ) {
    case CV_8U:  return 1;
    case CV_8S:  return 1;
    case CV_16U: return 2;
    case CV_16S: return 2;
    case CV_32S: return 4;
    case CV_32F: return 4;
    case CV_64F: return 8;
  }
}

 Mat readMat(std::string filename) {
  FILE *fi = fopen(filename.c_str(), "rb");
  uchar t; fread(&t, sizeof(uchar), 1, fi);
  int h;   fread(&h, sizeof(int), 1, fi);
  int w;   fread(&w, sizeof(int), 1, fi);
  Mat out(h, w, t);
  fread(out.data, sizeOfType(out.type()), h * w * out.channels(), fi);
  fclose(fi);
  return out;
}


To visualize the final depthmap as shown in the paper:
  Mat a = readMat("..../calibration/keyboard/depth_var.bin");
  double mx = -1e10;
  double mn = 1e10;
  for (int i = 0; i < a.rows; i++) {
    for (int j = 0; j < a.cols; j++) {
      a.at<double>(i, j) = 1 / a.at<double>(i, j);
      if (a.at<double>(i, j) > mx) 
        mx = a.at<double>(i, j);
      if (a.at<double>(i, j) < mn) 
        mn = a.at<double>(i, j);
    }
  }
  a -= mn;
  a /= (mx-mn);
  imshow("a", Scalar::all(1) - a);

