diff --git a/src/aliceVision/image/dcp.cpp b/src/aliceVision/image/dcp.cpp index 093c649712..8950196cca 100644 --- a/src/aliceVision/image/dcp.cpp +++ b/src/aliceVision/image/dcp.cpp @@ -955,8 +955,7 @@ void DCPProfile::Load(const std::string& filename) if (file == nullptr) { - ALICEVISION_LOG_WARNING("Unable to load DCP profile " << filename); - return; + ALICEVISION_THROW_ERROR("Unable to load DCP profile " << filename); } // read tiff header diff --git a/src/software/pipeline/main_LdrToHdrMerge.cpp b/src/software/pipeline/main_LdrToHdrMerge.cpp index 76e7bedef0..879c9c3bf5 100644 --- a/src/software/pipeline/main_LdrToHdrMerge.cpp +++ b/src/software/pipeline/main_LdrToHdrMerge.cpp @@ -54,6 +54,7 @@ int aliceVision_main(int argc, char** argv) int nbBrackets = 3; bool byPass = false; int channelQuantizationPower = 10; + image::EImageColorSpace workingColorSpace = image::EImageColorSpace::SRGB; int offsetRefBracketIndex = 0; hdr::EFunctionType fusionWeightFunction = hdr::EFunctionType::GAUSSIAN; @@ -83,6 +84,8 @@ int aliceVision_main(int argc, char** argv) "bypass HDR creation and use medium bracket as input for next steps") ("channelQuantizationPower", po::value(&channelQuantizationPower)->default_value(channelQuantizationPower), "Quantization level like 8 bits or 10 bits.") + ("workingColorSpace", po::value(&workingColorSpace)->default_value(workingColorSpace), + ("Working color space: " + image::EImageColorSpace_informations()).c_str()) ("fusionWeight,W", po::value(&fusionWeightFunction)->default_value(fusionWeightFunction), "Weight function used to fuse all LDR images together (gaussian, triangle, plateau).") ("offsetRefBracketIndex", po::value(&offsetRefBracketIndex)->default_value(offsetRefBracketIndex), @@ -253,7 +256,7 @@ int aliceVision_main(int argc, char** argv) ALICEVISION_LOG_INFO("Load " << filepath); image::ImageReadOptions options; - options.workingColorSpace = image::EImageColorSpace::SRGB; + options.workingColorSpace = workingColorSpace; options.rawColorInterpretation = image::ERawColorInterpretation_stringToEnum(group[i]->getRawColorInterpretation()); options.colorProfileFileName = group[i]->getColorProfileFileName(); image::readImage(filepath, images[i], options); diff --git a/src/software/pipeline/main_LdrToHdrSampling.cpp b/src/software/pipeline/main_LdrToHdrSampling.cpp index 1c492b7416..e412d64a91 100644 --- a/src/software/pipeline/main_LdrToHdrSampling.cpp +++ b/src/software/pipeline/main_LdrToHdrSampling.cpp @@ -54,6 +54,7 @@ int aliceVision_main(int argc, char** argv) std::string outputFolder; int nbBrackets = 0; int channelQuantizationPower = 10; + image::EImageColorSpace workingColorSpace = image::EImageColorSpace::SRGB; hdr::Sampling::Params params; bool debug = false; @@ -75,6 +76,8 @@ int aliceVision_main(int argc, char** argv) "bracket count per HDR image (0 means automatic).") ("channelQuantizationPower", po::value(&channelQuantizationPower)->default_value(channelQuantizationPower), "Quantization level like 8 bits or 10 bits.") + ("workingColorSpace", po::value(&workingColorSpace)->default_value(workingColorSpace), + ("Working color space: " + image::EImageColorSpace_informations()).c_str()) ("blockSize", po::value(¶ms.blockSize)->default_value(params.blockSize), "Size of the image tile to extract a sample.") ("radius", po::value(¶ms.radius)->default_value(params.radius), @@ -209,7 +212,7 @@ int aliceVision_main(int argc, char** argv) std::vector exposures = getExposures(exposuresSetting); image::ImageReadOptions imgReadOptions; - imgReadOptions.workingColorSpace = image::EImageColorSpace::SRGB; + imgReadOptions.workingColorSpace = workingColorSpace; imgReadOptions.rawColorInterpretation = rawColorInterpretation; imgReadOptions.colorProfileFileName = colorProfileFileName; diff --git a/src/software/pipeline/main_cameraInit.cpp b/src/software/pipeline/main_cameraInit.cpp index 40d14b0e04..8893a47896 100644 --- a/src/software/pipeline/main_cameraInit.cpp +++ b/src/software/pipeline/main_cameraInit.cpp @@ -162,7 +162,7 @@ int aliceVision_main(int argc, char **argv) bool allowSingleView = false; bool errorOnMissingColorProfile = true; - image::ERawColorInterpretation rawColorInterpretation = image::ERawColorInterpretation::LibRawNoWhiteBalancing; + image::ERawColorInterpretation rawColorInterpretation = image::ERawColorInterpretation::LibRawWhiteBalancing; po::options_description requiredParams("Required parameters"); @@ -452,6 +452,8 @@ int aliceVision_main(int argc, char **argv) std::string imgFormat = in->format_name(); + bool dcpError = true; + // if a color profile is required check if a dcp database exists and if one is available inside // if yes and if metadata exist and image format is raw then update metadata with DCP info if((rawColorInterpretation == image::ERawColorInterpretation::DcpLinearProcessing || @@ -465,28 +467,40 @@ int aliceVision_main(int argc, char **argv) // No color profile available boost::atomic_ref{allColorProfilesFound} = 0; } - else if (!dcpDatabase.empty()) + else { image::DCPProfile dcpProf; - if (dcpDatabase.getDcpForCamera(make, model, dcpProf)) + if (!dcpDatabase.empty() && dcpDatabase.getDcpForCamera(make, model, dcpProf)) { view.addDCPMetadata(dcpProf); #pragma omp critical viewsWithDCPMetadata++; + + dcpError = false; } else if (allColorProfilesFound) { - // there is a missing color profile for one image or more + // there is a missing color profile for at least one image boost::atomic_ref{allColorProfilesFound} = 0; } + } } // Store the color interpretation mode choosed for raw images in metadata, // so all future loads of this image will be interpreted in the same way. - view.addMetadata("AliceVision:rawColorInterpretation", image::ERawColorInterpretation_enumToString(rawColorInterpretation)); + if (!dcpError) + { + view.addMetadata("AliceVision:rawColorInterpretation", image::ERawColorInterpretation_enumToString(rawColorInterpretation)); + } + else + { + view.addMetadata("AliceVision:rawColorInterpretation", image::ERawColorInterpretation_enumToString(image::ERawColorInterpretation::LibRawWhiteBalancing)); + if (!dcpDatabase.empty()) + ALICEVISION_LOG_WARNING("DCP Profile not found for image: " << view.getImagePath() << ". Use LibRawWhiteBalancing option for raw color processing."); + } // check if the view intrinsic is already defined if(intrinsicId != UndefinedIndexT) @@ -752,6 +766,7 @@ int aliceVision_main(int argc, char **argv) else { ALICEVISION_LOG_WARNING("Can't find color profile for at least one input image."); + ALICEVISION_LOG_WARNING("Images without color profiles have been decoded with the LibRawWhiteBalancing option."); } }