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 8af3decdfcf0ad4177b41bb2147107c08d6bd064..6366ea4e3572f96d965170748cf00a206f339372 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/OpenCV.h b/apps/specular_estimation/src/OpenCV.h index c67582c885f923b63275e640fd21a9a88a84b739..3dc886c3bbffb82b026a827974ac1f490d2ef6a2 100644 --- a/apps/specular_estimation/src/OpenCV.h +++ b/apps/specular_estimation/src/OpenCV.h @@ -306,8 +306,8 @@ cv::Vec3f getLightDirectionFromSphere(cv::Mat Image, cv::Rect boundingBox) { cv::Point center(int(m.m10 / m.m00), int(m.m01 / m.m00)); // x,y are swapped here // TODO check if necessary - float x = (center.y - radius) / radius; - float y = (center.x - radius) / radius; + float x = (center.x - radius) / radius; + float y = (center.y - radius) / radius; float z = sqrt(1.0f - pow(x, 2.0f) - pow(y, 2.0f)); return cv::Vec3f(x, y, z); diff --git a/apps/specular_estimation/src/OpenGL.h b/apps/specular_estimation/src/OpenGL.h index e584df01284c11a1f37291a84912fd16808909a4..4cb103a2e93ffe9b128e3dc42a858b30c1a4a2aa 100644 --- a/apps/specular_estimation/src/OpenGL.h +++ b/apps/specular_estimation/src/OpenGL.h @@ -762,7 +762,6 @@ void computeMatricesFromLights(int windowWidth, int windowHeight, glm::vec3& pos modifier = 0.01f; } - 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) { @@ -773,7 +772,6 @@ void computeMatricesFromLights(int windowWidth, int windowHeight, glm::vec3& pos else { lightNumber = numberOfLights - 1; } - lightInvDir = glm::vec3(lightDirections.at<float>(lightNumber, 1), -lightDirections.at<float>(lightNumber, 0), lightDirections.at<float>(lightNumber, 2)); calculateResidual = true; } } @@ -785,10 +783,13 @@ void computeMatricesFromLights(int windowWidth, int windowHeight, glm::vec3& pos else { lightNumber = 0; } - lightInvDir = glm::vec3(lightDirections.at<float>(lightNumber, 1), -lightDirections.at<float>(lightNumber, 0), lightDirections.at<float>(lightNumber, 2)); calculateResidual = true; } } + + lightInvDir = glm::vec3(lightDirections.at<float>(lightNumber, 0), -lightDirections.at<float>(lightNumber, 2), lightDirections.at<float>(lightNumber, 1)); + //lightInvDir = glm::vec3(lightDirections.at<float>(lightNumber, 0), lightDirections.at<float>(lightNumber, 1), lightDirections.at<float>(lightNumber, 2)); + // Modify specular power if (glfwGetKey(window, GLFW_KEY_7) == GLFW_PRESS) { diff --git a/apps/specular_estimation/src/specular_estimation.cc b/apps/specular_estimation/src/specular_estimation.cc index 2e9284fc80b1c60c3a1616bb44c859979718e6ba..fb416b479c8b4e9858f49ab3ead2304216de7b00 100644 --- a/apps/specular_estimation/src/specular_estimation.cc +++ b/apps/specular_estimation/src/specular_estimation.cc @@ -135,8 +135,11 @@ int main(int argc, char** argv) { cv::waitKey(0); //normalMap.convertTo(normalMap, CV_8UC1); - texture.convertTo(texture, CV_8UC1); + + cv::cvtColor(texture, texture, CV_GRAY2BGR); + texture.convertTo(texture, CV_8UC3); + //texture.convertTo(texture, CV_GRAY2BGR); //normalAlbedo.convertTo(normalAlbedo, CV_8UC3); @@ -198,19 +201,23 @@ int main(int argc, char** argv) { double totalResidual, residualValue, SpecularIntensity = 0.5, SpecularPower = 2.0; cv::Mat residualImage; - /*lightDirections = (Mat_<double>(3,3) << 0.447712 << 0.138562 << 0.883377 - cv::invert(L, lightDirectionsInverted, cv::DECOMP_SVD); + cv::Mat lightDirectionsInverted; + //lightDirections = (cv::Mat_<double>(6,3) << 0.447712, 0.883377, 0.138562, 0.228758, 0.967636, -0.106536, 0.1, 0.99248, 0.0705882, 0.000653595, 0.997412, -0.0718954, -0.139216, 0.982279, -0.12549, -0.494771, 0.861376, 0.115033); + cv::invert(lightDirections, lightDirectionsInverted, cv::DECOMP_SVD); + + /* + std::vector<glm::vec3> lightInvDirs; + lightInvDirs.push_back(glm::vec3(0.447712, 0.138562, 0.883377)); + lightInvDirs.push_back(glm::vec3(0.228758, -0.106536, 0.967636)); + lightInvDirs.push_back(glm::vec3(0.1, 0.0705882, 0.99248)); + lightInvDirs.push_back(glm::vec3(0.000653595, -0.0718954, 0.997412)); + lightInvDirs.push_back(glm::vec3(-0.139216, -0.12549, 0.982279)); + lightInvDirs.push_back(glm::vec3(-0.494771, 0.115033, 0.861376)); + */ - lightInvDirs.push_back(phoSte::light(0.447712, 0.138562, 0.883377)); - lightInvDirs.push_back(phoSte::light(0.228758, -0.106536, 0.967636)); - lightInvDirs.push_back(phoSte::light(0.1, 0.0705882, 0.99248)); - lightInvDirs.push_back(phoSte::light(0.000653595, -0.0718954, 0.997412)); - lightInvDirs.push_back(phoSte::light(-0.139216, -0.12549, 0.982279)); - lightInvDirs.push_back(phoSte::light(-0.494771, 0.115033, 0.861376));*/ - std::vector<glm::vec3> lightInvDirs; for (int i = 0; i < numberOfLights; i++) - lightInvDirs.push_back(glm::vec3(lightDirections.at<float>(i, 1), -lightDirections.at<float>(i, 0), lightDirections.at<float>(i, 2))); + lightInvDirs.push_back(glm::vec3(lightDirections.at<float>(i, 0), -lightDirections.at<float>(i, 2), lightDirections.at<float>(i, 1))); initialiseOpenGL(heightMap, normalMap, texture, textureImages, lightDirections, width, height, depthProjectionMatrix, depthViewMatrix, position, horizontalAngle, verticalAngle, FoV, lightInvDir, programID, MatrixID, ModelMatrixID, ViewMatrixID, DepthBiasID, lightInvDirID, Texture, TextureID, depthTexture, ShadowMapID, vertexbuffer, uvbuffer, normalbuffer, elementbuffer, indices, depthProgramID, quad_programID, FramebufferName, quad_vertexbuffer, VertexArrayID, SpecularIntensityID, SpecularIntensity, SpecularPowerID, SpecularPower, numberOfLights, calculateResidual, depthMVP, depthModelMatrix, MVP, ProjectionMatrix, ViewMatrix, ModelMatrix, depthBiasMVP, biasMatrix); diff --git a/bin/specular_estimation b/bin/specular_estimation index efa94b177119278adadeafefb949cb6cb69f1a91..24ec1e8dbaf9d4d69c72a136c58bd0ebb3a7045a 100755 Binary files a/bin/specular_estimation and b/bin/specular_estimation differ