From 84e6baa218b686fdeb76f5a1e9885925b6a3ed34 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Fri, 16 Dec 2022 18:57:42 +0100 Subject: [PATCH 1/3] [image] raw io: use librawwhitebalancing by default --- src/aliceVision/image/io.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aliceVision/image/io.hpp b/src/aliceVision/image/io.hpp index 6523e197d1..8a647a51dc 100644 --- a/src/aliceVision/image/io.hpp +++ b/src/aliceVision/image/io.hpp @@ -182,7 +182,7 @@ std::istream& operator>>(std::istream& in, EImageQuality& imageQuality); struct ImageReadOptions { ImageReadOptions(EImageColorSpace colorSpace = EImageColorSpace::AUTO, - ERawColorInterpretation rawColorInterpretation = ERawColorInterpretation::Auto, + ERawColorInterpretation rawColorInterpretation = ERawColorInterpretation::LibRawWhiteBalancing, const std::string& colorProfile = "", const oiio::ROI& roi = oiio::ROI()) : workingColorSpace(colorSpace), rawColorInterpretation(rawColorInterpretation), colorProfileFileName(colorProfile), subROI(roi) { From 946e2c6785463b2dc15e7fa315343fab801095d2 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Fri, 16 Dec 2022 18:58:19 +0100 Subject: [PATCH 2/3] [image] raw io: throw an error if we are in an undefined case --- src/aliceVision/image/io.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index aff065e627..fff458612b 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -499,6 +499,10 @@ void readImage(const std::string& path, configSpec.attribute("raw:ColorSpace", "raw"); // use raw data configSpec.attribute("raw:HighlightMode", 1); // unclip } + else + { + ALICEVISION_THROW_ERROR("[image] readImage: invalid rawColorInterpretation " << ERawColorInterpretation_enumToString(imageReadOptions.rawColorInterpretation) << "."); + } } oiio::ImageBuf inBuf(path, 0, 0, NULL, &configSpec); From 286560018e2f241e28ef62a99bf2c5388f77ae48 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Fri, 16 Dec 2022 18:59:30 +0100 Subject: [PATCH 3/3] [software] CameraInit: set the metadata in the main loop to avoid an extra loop on views --- src/software/pipeline/main_cameraInit.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/software/pipeline/main_cameraInit.cpp b/src/software/pipeline/main_cameraInit.cpp index 283962485c..40d14b0e04 100644 --- a/src/software/pipeline/main_cameraInit.cpp +++ b/src/software/pipeline/main_cameraInit.cpp @@ -484,6 +484,10 @@ int aliceVision_main(int argc, char **argv) } } + // 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)); + // check if the view intrinsic is already defined if(intrinsicId != UndefinedIndexT) { @@ -847,15 +851,6 @@ int aliceVision_main(int argc, char **argv) return EXIT_FAILURE; } - // Add the white balance option to the image metadata - for (auto vitem : sfmData.getViews()) - { - if (vitem.second) - { - vitem.second->addMetadata("AliceVision:rawColorInterpretation", image::ERawColorInterpretation_enumToString(rawColorInterpretation)); - } - } - // store SfMData views & intrinsic data if(!Save(sfmData, outputFilePath, ESfMData(VIEWS|INTRINSICS|EXTRINSICS))) {