From 538f8be5e7d34a75f1cbc9fb5fa711e5364d23eb Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Mon, 14 Sep 2020 22:25:23 +0200 Subject: [PATCH 1/2] [image] storageDataType: use lowerCamelCase --- src/aliceVision/image/io.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index 8d505264db..25dbe9eb8d 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -127,10 +127,10 @@ std::string EStorageDataType_enumToString(const EStorageDataType dataType) { switch (dataType) { - case EStorageDataType::Float: return "Float"; - case EStorageDataType::Half: return "Half"; - case EStorageDataType::HalfFinite: return "HalfFinite"; - case EStorageDataType::Auto: return "Auto"; + case EStorageDataType::Float: return "float"; + case EStorageDataType::Half: return "half"; + case EStorageDataType::HalfFinite: return "halfFinite"; + case EStorageDataType::Auto: return "auto"; } throw std::out_of_range("Invalid EStorageDataType enum"); } From 910edf7ae22a5cd96a7cbf95202b3f5f60bb617a Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Mon, 14 Sep 2020 22:25:58 +0200 Subject: [PATCH 2/2] [software] imageProcessing: add storageDataType option --- src/software/utils/main_imageProcessing.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/software/utils/main_imageProcessing.cpp b/src/software/utils/main_imageProcessing.cpp index 3a822933a2..cc5eea581b 100644 --- a/src/software/utils/main_imageProcessing.cpp +++ b/src/software/utils/main_imageProcessing.cpp @@ -455,12 +455,14 @@ void processImage(image::Image& image, const ProcessingParams void saveImage(image::Image& image, const std::string& inputPath, const std::string& outputPath, const std::vector& metadataFolders, - const EImageFormat& outputFormat) + const EImageFormat outputFormat, const image::EStorageDataType storageDataType) { // Read metadata path std::string metadataFilePath; const std::string filename = fs::path(inputPath).filename().string(); + const std::string outExtension = boost::to_lower_copy(fs::path(outputPath).extension().string()); + const bool isEXR = (outExtension == ".exr"); // If metadataFolders is specified if(!metadataFolders.empty()) { @@ -496,7 +498,13 @@ void saveImage(image::Image& image, const std::string& inputP metadataFilePath = inputPath; } - const oiio::ParamValueList metadata = image::readImageMetadata(metadataFilePath); + oiio::ParamValueList metadata = image::readImageMetadata(metadataFilePath); + + if(isEXR) + { + // Select storage data type + metadata.push_back(oiio::ParamValue("AliceVision:storageDataType", image::EStorageDataType_enumToString(storageDataType))); + } // Save image ALICEVISION_LOG_TRACE("Export image: '" << outputPath << "'."); @@ -528,6 +536,7 @@ int aliceVision_main(int argc, char * argv[]) std::vector metadataFolders; std::string outputPath; EImageFormat outputFormat = EImageFormat::RGBA; + image::EStorageDataType storageDataType = image::EStorageDataType::Float; std::string extension; ProcessingParams pParams; @@ -603,6 +612,9 @@ int aliceVision_main(int argc, char * argv[]) ("outputFormat", po::value(&outputFormat)->default_value(outputFormat), "Output image format (rgba, rgb, grayscale)") + + ("storageDataType", po::value(&storageDataType)->default_value(storageDataType), + ("Storage data type: " + image::EStorageDataType_informations()).c_str()) ("extension", po::value(&extension)->default_value(extension), "Output image extension (like exr, or empty to keep the source file format.") @@ -760,7 +772,7 @@ int aliceVision_main(int argc, char * argv[]) processImage(image, pParams); // Save the image - saveImage(image, viewPath, outputfilePath, metadataFolders, outputFormat); + saveImage(image, viewPath, outputfilePath, metadataFolders, outputFormat, storageDataType); // Update view for this modification view.setImagePath(outputfilePath); @@ -855,7 +867,7 @@ int aliceVision_main(int argc, char * argv[]) processImage(image, pParams); // Save the image - saveImage(image, inputFilePath, outputFilePath, metadataFolders, outputFormat); + saveImage(image, inputFilePath, outputFilePath, metadataFolders, outputFormat, storageDataType); } }