diff --git a/src/software/pipeline/main_LdrToHdrMerge.cpp b/src/software/pipeline/main_LdrToHdrMerge.cpp index 4eff179e68..57df18e83f 100644 --- a/src/software/pipeline/main_LdrToHdrMerge.cpp +++ b/src/software/pipeline/main_LdrToHdrMerge.cpp @@ -37,17 +37,17 @@ using namespace aliceVision; namespace po = boost::program_options; namespace fs = boost::filesystem; -std::string getHdrImagePath(const std::string& outputPath, std::size_t g, const std::string& rootname = "") +std::string getHdrImagePath(const std::string& outputPath, std::size_t g, const std::string& rootname = "", bool macbeth = false) { // Output image file path std::stringstream sstream; if (rootname == "") { - sstream << "hdr_" << std::setfill('0') << std::setw(4) << g << ".exr"; + sstream << "hdr_" << std::setfill('0') << std::setw(4) << g << (macbeth ? "_macbeth" : "") << ".exr"; } else { - sstream << rootname << ".exr"; + sstream << rootname << (macbeth ? "_macbeth" : "") << ".exr"; } const std::string hdrImagePath = (fs::path(outputPath) / sstream.str()).string(); return hdrImagePath; @@ -354,7 +354,7 @@ int aliceVision_main(int argc, char** argv) std::shared_ptr hdrView; const auto & group = groups[g]; - + if (group.size() == 1) { hdrView = std::make_shared(*group.at(0)); @@ -370,8 +370,18 @@ int aliceVision_main(int argc, char** argv) } if (!byPass) { - boost::filesystem::path p(targetViews[g]->getImagePath()); - const std::string hdrImagePath = getHdrImagePath(outputPath, pos, keepSourceImageName ? p.stem().string() : ""); + bool macbeth = false; + for(int k = 0; k < group.size(); k++) + { + const std::string fname = group[k]->getImagePath(); + boost::filesystem::path p(fname); + macbeth = macbeth || (p.stem().string().find("_macbeth") != std::string::npos); + } + const std::string tgt_name = targetViews[g]->getImagePath(); + macbeth = macbeth && ((tgt_name.find("_macbeth") == std::string::npos) || !keepSourceImageName); + + boost::filesystem::path p(tgt_name); + const std::string hdrImagePath = getHdrImagePath(outputPath, pos, keepSourceImageName ? p.stem().string() : "", macbeth); hdrView->setImagePath(hdrImagePath); } hdrView->addMetadata("AliceVision:ColorSpace", image::EImageColorSpace_enumToString(mergedColorSpace)); @@ -427,11 +437,14 @@ int aliceVision_main(int argc, char** argv) std::shared_ptr targetView = targetViews[g]; std::vector exposuresSetting(group.size()); + bool macbeth = false; // Load all images of the group for(std::size_t i = 0; i < group.size(); ++i) { const std::string filepath = group[i]->getImagePath(); ALICEVISION_LOG_INFO("Load " << filepath); + boost::filesystem::path p(filepath); + macbeth = macbeth || (p.stem().string().find("_macbeth") != std::string::npos); image::ImageReadOptions options; options.workingColorSpace = workingColorSpace; @@ -493,7 +506,8 @@ int aliceVision_main(int argc, char** argv) } boost::filesystem::path p(targetView->getImagePath()); - const std::string hdrImagePath = getHdrImagePath(outputPath, pos, keepSourceImageName ? p.stem().string() : ""); + macbeth = macbeth && ((p.stem().string().find("_macbeth") == std::string::npos) || !keepSourceImageName); + const std::string hdrImagePath = getHdrImagePath(outputPath, pos, keepSourceImageName ? p.stem().string() : "", macbeth); // Write an image with parameters from the target view std::map viewMetadata = targetView->getMetadata(); diff --git a/src/software/utils/main_colorCheckerDetection.cpp b/src/software/utils/main_colorCheckerDetection.cpp index 79c65d2943..6f0055a314 100644 --- a/src/software/utils/main_colorCheckerDetection.cpp +++ b/src/software/utils/main_colorCheckerDetection.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -406,6 +407,8 @@ int aliceVision_main(int argc, char** argv) // user optional parameters bool debug = false; unsigned int maxCountByImage = 1; + bool processAllImages = true; + std::string filter = "*_macbeth.*"; po::options_description inputParams("Required parameters"); inputParams.add_options() @@ -416,8 +419,11 @@ int aliceVision_main(int argc, char** argv) po::options_description optionalParams("Optional parameters"); optionalParams.add_options() - ("debug", po::value(&debug), - "Output debug data.") + ("debug", po::value(&debug), "Output debug data.") + ("processAllImages", po::value(&processAllImages)->default_value(processAllImages), + "If True, process all available images.") + ("filter", po::value(&filter)->default_value(filter), + "Regular expression to select images to be processed.") ("maxCount", po::value(&maxCountByImage), "Maximum color charts count to detect in a single image."); @@ -458,17 +464,20 @@ int aliceVision_main(int argc, char** argv) { const sfmData::View& view = *(viewIt.second); - ALICEVISION_LOG_INFO(++counter << "/" << sfmData.getViews().size() << " - Process image at: '" << view.getImagePath() << "'."); - ImageOptions imgOpt = { - view.getImagePath(), - std::to_string(view.getViewId()), - view.getMetadataBodySerialNumber(), - view.getMetadataLensSerialNumber() }; - imgOpt.readOptions.workingColorSpace = image::EImageColorSpace::SRGB; - imgOpt.readOptions.rawColorInterpretation = image::ERawColorInterpretation_stringToEnum(view.getRawColorInterpretation()); - detectColorChecker(detectedCCheckers, imgOpt, settings); + boost::filesystem::path p(view.getImagePath()); + const std::regex regex = utils::filterToRegex(filter); + if(processAllImages || std::regex_match(p.generic_string(), regex)) + { + ALICEVISION_LOG_INFO(++counter << "/" << sfmData.getViews().size() << " - Process image at: '" + << view.getImagePath() << "'."); + ImageOptions imgOpt = {view.getImagePath(), std::to_string(view.getViewId()), + view.getMetadataBodySerialNumber(), view.getMetadataLensSerialNumber()}; + imgOpt.readOptions.workingColorSpace = image::EImageColorSpace::SRGB; + imgOpt.readOptions.rawColorInterpretation = + image::ERawColorInterpretation_stringToEnum(view.getRawColorInterpretation()); + detectColorChecker(detectedCCheckers, imgOpt, settings); + } } - } else { @@ -509,11 +518,16 @@ int aliceVision_main(int argc, char** argv) int counter = 0; for(const std::string& imgSrcPath : filesStrPaths) { - ALICEVISION_LOG_INFO(++counter << "/" << size << " - Process image at: '" << imgSrcPath << "'."); - ImageOptions imgOpt; - imgOpt.imgFsPath = imgSrcPath; - imgOpt.readOptions.workingColorSpace = image::EImageColorSpace::SRGB; - detectColorChecker(detectedCCheckers, imgOpt, settings); + boost::filesystem::path p(imgSrcPath); + const std::regex regex = utils::filterToRegex(filter); + if(processAllImages || std::regex_match(p.generic_string(), regex)) + { + ALICEVISION_LOG_INFO(++counter << "/" << size << " - Process image at: '" << imgSrcPath << "'."); + ImageOptions imgOpt; + imgOpt.imgFsPath = imgSrcPath; + imgOpt.readOptions.workingColorSpace = image::EImageColorSpace::SRGB; + detectColorChecker(detectedCCheckers, imgOpt, settings); + } } }