diff --git a/apps/specular_estimation/CMakeFiles/specular_estimation.dir/CXX.includecache b/apps/specular_estimation/CMakeFiles/specular_estimation.dir/CXX.includecache
index 97fdfa576eb3e3b4dbf0d86c5c766e77baae4511..53e80b01e4e612409fb1bf2a1fe837f2122229dd 100644
--- a/apps/specular_estimation/CMakeFiles/specular_estimation.dir/CXX.includecache
+++ b/apps/specular_estimation/CMakeFiles/specular_estimation.dir/CXX.includecache
@@ -69,6 +69,10 @@ GL/gl.h
 -
 GL/glu.h
 -
+ceres/ceres.h
+/home/thomas/Documents/Minimisation/apps/specular_estimation/src/ceres/ceres.h
+glog/logging.h
+/home/thomas/Documents/Minimisation/apps/specular_estimation/src/glog/logging.h
 
 /home/thomas/Documents/Minimisation/apps/specular_estimation/src/objloader.cpp
 vector
diff --git a/apps/specular_estimation/CMakeFiles/specular_estimation.dir/src/specular_estimation.cc.o b/apps/specular_estimation/CMakeFiles/specular_estimation.dir/src/specular_estimation.cc.o
index dec791fb80424a625a03d3fa21e9cbc20807488d..7821e82836923bd38246c905047fca7037cf83a6 100644
Binary files a/apps/specular_estimation/CMakeFiles/specular_estimation.dir/src/specular_estimation.cc.o and b/apps/specular_estimation/CMakeFiles/specular_estimation.dir/src/specular_estimation.cc.o differ
diff --git a/apps/specular_estimation/src/Ceres.h b/apps/specular_estimation/src/Ceres.h
index 2987824a01248924bae75456a268f640435a5bc3..f43f3137a6479f04580221c8a4003faab9ef15f2 100644
--- a/apps/specular_estimation/src/Ceres.h
+++ b/apps/specular_estimation/src/Ceres.h
@@ -21,14 +21,16 @@ struct CostFunctor {
 		return true;
 	}
 };
-/*
-struct CostFunctor {
+
+/*struct CostFunctor {
   template <typename T> bool operator()(const T* const SpecularIntensity, const T* const SpecularPower, T* residual) const {
-    residual[0] = returnResidual(lightNumber, height, width, textureImages, residualImage, residuals, SpecularIntensity, SpecularPower);
+    computeResiduals(residual, residuals, totalResidual, residualImage, calculateResidual, depthProjectionMatrix, depthViewMatrix, width, height, position, horizontalAngle, verticalAngle, FoV, lightInvDir, lightDirections, textureImages, lightNumber, numberOfLights, SpecularIntensityID, SpecularIntensity, SpecularPowerID, SpecularPower, programID, ModelMatrixID, ViewMatrixID, DepthBiasID, lightInvDirID, Texture, TextureID, depthTexture, ShadowMapID, vertexbuffer, uvbuffer, normalbuffer, elementbuffer, indices, MatrixID);
+	
+    residual[0] = residual;
     return true;
   }
-};
-*/
+};*/
+
 void specularMinimisation(float& SpecularIntensity, float& SpecularPower, double& residual) {
 	
   // The variable to solve for with its initial value. It will be mutated in place by the solver.
diff --git a/apps/specular_estimation/src/OpenGL.h b/apps/specular_estimation/src/OpenGL.h
index 2154ba679cc2922dc9011e2c8bf215ccf879367e..5253137d993e7a6ff7c3c18217f09b834a3a53d2 100644
--- a/apps/specular_estimation/src/OpenGL.h
+++ b/apps/specular_estimation/src/OpenGL.h
@@ -26,6 +26,15 @@
 #include <GL/gl.h>		// Header File For The OpenGL32 Library
 #include <GL/glu.h>		// Header File For The GLu32 Library
 
+#include "ceres/ceres.h"
+#include "glog/logging.h"
+
+using ceres::AutoDiffCostFunction;
+using ceres::CostFunction;
+using ceres::Problem;
+using ceres::Solver;
+using ceres::Solve;
+
 void computeMatricesFromInputs(int windowWidth, int windowHeight, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, float mouseSpeed, glm::mat4& ProjectionMatrix, glm::mat4& ViewMatrix, glm::vec3& lightInvDir, glm::mat4& depthProjectionMatrix, glm::mat4& depthViewMatrix, bool& perspectiveProjection, bool& shadowControl, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, bool& calculateResidual);
 void computeMatricesFromLights(int windowWidth, int windowHeight, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::mat4& ProjectionMatrix, glm::mat4& ViewMatrix, glm::vec3& lightInvDir, glm::mat4& depthProjectionMatrix, glm::mat4& depthViewMatrix, bool& perspectiveProjection, cv::Mat lightDirections, std::vector< cv::Mat > textureImages, int& lightNumber, int numberOfLights, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, bool& calculateResidual);
 void createMesh(cv::Mat Z, cv::Mat normals, std::vector<glm::vec3> & out_vertices, std::vector<glm::vec2> & out_uvs, std::vector<glm::vec3> & out_normals, std::vector<unsigned int> & out_indices);
@@ -36,9 +45,9 @@ void terminateOpenGL(GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer,
 void renderPolygons(int windowWidth, int windowHeight, GLuint programID, glm::vec3 lightInvDir, GLuint MatrixID, GLuint ModelMatrixID, GLuint ViewMatrixID, GLuint DepthBiasID, GLuint lightInvDirID, GLuint Texture, GLuint TextureID, GLuint depthTexture, GLuint ShadowMapID, GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, glm::mat4 MVP, glm::mat4 ModelMatrix, glm::mat4 ViewMatrix, glm::mat4 depthBiasMVP, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower);
 void renderShadows(GLuint FramebufferName, int shadowResolution, GLuint depthProgramID, glm::mat4 depthProjectionMatrix, glm::mat4 depthViewMatrix, GLuint depthMatrixID, GLuint vertexbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, glm::mat4 depthModelMatrix, glm::mat4 depthMVP);
 void renderShadowMap(GLuint quad_programID, GLuint depthTexture, GLuint texID, GLuint quad_vertexbuffer);
-void computeResidual(int imageNumber, int windowHeight, int windowWidth, std::vector < cv::Mat > textureImages, cv::Mat& residual, cv::Vec3d& residuals, double& sum, float SpecularIntensity, float SpecularPower);
+void computeResidual(int imageNumber, int windowHeight, int windowWidth, std::string modelPath, std::vector < cv::Mat > textureImages, cv::Mat& residual, cv::Vec3d& residuals, double& sum, float SpecularIntensity, float SpecularPower);
 double returnResidual(int imageNumber, int windowHeight, int windowWidth, std::vector < cv::Mat > textureImages, cv::Mat& residual, cv::Vec3d& residuals, float SpecularIntensity, float SpecularPower);
-void computeResiduals(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals, double& totalResidual, cv::Mat& residualImage, bool calculateResidual, glm::mat4 depthProjectionMatrix, glm::mat4 depthViewMatrix, int width, int height, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::vec3& lightInvDir, cv::Mat lightDirections, std::vector< cv::Mat > textureImages, int& lightNumber, int numberOfLights, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, GLuint programID, GLuint ModelMatrixID, GLuint ViewMatrixID, GLuint DepthBiasID, GLuint lightInvDirID, GLuint Texture, GLuint TextureID, GLuint depthTexture, GLuint ShadowMapID, GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, GLuint MatrixID);
+void computeResiduals(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals, double& totalResidual, cv::Mat& residualImage, bool calculateResidual, glm::mat4 depthProjectionMatrix, glm::mat4 depthViewMatrix, int width, int height, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::vec3& lightInvDir, cv::Mat lightDirections, std::vector< cv::Mat > textureImages, int& lightNumber, int numberOfLights, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, GLuint programID, GLuint ModelMatrixID, GLuint ViewMatrixID, GLuint DepthBiasID, GLuint lightInvDirID, GLuint Texture, GLuint TextureID, GLuint depthTexture, GLuint ShadowMapID, GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, GLuint MatrixID, std::string modelPath, double& x, Problem& problem);
 void viewModel(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals, double& totalResidual, cv::Mat& residualImage, bool calculateResidual, glm::mat4 depthProjectionMatrix, glm::mat4 depthViewMatrix, int width, int height, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::vec3& lightInvDir, cv::Mat lightDirections, std::vector< cv::Mat > textureImages, int& lightNumber, int numberOfLights, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, GLuint programID, GLuint ModelMatrixID, GLuint ViewMatrixID, GLuint DepthBiasID, GLuint lightInvDirID, GLuint Texture, GLuint TextureID, GLuint depthTexture, GLuint ShadowMapID, GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, GLuint MatrixID);
 
 void initialiseOpenGL(cv::Mat cv_depth, cv::Mat cv_normals, cv::Mat cv_texture, std::vector< cv::Mat > textureImages, cv::Mat lightDirections, int& windowWidth, int& windowHeight, glm::mat4& depthProjectionMatrix, glm::mat4& depthViewMatrix, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::vec3& lightInvDir, GLuint& programID, GLuint& MatrixID, GLuint& ModelMatrixID, GLuint& ViewMatrixID, GLuint& DepthBiasID, GLuint& lightInvDirID, GLuint& Texture, GLuint& TextureID, GLuint& depthTexture, GLuint& ShadowMapID, GLuint& vertexbuffer, GLuint& uvbuffer, GLuint& normalbuffer, GLuint& elementbuffer, std::vector<unsigned int> & indices, GLuint& depthProgramID, GLuint& quad_programID, GLuint& FramebufferName, GLuint& quad_vertexbuffer, GLuint& VertexArrayID, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower) {
@@ -460,7 +469,7 @@ void renderPolygons(int windowWidth, int windowHeight, GLuint programID, glm::ve
 	}
 }*/
 
-void computeResidual(int imageNumber, int windowHeight, int windowWidth, std::vector < cv::Mat > textureImages, cv::Mat& residual, cv::Vec3d& residuals, double& sum, float SpecularIntensity, float SpecularPower) {
+void computeResidual(int imageNumber, int windowHeight, int windowWidth, std::string modelPath, std::vector < cv::Mat > textureImages, cv::Mat& residual, cv::Vec3d& residuals, double& sum, float SpecularIntensity, float SpecularPower) {
 	
 	// Create an empty Mat the same size as the image
 	cv::Mat temp = cv::Mat(windowHeight, windowWidth, CV_8UC3);
@@ -472,7 +481,8 @@ void computeResidual(int imageNumber, int windowHeight, int windowWidth, std::ve
 	// 3D models have the origin in the bottom-left corner, while images have the origin in the top-left corner. The image is flipped to convert between the two.
 	cv::flip(temp, temp, 0);
 	
-	
+	/*temp = temp(cv::Rect(0, 0, windowWidth, windowHeight-1));
+	copyMakeBorder(temp, temp, 0, 1, 0, 0, cv::BORDER_REPLICATE);*/
 	
 	// Calculate the absolute differences between the model and the photograph
 	cv::absdiff(temp, textureImages[imageNumber], residual);
@@ -480,9 +490,17 @@ void computeResidual(int imageNumber, int windowHeight, int windowWidth, std::ve
 	// Square each element
 	multiply(residual, residual, sumOfSquaredDifferences);
 	
+	std::ostringstream stm;
+	stm << imageNumber;
+	std::string number = stm.str();
+	
 	// Display the residual
-	//cv::imshow("Original", temp);
-	//cv::imshow("Residual", residual);
+	//cv::namedWindow("Model", CV_WINDOW_NORMAL);
+	//cv::imshow("Model", temp);
+	//cv::namedWindow("Sum of Squared Differences", CV_WINDOW_NORMAL);
+	//cv::imshow("Sum of Squared Differences", sumOfSquaredDifferences);
+	cv::imwrite(modelPath + "model." + number + ".png", temp);
+	cv::imwrite(modelPath + "residual." + number + ".png", sumOfSquaredDifferences);
 	
 	//
 	sum = (cv::sum(sumOfSquaredDifferences)[0] + cv::sum(sumOfSquaredDifferences)[1] + cv::sum(sumOfSquaredDifferences)[2])/(windowHeight * windowWidth);
@@ -539,7 +557,7 @@ double returnResidual(int imageNumber, int windowHeight, int windowWidth, std::v
 	return sum;
 }
 
-void computeResiduals(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals, double& totalResidual, cv::Mat& residualImage, bool calculateResidual, glm::mat4 depthProjectionMatrix, glm::mat4 depthViewMatrix, int width, int height, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::vec3& lightInvDir, cv::Mat lightDirections, std::vector< cv::Mat > textureImages, int& lightNumber, int numberOfLights, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, GLuint programID, GLuint ModelMatrixID, GLuint ViewMatrixID, GLuint DepthBiasID, GLuint lightInvDirID, GLuint Texture, GLuint TextureID, GLuint depthTexture, GLuint ShadowMapID, GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, GLuint MatrixID) {
+void computeResiduals(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals, double& totalResidual, cv::Mat& residualImage, bool calculateResidual, glm::mat4 depthProjectionMatrix, glm::mat4 depthViewMatrix, int width, int height, glm::vec3& position, float& horizontalAngle, float& verticalAngle, float& FoV, glm::vec3& lightInvDir, cv::Mat lightDirections, std::vector< cv::Mat > textureImages, int& lightNumber, int numberOfLights, GLuint& SpecularIntensityID, float& SpecularIntensity, GLuint& SpecularPowerID, float& SpecularPower, GLuint programID, GLuint ModelMatrixID, GLuint ViewMatrixID, GLuint DepthBiasID, GLuint lightInvDirID, GLuint Texture, GLuint TextureID, GLuint depthTexture, GLuint ShadowMapID, GLuint vertexbuffer, GLuint uvbuffer, GLuint normalbuffer, GLuint elementbuffer, std::vector<unsigned int> indices, GLuint MatrixID, std::string modelPath, double& x, Problem& problem) {
 	do {
 		// Render the shadows
 		glm::mat4 depthModelMatrix = glm::mat4(1.0);
@@ -573,7 +591,7 @@ void computeResiduals(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals,
 		
 		
 		//totalResidual = returnResidual(lightNumber, height, width, textureImages, residualImage, residuals, SpecularIntensity, SpecularPower);
-		computeResidual(lightNumber, height, width, textureImages, residualImage, residual, totalResidual, SpecularIntensity, SpecularPower);
+		computeResidual(lightNumber, height, width, modelPath, textureImages, residualImage, residual, totalResidual, SpecularIntensity, SpecularPower);
 		residuals.push_back(residual);
 		
 		// Set up the only cost function (also known as residual). This uses auto-differentiation to obtain the derivative (jacobian).
@@ -585,6 +603,14 @@ void computeResiduals(cv::Vec3d& residual, std::vector< cv::Vec3d >& residuals,
 		glfwSwapBuffers(window);
 		glfwPollEvents();
 		
+		
+		
+		//TODO: Save model image and residual
+		
+		
+		/*CostFunction* cost_function = new AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor);
+		problem.AddResidualBlock(cost_function, NULL, &x);
+		*/
 		lightNumber++;
 	} while (lightNumber < numberOfLights);
 	//} while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0); // Check if the ESC key was pressed or the window was closed
@@ -673,6 +699,8 @@ void computeMatricesFromLights(int windowWidth, int windowHeight, glm::vec3& pos
 	// Up vector
 	glm::vec3 up = glm::cross(right, direction);
 	
+	lightInvDir = glm::vec3(lightDirections.at<float>(lightNumber, 1), -lightDirections.at<float>(lightNumber, 0), lightDirections.at<float>(lightNumber, 2));
+	
 	// Change light direction
 	if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS) {
 		if (glfwGetKey(window, GLFW_KEY_1) == GLFW_RELEASE) {
@@ -698,24 +726,21 @@ void computeMatricesFromLights(int windowWidth, int windowHeight, glm::vec3& pos
 			calculateResidual = true;
 		}
 	}
-	else {
-		lightInvDir = glm::vec3(lightDirections.at<float>(lightNumber, 1), -lightDirections.at<float>(lightNumber, 0), lightDirections.at<float>(lightNumber, 2));
-	}
 	
 	// Modify specular power
 	if (glfwGetKey(window, GLFW_KEY_7) == GLFW_PRESS) {
-		if (glfwGetKey(window, GLFW_KEY_7) == GLFW_RELEASE) {
-			if (SpecularPower > 1.0f) {
-				SpecularPower -= 1.0f;
+		//if (glfwGetKey(window, GLFW_KEY_7) == GLFW_RELEASE) {
+			if (SpecularPower > 0.1f) {
+				SpecularPower -= 0.1f;
 				calculateResidual = true;
 			}
-		}
+		//}
 	}
 	else if (glfwGetKey(window, GLFW_KEY_8) == GLFW_PRESS) {
-		if (glfwGetKey(window, GLFW_KEY_8) == GLFW_RELEASE) {
-			SpecularPower += 1.0f;
+		//if (glfwGetKey(window, GLFW_KEY_8) == GLFW_RELEASE) {
+			SpecularPower += 0.1f;
 			calculateResidual = true;
-		}
+		//}
 	}
 	
 	// Modify specular intensity
@@ -902,15 +927,32 @@ void createMesh(cv::Mat cv_depth, cv::Mat cv_normals, std::vector<glm::vec3> & o
 
 	int percentage = 0;
 
-	for (int y = 0; y < cv_normals.rows; y++) {
-		for (int x = 0; x < cv_normals.cols; x++) {
+	for (int y = 0; y <= cv_normals.rows; y++) {
+		for (int x = 0; x <= cv_normals.cols; x++) {
 			out_vertices.push_back(glm::vec3(float(x - (cv_normals.cols / 2)) / cv_normals.rows, float(y - (cv_normals.rows / 2)) / cv_normals.rows, 0));
 			//out_vertices.push_back(glm::vec3(float(x - (cv_normals.cols / 2)) / cv_normals.rows, float(y - (cv_normals.rows / 2)) / cv_normals.rows, -cv_depth.at<float>(y, x) / (cv_normals.rows * 10)));
-
 			out_uvs.push_back(glm::vec2(float(x) / cv_normals.cols, 1.0f - (float(y) / cv_normals.rows)));
-
+			/*
+			if (y == cv_normals.rows)
+				y--;
+			if (x == cv_normals.cols)
+				x--;
+			
 			out_normals.push_back(glm::vec3(cv_normals.at<cv::Vec3f>(y, x)[1], -cv_normals.at<cv::Vec3f>(y, x)[0], cv_normals.at<cv::Vec3f>(y, x)[2]));
-			//out_normals.push_back(glm::vec3(0, 0, 1));
+			*/
+			
+			if (y == cv_normals.rows) {
+				out_normals.push_back(glm::vec3(cv_normals.at<cv::Vec3f>(y-1, x)[1], -cv_normals.at<cv::Vec3f>(y-1, x)[0], cv_normals.at<cv::Vec3f>(y-1, x)[2]));
+			} else if (x == cv_normals.cols) {
+				out_normals.push_back(glm::vec3(cv_normals.at<cv::Vec3f>(y, x-1)[1], -cv_normals.at<cv::Vec3f>(y, x-1)[0], cv_normals.at<cv::Vec3f>(y, x-1)[2]));
+			} else if (y == cv_normals.rows && x == cv_normals.cols) {
+				out_normals.push_back(glm::vec3(cv_normals.at<cv::Vec3f>(y-1, x-1)[1], -cv_normals.at<cv::Vec3f>(y-1, x-1)[0], cv_normals.at<cv::Vec3f>(y-1, x-1)[2]));
+			} else {
+				out_normals.push_back(glm::vec3(cv_normals.at<cv::Vec3f>(y, x)[1], -cv_normals.at<cv::Vec3f>(y, x)[0], cv_normals.at<cv::Vec3f>(y, x)[2]));
+				//out_normals.push_back(glm::vec3(0, 0, 1));
+			}
+			
+			
 		}
 
 		if (((y * 100) / cv_normals.rows) > percentage) {
@@ -925,8 +967,8 @@ void createMesh(cv::Mat cv_depth, cv::Mat cv_normals, std::vector<glm::vec3> & o
 
 	percentage = 0;
 
-	for (int y = 0; y < (cv_normals.rows - 1); y++) {
-		for (int x = 0; x < (cv_normals.cols - 1); x++) {
+	for (int y = 0; y < cv_normals.rows; y++) {
+		for (int x = 0; x < cv_normals.cols; x++) {
 			out_indices.push_back(int((y * cv_normals.cols) + x));
 			out_indices.push_back(int((y * cv_normals.cols) + x + 1));
 			out_indices.push_back(int(((y + 1) * cv_normals.cols) + x + 1));
diff --git a/apps/specular_estimation/src/specular_estimation.cc b/apps/specular_estimation/src/specular_estimation.cc
index 398f1cac74ebbee74d598a12e267df4224767350..c1402490dd11c0f015c70c1982c33c717899d48b 100644
--- a/apps/specular_estimation/src/specular_estimation.cc
+++ b/apps/specular_estimation/src/specular_estimation.cc
@@ -125,21 +125,21 @@ int main(int argc, char** argv) {
 	const double initial_x = x;
 
 	// Build the problem.
-	Problem problem;
+	ceres::Problem problem;
 	
 	
-	computeResiduals(residual, residuals, totalResidual, residualImage, calculateResidual, depthProjectionMatrix, depthViewMatrix, width, height, position, horizontalAngle, verticalAngle, FoV, lightInvDir, lightDirections, textureImages, lightNumber, numberOfLights, SpecularIntensityID, SpecularIntensity, SpecularPowerID, SpecularPower, programID, ModelMatrixID, ViewMatrixID, DepthBiasID, lightInvDirID, Texture, TextureID, depthTexture, ShadowMapID, vertexbuffer, uvbuffer, normalbuffer, elementbuffer, indices, MatrixID);
+	computeResiduals(residual, residuals, totalResidual, residualImage, calculateResidual, depthProjectionMatrix, depthViewMatrix, width, height, position, horizontalAngle, verticalAngle, FoV, lightInvDir, lightDirections, textureImages, lightNumber, numberOfLights, SpecularIntensityID, SpecularIntensity, SpecularPowerID, SpecularPower, programID, ModelMatrixID, ViewMatrixID, DepthBiasID, lightInvDirID, Texture, TextureID, depthTexture, ShadowMapID, vertexbuffer, uvbuffer, normalbuffer, elementbuffer, indices, MatrixID, modelPath, x, problem);
+	
 	
-	/*
 	// Run the solver!
-	Solver::Options options;
+	ceres::Solver::Options options;
 	options.minimizer_progress_to_stdout = true;
-	Solver::Summary summary;
+	ceres::Solver::Summary summary;
 	Solve(options, &problem, &summary);
 
 	std::cout << summary.BriefReport() << "\n";
 	std::cout << "Specular Intensity: " << initial_x << " -> " << x << "\n";
-	*/
+	
 	viewModel(residual, residuals, totalResidual, residualImage, calculateResidual, depthProjectionMatrix, depthViewMatrix, width, height, position, horizontalAngle, verticalAngle, FoV, lightInvDir, lightDirections, textureImages, lightNumber, numberOfLights, SpecularIntensityID, SpecularIntensity, SpecularPowerID, SpecularPower, programID, ModelMatrixID, ViewMatrixID, DepthBiasID, lightInvDirID, Texture, TextureID, depthTexture, ShadowMapID, vertexbuffer, uvbuffer, normalbuffer, elementbuffer, indices, MatrixID);
 	
 	terminateOpenGL(vertexbuffer, uvbuffer, normalbuffer, elementbuffer, programID, depthProgramID, quad_programID, Texture, FramebufferName, depthTexture, quad_vertexbuffer, VertexArrayID);
diff --git a/bin/specular_estimation b/bin/specular_estimation
index 4a95a202c60708a5dad29013c3a0586597fb01b3..d8732b5fe59385b7670f751a94007db5ba9753f0 100755
Binary files a/bin/specular_estimation and b/bin/specular_estimation differ