From ef5ac6633e74a4524f90cb82dd3eebb5f58fde7a Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Tue, 16 Jun 2020 17:56:59 +0200 Subject: [PATCH 1/6] [depthMap] add metadata "nbDepthValues" This metadata was only exported after depth map filter, now it is also exported after depth map estimation. --- src/aliceVision/depthMap/DepthSimMap.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/aliceVision/depthMap/DepthSimMap.cpp b/src/aliceVision/depthMap/DepthSimMap.cpp index f78f1794e5..d155fbdccb 100644 --- a/src/aliceVision/depthMap/DepthSimMap.cpp +++ b/src/aliceVision/depthMap/DepthSimMap.cpp @@ -401,8 +401,10 @@ void DepthSimMap::save(int rc, const StaticVector& tcams) const int width = mp->getWidth(rc) / scale; const int height = mp->getHeight(rc) / scale; + const int nbDepthValues = std::count_if(depthMap->begin(), depthMap->end(), [](float v) { return v > 0.0f; }); oiio::ParamValueList metadata = imageIO::getMetadataFromMap(mp->getMetadata(rc)); + metadata.push_back(oiio::ParamValue("AliceVision:nbDepthValues", oiio::TypeDesc::INT32, 1, &nbDepthValues)); metadata.push_back(oiio::ParamValue("AliceVision:downscale", mp->getDownscaleFactor(rc))); metadata.push_back(oiio::ParamValue("AliceVision:CArr", oiio::TypeDesc(oiio::TypeDesc::DOUBLE, oiio::TypeDesc::VEC3), 1, mp->CArr[rc].m)); metadata.push_back(oiio::ParamValue("AliceVision:iCamArr", oiio::TypeDesc(oiio::TypeDesc::DOUBLE, oiio::TypeDesc::MATRIX33), 1, mp->iCamArr[rc].m)); From 3ab6f30c81991e7fdbe3e917e5a47d583d664e26 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Tue, 16 Jun 2020 17:58:09 +0200 Subject: [PATCH 2/6] [fuseCut] Add metadata min/maxDepth Add missing metadata after depth map filter. --- src/aliceVision/fuseCut/Fuser.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/aliceVision/fuseCut/Fuser.cpp b/src/aliceVision/fuseCut/Fuser.cpp index 74ed496ff0..cf13199ba1 100644 --- a/src/aliceVision/fuseCut/Fuser.cpp +++ b/src/aliceVision/fuseCut/Fuser.cpp @@ -302,7 +302,13 @@ bool Fuser::filterDepthMapsRC(int rc, int minNumOfModals, int minNumOfModalsWSP2 metadata.push_back(oiio::ParamValue("AliceVision:downscale", mp->getDownscaleFactor(rc))); metadata.push_back(oiio::ParamValue("AliceVision:CArr", oiio::TypeDesc(oiio::TypeDesc::DOUBLE, oiio::TypeDesc::VEC3), 1, mp->CArr[rc].m)); metadata.push_back(oiio::ParamValue("AliceVision:iCamArr", oiio::TypeDesc(oiio::TypeDesc::DOUBLE, oiio::TypeDesc::MATRIX33), 1, mp->iCamArr[rc].m)); - + { + float minDepth, maxDepth, midDepth; + size_t nbDepths; + mp->getMinMaxMidNbDepth(rc, minDepth, maxDepth, midDepth, nbDepths); + metadata.push_back(oiio::ParamValue("AliceVision:maxDepth", maxDepth)); + metadata.push_back(oiio::ParamValue("AliceVision:minDepth", minDepth)); + } { std::vector matrixP = mp->getOriginalP(rc); metadata.push_back(oiio::ParamValue("AliceVision:P", oiio::TypeDesc(oiio::TypeDesc::DOUBLE, oiio::TypeDesc::MATRIX44), 1, matrixP.data())); From ce9c463b9e1f8a95f8715ceb4ff55dc8180d524d Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Tue, 16 Jun 2020 17:59:26 +0200 Subject: [PATCH 3/6] [fuseCut] avoid failure if nModMap files are missing --- src/aliceVision/fuseCut/DelaunayGraphCut.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp index 6133fb0142..4090f296d7 100644 --- a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp +++ b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp @@ -889,9 +889,20 @@ void DelaunayGraphCut::fuseFromDepthMaps(const StaticVector& cams, const Po } const std::string nmodMapFilepath = getFileNameFromIndex(mp, c, mvsUtils::EFileType::nmodMap, 0); - imageIO::readImage(nmodMapFilepath, wTmp, hTmp, numOfModalsMap, imageIO::EImageColorSpace::NO_CONVERSION); - if(wTmp != width || hTmp != height) - throw std::runtime_error("Wrong nmod map dimensions: " + nmodMapFilepath); + // If we have an nModMap in input (from depthmapfilter) use it, + // else init with a constant value. + if(boost::filesystem::exists(nmodMapFilepath)) + { + imageIO::readImage(nmodMapFilepath, wTmp, hTmp, numOfModalsMap, + imageIO::EImageColorSpace::NO_CONVERSION); + if(wTmp != width || hTmp != height) + throw std::runtime_error("Wrong nmod map dimensions: " + nmodMapFilepath); + } + else + { + ALICEVISION_LOG_WARNING("nModMap file can't be found."); + numOfModalsMap.resize(width*height, 1); + } } int syMax = std::ceil(height/step); From f8109b0ba4b47eb2bf95850cdaae8d6efdac1a64 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Tue, 16 Jun 2020 18:00:35 +0200 Subject: [PATCH 4/6] [software] Meshing: use only one depth map folder input --- src/aliceVision/mvsUtils/MultiViewParams.cpp | 5 ++++- src/software/pipeline/main_meshing.cpp | 10 +++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/aliceVision/mvsUtils/MultiViewParams.cpp b/src/aliceVision/mvsUtils/MultiViewParams.cpp index b850dac794..bd324af46a 100644 --- a/src/aliceVision/mvsUtils/MultiViewParams.cpp +++ b/src/aliceVision/mvsUtils/MultiViewParams.cpp @@ -65,7 +65,10 @@ MultiViewParams::MultiViewParams(const sfmData::SfMData& sfmData, if(readFromDepthMaps) { - path = getFileNameFromViewId(this, view.getViewId(), mvsUtils::EFileType::depthMap, 1); + // use output of DepthMapFilter if scale==0 + // use output of DepthMap if scale==1 + const int scale = (depthMapsFolder.empty() ? 0 : 1); + path = getFileNameFromViewId(this, view.getViewId(), mvsUtils::EFileType::depthMap, scale); } else if(_imagesFolder != "/" && !_imagesFolder.empty() && fs::is_directory(_imagesFolder) && !fs::is_empty(_imagesFolder)) { diff --git a/src/software/pipeline/main_meshing.cpp b/src/software/pipeline/main_meshing.cpp index e87ee1dfd3..9e07d65621 100644 --- a/src/software/pipeline/main_meshing.cpp +++ b/src/software/pipeline/main_meshing.cpp @@ -139,7 +139,6 @@ int aliceVision_main(int argc, char* argv[]) std::string outputMesh; std::string outputDensePointCloud; std::string depthMapsFolder; - std::string depthMapsFilterFolder; EPartitioningMode partitioningMode = ePartitioningSingleBlock; ERepartitionMode repartitionMode = eRepartitionMultiResolution; std::size_t estimateSpaceMinObservations = 3; @@ -168,8 +167,6 @@ int aliceVision_main(int argc, char* argv[]) po::options_description optionalParams("Optional parameters"); optionalParams.add_options() ("depthMapsFolder", po::value(&depthMapsFolder), - "Input depth maps folder.") - ("depthMapsFilterFolder", po::value(&depthMapsFilterFolder), "Input filtered depth maps folder.") ("maxInputPoints", po::value(&fuseParams.maxInputPoints)->default_value(fuseParams.maxInputPoints), "Max input points loaded from images.") @@ -262,10 +259,9 @@ int aliceVision_main(int argc, char* argv[]) // set verbose level system::Logger::get()->setLogLevel(verboseLevel); - if(depthMapsFolder.empty() || depthMapsFilterFolder.empty()) + if(depthMapsFolder.empty()) { if(depthMapsFolder.empty() && - depthMapsFilterFolder.empty() && repartitionMode == eRepartitionMultiResolution && partitioningMode == ePartitioningSingleBlock) { @@ -275,7 +271,7 @@ int aliceVision_main(int argc, char* argv[]) else { ALICEVISION_LOG_ERROR("Invalid input options:\n" - "- Meshing from depth maps require --depthMapsFolder and --depthMapsFilterFolder options.\n" + "- Meshing from depth maps require --depthMapsFolder option.\n" "- Meshing from SfM require option --partitioning set to 'singleBlock' and option --repartition set to 'multiResolution'."); return EXIT_FAILURE; } @@ -290,7 +286,7 @@ int aliceVision_main(int argc, char* argv[]) } // initialization - mvsUtils::MultiViewParams mp(sfmData, "", depthMapsFolder, depthMapsFilterFolder, meshingFromDepthMaps); + mvsUtils::MultiViewParams mp(sfmData, "", "", depthMapsFolder, meshingFromDepthMaps); mp.userParams.put("LargeScale.universePercentile", universePercentile); From 94e7c658558d2495078f34416f82628145f34deb Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Wed, 17 Jun 2020 10:42:26 +0200 Subject: [PATCH 5/6] [fuseCut] convert Histogram LOG_INFO into LOG_TRACE Conversion of the histogram LOG_INFO to LOG_TRACE for more clarity in the information panel. --- src/aliceVision/fuseCut/DelaunayGraphCut.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp index 4090f296d7..be6da5c0cb 100644 --- a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp +++ b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp @@ -494,15 +494,15 @@ void DelaunayGraphCut::displayStatistics() // Display some statistics StaticVector* ptsCamsHist = getPtsCamsHist(); - ALICEVISION_LOG_INFO("Histogram of number of cams per point:"); + ALICEVISION_LOG_TRACE("Histogram of number of cams per point:"); for(int i = 0; i < ptsCamsHist->size(); ++i) - ALICEVISION_LOG_INFO(" " << i << ": " << mvsUtils::num2str((*ptsCamsHist)[i])); + ALICEVISION_LOG_TRACE(" " << i << ": " << mvsUtils::num2str((*ptsCamsHist)[i])); delete ptsCamsHist; StaticVector* ptsNrcsHist = getPtsNrcHist(); - ALICEVISION_LOG_INFO("Histogram of Nrc per point:"); + ALICEVISION_LOG_TRACE("Histogram of Nrc per point:"); for(int i = 0; i < ptsNrcsHist->size(); ++i) - ALICEVISION_LOG_INFO(" " << i << ": " << mvsUtils::num2str((*ptsNrcsHist)[i])); + ALICEVISION_LOG_TRACE(" " << i << ": " << mvsUtils::num2str((*ptsNrcsHist)[i])); delete ptsNrcsHist; } From 47c25ccde71638663289791b48051d92e4075795 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Thu, 18 Jun 2020 16:22:37 +0200 Subject: [PATCH 6/6] [Software] update binary version --- src/software/pipeline/main_meshing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/software/pipeline/main_meshing.cpp b/src/software/pipeline/main_meshing.cpp index 9e07d65621..8f19bfb0c7 100644 --- a/src/software/pipeline/main_meshing.cpp +++ b/src/software/pipeline/main_meshing.cpp @@ -27,7 +27,7 @@ // These constants define the current software version. // They must be updated when the command line is changed. -#define ALICEVISION_SOFTWARE_VERSION_MAJOR 3 +#define ALICEVISION_SOFTWARE_VERSION_MAJOR 4 #define ALICEVISION_SOFTWARE_VERSION_MINOR 0 using namespace aliceVision;