void DiscreteDepthDistortionModel::deserialize(std::istream& in, bool ascii)
    {
      UDEBUG("");
      string buf;
      getline(in, buf);
      UDEBUG("buf=%s", buf.c_str());
      assert(buf == "DiscreteDepthDistortionModel v01");
      if(ascii)
      {
    	  eigen_extensions::deserializeScalarASCII(in, &width_);
		  eigen_extensions::deserializeScalarASCII(in, &height_);
		  eigen_extensions::deserializeScalarASCII(in, &bin_width_);
		  eigen_extensions::deserializeScalarASCII(in, &bin_height_);
		  eigen_extensions::deserializeScalarASCII(in, &bin_depth_);
		  eigen_extensions::deserializeScalarASCII(in, &num_bins_x_);
		  eigen_extensions::deserializeScalarASCII(in, &num_bins_y_);
		  eigen_extensions::deserializeScalarASCII(in, &training_samples_);
      }
      else
      {
		  eigen_extensions::deserializeScalar(in, &width_);
		  eigen_extensions::deserializeScalar(in, &height_);
		  eigen_extensions::deserializeScalar(in, &bin_width_);
		  eigen_extensions::deserializeScalar(in, &bin_height_);
		  eigen_extensions::deserializeScalar(in, &bin_depth_);
		  eigen_extensions::deserializeScalar(in, &num_bins_x_);
		  eigen_extensions::deserializeScalar(in, &num_bins_y_);
		  eigen_extensions::deserializeScalar(in, &training_samples_);
      }
      UINFO("Distortion Model: width=%d", width_);
      UINFO("Distortion Model: height=%d", height_);
      UINFO("Distortion Model: bin_width=%d", bin_width_);
      UINFO("Distortion Model: bin_height=%d", bin_height_);
      UINFO("Distortion Model: bin_depth=%f", bin_depth_);
      UINFO("Distortion Model: num_bins_x=%d", num_bins_x_);
      UINFO("Distortion Model: num_bins_y=%d", num_bins_y_);
      UINFO("Distortion Model: training_samples=%d", training_samples_);
      deleteFrustums();
      frustums_.resize(num_bins_y_);
      for(size_t y = 0; y < frustums_.size(); ++y) {
        frustums_[y].resize(num_bins_x_, NULL);
        for(size_t x = 0; x < frustums_[y].size(); ++x) {
        	UDEBUG("Distortion Model: Frustum[%d][%d]", y, x);
          frustums_[y][x] = new DiscreteFrustum;
          frustums_[y][x]->deserialize(in, ascii);
        }
      }
      UDEBUG("");
    }
  void DiscreteDepthDistortionModel::deserialize(std::istream& in)
  {
    string buf;
    getline(in, buf);
    assert(buf == "DiscreteDepthDistortionModel v01");
    eigen_extensions::deserializeScalar(in, &width_);
    eigen_extensions::deserializeScalar(in, &height_);
    eigen_extensions::deserializeScalar(in, &bin_width_);
    eigen_extensions::deserializeScalar(in, &bin_height_);
    eigen_extensions::deserializeScalar(in, &bin_depth_);
    eigen_extensions::deserializeScalar(in, &num_bins_x_);
    eigen_extensions::deserializeScalar(in, &num_bins_y_);

    deleteFrustums();
    frustums_.resize(num_bins_y_);
    for(size_t y = 0; y < frustums_.size(); ++y) {
      frustums_[y].resize(num_bins_x_, NULL);
      for(size_t x = 0; x < frustums_[y].size(); ++x) {
        frustums_[y][x] = new DiscreteFrustum;
        frustums_[y][x]->deserialize(in);
      }
    }
  }
 DiscreteDepthDistortionModel::~DiscreteDepthDistortionModel()
 {
   deleteFrustums();
 }