From ca49c0bdfda62130d280f82390cb349b1112fa67 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 22 Jul 2022 03:46:20 +0300 Subject: [PATCH 1/3] [mvsUtils] Remove FileExists which is wrapper for boost::filesystem --- src/aliceVision/depthMap/depthMap.cpp | 6 +++++- src/aliceVision/fuseCut/Fuser.cpp | 2 +- src/aliceVision/fuseCut/LargeScale.cpp | 2 +- src/aliceVision/fuseCut/ReconstructionPlan.cpp | 10 +++++----- src/aliceVision/fuseCut/VoxelsGrid.cpp | 10 +++++----- src/aliceVision/mvsUtils/MultiViewParams.cpp | 4 ++-- src/aliceVision/mvsUtils/fileIO.cpp | 5 ----- src/aliceVision/mvsUtils/fileIO.hpp | 1 - 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/aliceVision/depthMap/depthMap.cpp b/src/aliceVision/depthMap/depthMap.cpp index bbf4f8c011..0675f63c3d 100644 --- a/src/aliceVision/depthMap/depthMap.cpp +++ b/src/aliceVision/depthMap/depthMap.cpp @@ -16,6 +16,10 @@ #include #include +#include + +namespace fs = boost::filesystem; + namespace aliceVision { namespace depthMap { @@ -120,7 +124,7 @@ void computeNormalMaps(int cudaDeviceIndex, mvsUtils::MultiViewParams& mp, const { const std::string normalMapFilepath = getFileNameFromIndex(mp, rc, mvsUtils::EFileType::normalMap, 0); - if(!mvsUtils::FileExists(normalMapFilepath)) + if (!fs::exists(normalMapFilepath)) { std::vector depthMap; int w = 0; diff --git a/src/aliceVision/fuseCut/Fuser.cpp b/src/aliceVision/fuseCut/Fuser.cpp index 46423dacea..561939cc02 100644 --- a/src/aliceVision/fuseCut/Fuser.cpp +++ b/src/aliceVision/fuseCut/Fuser.cpp @@ -149,7 +149,7 @@ void Fuser::filterGroups(const std::vector& cams, float pixToleranceFactor, // minNumOfModals number of other cams including this cam ... minNumOfModals /in 2,3,... bool Fuser::filterGroupsRC(int rc, float pixToleranceFactor, int pixSizeBall, int pixSizeBallWSP, int nNearestCams) { - if(mvsUtils::FileExists(getFileNameFromIndex(_mp, rc, mvsUtils::EFileType::nmodMap))) + if (bfs::exists(getFileNameFromIndex(_mp, rc, mvsUtils::EFileType::nmodMap))) { return true; } diff --git a/src/aliceVision/fuseCut/LargeScale.cpp b/src/aliceVision/fuseCut/LargeScale.cpp index 6aaef0db55..33ba78be1f 100644 --- a/src/aliceVision/fuseCut/LargeScale.cpp +++ b/src/aliceVision/fuseCut/LargeScale.cpp @@ -35,7 +35,7 @@ LargeScale::~LargeScale() bool LargeScale::isSpaceSaved() { - return mvsUtils::FileExists(spaceFileName); + return bfs::exists(spaceFileName); } void LargeScale::saveSpaceToFile() diff --git a/src/aliceVision/fuseCut/ReconstructionPlan.cpp b/src/aliceVision/fuseCut/ReconstructionPlan.cpp index f52c054722..9579038796 100644 --- a/src/aliceVision/fuseCut/ReconstructionPlan.cpp +++ b/src/aliceVision/fuseCut/ReconstructionPlan.cpp @@ -257,7 +257,7 @@ StaticVector*>* loadLargeScalePtsCams(const std::vector& recsDirs, StaticVecto std::string filePtsCamsFromDCTName = folderName + "meshPtsCamsFromDGC.bin"; - if(!mvsUtils::FileExists(filePtsCamsFromDCTName)) + if (!bfs::exists(filePtsCamsFromDCTName)) { throw std::runtime_error("Missing file: " + filePtsCamsFromDCTName); } @@ -324,7 +324,7 @@ mesh::Mesh* joinMeshes(const std::vector& recsDirs, StaticVectorloadFromBin(fileName); @@ -360,7 +360,7 @@ mesh::Mesh* joinMeshes(const std::vector& recsDirs, StaticVectorloadFromBin(fileName); @@ -376,7 +376,7 @@ mesh::Mesh* joinMeshes(const std::vector& recsDirs, StaticVector* ptsColsi = loadArrayFromFile(fileName); StaticVector* trisColsi = getTrisColorsRgb(mei, ptsColsi); diff --git a/src/aliceVision/fuseCut/VoxelsGrid.cpp b/src/aliceVision/fuseCut/VoxelsGrid.cpp index 2329e5c125..a293d2c769 100644 --- a/src/aliceVision/fuseCut/VoxelsGrid.cpp +++ b/src/aliceVision/fuseCut/VoxelsGrid.cpp @@ -162,7 +162,7 @@ StaticVector* VoxelsGrid::loadTracksFromVoxelFiles(S const std::string fileNameTracksPtsCams = folderName + "tracksGridPtsCams.bin"; const std::string fileNameTracksStat = folderName + "tracksGridStat.bin"; - if(!mvsUtils::FileExists(fileNameTracksPts)) + if (!bfs::exists(fileNameTracksPts)) return nullptr; StaticVector* tracksStat = loadArrayFromFile(fileNameTracksStat); // minPixSize, minSim, npts @@ -384,7 +384,7 @@ void VoxelsGrid::generateSpace(VoxelsGrid* vgnew, const Voxel& LU, const Voxel& Voxel subRD = LU + (v + 1) * ns; // if (FolderExists(subfn)==true) - if(mvsUtils::FileExists(subfnFileMark)) + if (bfs::exists(subfnFileMark)) { VoxelsGrid* vgrec = new VoxelsGrid(Voxel(2, 2, 2), &(*voxels)[voxid * 8], mp, subfn, doVisualize); vgrec->generateSpace(vgnew, subLU, subRD, depthMapsPtsSimsTmpDir); @@ -479,7 +479,7 @@ void VoxelsGrid::cloneSpaceVoxel(int voxelId, int numSubVoxs, VoxelsGrid* newSpa std::string folderName = getVoxelFolderName(voxelId); std::string fileNameTracksPts = folderName + "tracksGridPts.bin"; - if(mvsUtils::FileExists(fileNameTracksPts)) + if (bfs::exists(fileNameTracksPts)) { OctreeTracks* ott = new OctreeTracks(&(*voxels)[voxelId * 8], mp, Voxel(numSubVoxs, numSubVoxs, numSubVoxs)); @@ -525,7 +525,7 @@ void VoxelsGrid::copySpaceVoxel(int voxelId, VoxelsGrid* newSpace) std::string folderName = getVoxelFolderName(voxelId); std::string fileNameTracksPts = folderName + "tracksGridPts.bin"; - if(mvsUtils::FileExists(fileNameTracksPts)) + if (bfs::exists(fileNameTracksPts)) { StaticVector* tcams; StaticVector* tracksOld = loadTracksFromVoxelFiles(&tcams, voxelId); @@ -579,7 +579,7 @@ void VoxelsGrid::generateCamsPtsFromVoxelsTracks() // printf("SAVING %i-th VOXEL POINTS TO CAMS FILES\n",i); - if(mvsUtils::FileExists(fileNameTracksPts)) + if (bfs::exists(fileNameTracksPts)) { StaticVector* tracksPoints = loadArrayFromFile(fileNameTracksPts); StaticVector*>* tracksPointsCams = diff --git a/src/aliceVision/mvsUtils/MultiViewParams.cpp b/src/aliceVision/mvsUtils/MultiViewParams.cpp index 0aceb65277..ca41f2bced 100644 --- a/src/aliceVision/mvsUtils/MultiViewParams.cpp +++ b/src/aliceVision/mvsUtils/MultiViewParams.cpp @@ -232,7 +232,7 @@ MultiViewParams::MultiViewParams(const sfmData::SfMData& sfmData, void MultiViewParams::loadMatricesFromTxtFile(int index, const std::string& fileNameP, const std::string& fileNameD) { - if(!FileExists(fileNameP)) + if (!fs::exists(fileNameP)) throw std::runtime_error(std::string("mv_multiview_params: no such file: ") + fileNameP); FILE* f = fopen(fileNameP.c_str(), "r"); @@ -268,7 +268,7 @@ void MultiViewParams::loadMatricesFromTxtFile(int index, const std::string& file iRArr[index] = RArr[index].inverse(); iCamArr[index] = iRArr[index] * iKArr[index]; - if(FileExists(fileNameD)) + if (fs::exists(fileNameD)) { FILE* f = fopen(fileNameD.c_str(), "r"); fscanf(f, "%f %f %f", &FocK1K2Arr[index].x, &FocK1K2Arr[index].y, &FocK1K2Arr[index].z); diff --git a/src/aliceVision/mvsUtils/fileIO.cpp b/src/aliceVision/mvsUtils/fileIO.cpp index 0505caec97..666110645b 100644 --- a/src/aliceVision/mvsUtils/fileIO.cpp +++ b/src/aliceVision/mvsUtils/fileIO.cpp @@ -17,11 +17,6 @@ namespace aliceVision { namespace mvsUtils { -bool FileExists(const std::string& filePath) -{ - return boost::filesystem::exists(filePath); -} - bool FolderExists(const std::string& folderPath) { return boost::filesystem::is_directory(folderPath); diff --git a/src/aliceVision/mvsUtils/fileIO.hpp b/src/aliceVision/mvsUtils/fileIO.hpp index 41fe6dac88..df4ea6f01f 100644 --- a/src/aliceVision/mvsUtils/fileIO.hpp +++ b/src/aliceVision/mvsUtils/fileIO.hpp @@ -25,7 +25,6 @@ namespace oiio = OIIO; namespace aliceVision { namespace mvsUtils { -bool FileExists(const std::string& filePath); bool FolderExists(const std::string& folderPath); std::string getFileNameFromViewId(const MultiViewParams& mp, int viewId, EFileType fileType, int scale = 0, const std::string& customSuffix = ""); From 2ce85a0ecbd79416bae3cdc02990a289dd83d6ef Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 22 Jul 2022 03:46:21 +0300 Subject: [PATCH 2/3] [mvsUtils] Remove FolderExists which is wrapper for boost::filesystem --- src/aliceVision/fuseCut/Fuser.cpp | 2 +- src/aliceVision/fuseCut/VoxelsGrid.cpp | 10 +++++----- src/aliceVision/mvsUtils/fileIO.cpp | 5 ----- src/aliceVision/mvsUtils/fileIO.hpp | 2 -- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/aliceVision/fuseCut/Fuser.cpp b/src/aliceVision/fuseCut/Fuser.cpp index 561939cc02..30e89a2e34 100644 --- a/src/aliceVision/fuseCut/Fuser.cpp +++ b/src/aliceVision/fuseCut/Fuser.cpp @@ -733,7 +733,7 @@ std::string generateTempPtsSimsFiles(std::string tmpDir, mvsUtils::MultiViewPara ALICEVISION_LOG_INFO("generating temp files."); std::string depthMapsPtsSimsTmpDir = tmpDir + "depthMapsPtsSimsTmp/"; - if(!mvsUtils::FolderExists(depthMapsPtsSimsTmpDir)) + if (!bfs::is_directory(depthMapsPtsSimsTmpDir)) { bfs::create_directory(depthMapsPtsSimsTmpDir); diff --git a/src/aliceVision/fuseCut/VoxelsGrid.cpp b/src/aliceVision/fuseCut/VoxelsGrid.cpp index a293d2c769..6d1681d000 100644 --- a/src/aliceVision/fuseCut/VoxelsGrid.cpp +++ b/src/aliceVision/fuseCut/VoxelsGrid.cpp @@ -142,11 +142,11 @@ std::string VoxelsGrid::getVoxelFolderName(int id) const std::string fnxyz = spaceRootDir + "X" + mvsUtils::num2str(v.x) + "Y" + mvsUtils::num2str(v.y) + "Z" + mvsUtils::num2str(v.z) + "/"; // bfs::create_directory(fnxyz); - // if (FolderExists(fnx)==false) { + // if (bfs::is_directory(fnx)==false) { // printf("Warning folder %s does not exist!\n",fnx.c_str()); //} - // if (FolderExists(fnxyz)==false) { + // if (bfs::is_directory(fnxyz)==false) { // printf("Warning folder %s does not exist!\n",fnxyz.c_str()); //} @@ -203,7 +203,7 @@ bool VoxelsGrid::saveTracksToVoxelFiles(StaticVector* cams, StaticVector Date: Fri, 22 Jul 2022 03:46:22 +0300 Subject: [PATCH 3/3] [mvsUtils] Remove DeleteDirectory which is wrapper for boost::filesystem --- src/aliceVision/fuseCut/Fuser.cpp | 2 +- src/aliceVision/fuseCut/LargeScale.cpp | 2 +- src/aliceVision/mvsUtils/fileIO.cpp | 6 ------ src/aliceVision/mvsUtils/fileIO.hpp | 2 -- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/aliceVision/fuseCut/Fuser.cpp b/src/aliceVision/fuseCut/Fuser.cpp index 30e89a2e34..ed0b5330f0 100644 --- a/src/aliceVision/fuseCut/Fuser.cpp +++ b/src/aliceVision/fuseCut/Fuser.cpp @@ -902,7 +902,7 @@ void deleteTempPtsSimsFiles(mvsUtils::MultiViewParams& mp, std::string depthMaps remove(ptsfn.c_str()); remove(simsfn.c_str()); } - mvsUtils::DeleteDirectory(depthMapsPtsSimsTmpDir); + bfs::remove_all(depthMapsPtsSimsTmpDir); } } // namespace fuseCut diff --git a/src/aliceVision/fuseCut/LargeScale.cpp b/src/aliceVision/fuseCut/LargeScale.cpp index 33ba78be1f..dd19355d6b 100644 --- a/src/aliceVision/fuseCut/LargeScale.cpp +++ b/src/aliceVision/fuseCut/LargeScale.cpp @@ -190,7 +190,7 @@ bool LargeScale::generateSpace(int maxPts, int ocTreeDim, bool generateTracks) delete vgnew; delete vg; - mvsUtils::DeleteDirectory(tmpdir); + bfs::remove_all(tmpdir); deleteTempPtsSimsFiles(*mp, depthMapsPtsSimsTmpDir); diff --git a/src/aliceVision/mvsUtils/fileIO.cpp b/src/aliceVision/mvsUtils/fileIO.cpp index e0b840c216..2f217713c9 100644 --- a/src/aliceVision/mvsUtils/fileIO.cpp +++ b/src/aliceVision/mvsUtils/fileIO.cpp @@ -376,11 +376,5 @@ void loadImage(const std::string& path, const MultiViewParams& mp, int camId, Im template void loadImage(const std::string& path, const MultiViewParams& mp, int camId, ImageRGBf& img, imageIO::EImageColorSpace colorspace, ECorrectEV correctEV); template void loadImage(const std::string& path, const MultiViewParams& mp, int camId, ImageRGBAf& img, imageIO::EImageColorSpace colorspace, ECorrectEV correctEV); -bool DeleteDirectory(const std::string& sPath) -{ - boost::filesystem::remove_all(sPath); - return true; -} - } // namespace mvsUtils } // namespace aliceVision diff --git a/src/aliceVision/mvsUtils/fileIO.hpp b/src/aliceVision/mvsUtils/fileIO.hpp index 0371de58b6..a9ab32f004 100644 --- a/src/aliceVision/mvsUtils/fileIO.hpp +++ b/src/aliceVision/mvsUtils/fileIO.hpp @@ -37,7 +37,5 @@ template void loadImage(const std::string& path, const MultiViewParams& mp, int camId, Image& img, imageIO::EImageColorSpace colorspace, ECorrectEV correctEV); -bool DeleteDirectory(const std::string& sPath); - } // namespace mvsUtils } // namespace aliceVision