From be8a855a54c470771b497d820aa1222b826f4c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Wed, 10 Jan 2024 15:00:12 +0000 Subject: [PATCH 1/2] [imageSegmentation] Add option to keep input filename. --- .../pipeline/main_imageSegmentation.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/software/pipeline/main_imageSegmentation.cpp b/src/software/pipeline/main_imageSegmentation.cpp index b2f2ef7f9f..047c91791f 100644 --- a/src/software/pipeline/main_imageSegmentation.cpp +++ b/src/software/pipeline/main_imageSegmentation.cpp @@ -23,6 +23,7 @@ #include // IO +#include #include #include #include @@ -39,6 +40,7 @@ using namespace aliceVision; namespace po = boost::program_options; +namespace fs = std::filesystem; void imageToPlanes(std::vector & output, const image::Image::Base & source) { @@ -91,6 +93,7 @@ int aliceVision_main(int argc, char** argv) int rangeStart = -1; int rangeSize = 1; bool useGpu = true; + bool keepFilename = false; // Description of mandatory parameters po::options_description requiredParams("Required parameters"); @@ -107,10 +110,12 @@ int aliceVision_main(int argc, char** argv) "Invert mask values. If selected, the pixels corresponding to the mask will be set to 0.0 instead of 1.0.") ("useGpu", po::value(&useGpu)->default_value(useGpu), "Use GPU if available.") + ("keepFilename", po::value(&keepFilename)->default_value(keepFilename), + "Keep input filename.") ("rangeStart", po::value(&rangeStart)->default_value(rangeStart), - "Range start for processing views (ordered by image filepath). Set to -1 to process all images.") + "Range start for processing views (ordered by image filepath). Set to -1 to process all images.") ("rangeSize", po::value(&rangeSize)->default_value(rangeSize), - "Range size for processing views (ordered by image filepath)."); + "Range size for processing views (ordered by image filepath)."); CmdLine cmdline("AliceVision imageSegmentation"); cmdline.add(requiredParams); @@ -215,6 +220,9 @@ int aliceVision_main(int argc, char** argv) std::string path = view->getImage().getImagePath(); ALICEVISION_LOG_INFO("processing " << path); + const fs::path fsPath = path; + const std::string fileName = fsPath.stem().string(); + image::Image image; image::readImage(path, image, image::EImageColorSpace::SRGB); @@ -260,7 +268,15 @@ int aliceVision_main(int argc, char** argv) // Store image std::stringstream ss; - ss << outputPath << "/" << view->getViewId() << ".exr"; + if (keepFilename) + { + ss << outputPath << "/" << fileName << ".exr"; + } + else + { + ss << outputPath << "/" << view->getViewId() << ".exr"; + } + image::writeImage(ss.str(), mask, image::ImageWriteOptions()); } From 8988fadbc6ccb8c4f5586d5ac081557a71125e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Wed, 10 Jan 2024 15:00:53 +0000 Subject: [PATCH 2/2] [software] ImageSegmentation: Update version minor --- src/software/pipeline/main_imageSegmentation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/software/pipeline/main_imageSegmentation.cpp b/src/software/pipeline/main_imageSegmentation.cpp index 047c91791f..92296ca007 100644 --- a/src/software/pipeline/main_imageSegmentation.cpp +++ b/src/software/pipeline/main_imageSegmentation.cpp @@ -35,7 +35,7 @@ // These constants define the current software version. // They must be updated when the command line is changed. #define ALICEVISION_SOFTWARE_VERSION_MAJOR 1 -#define ALICEVISION_SOFTWARE_VERSION_MINOR 1 +#define ALICEVISION_SOFTWARE_VERSION_MINOR 2 using namespace aliceVision;