Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCP error management #1328

Merged
merged 2 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/aliceVision/image/dcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/software/pipeline/main_LdrToHdrMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<int>(&channelQuantizationPower)->default_value(channelQuantizationPower),
"Quantization level like 8 bits or 10 bits.")
("workingColorSpace", po::value<image::EImageColorSpace>(&workingColorSpace)->default_value(workingColorSpace),
("Working color space: " + image::EImageColorSpace_informations()).c_str())
("fusionWeight,W", po::value<hdr::EFunctionType>(&fusionWeightFunction)->default_value(fusionWeightFunction),
"Weight function used to fuse all LDR images together (gaussian, triangle, plateau).")
("offsetRefBracketIndex", po::value<int>(&offsetRefBracketIndex)->default_value(offsetRefBracketIndex),
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/software/pipeline/main_LdrToHdrSampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -75,6 +76,8 @@ int aliceVision_main(int argc, char** argv)
"bracket count per HDR image (0 means automatic).")
("channelQuantizationPower", po::value<int>(&channelQuantizationPower)->default_value(channelQuantizationPower),
"Quantization level like 8 bits or 10 bits.")
("workingColorSpace", po::value<image::EImageColorSpace>(&workingColorSpace)->default_value(workingColorSpace),
("Working color space: " + image::EImageColorSpace_informations()).c_str())
("blockSize", po::value<int>(&params.blockSize)->default_value(params.blockSize),
"Size of the image tile to extract a sample.")
("radius", po::value<int>(&params.radius)->default_value(params.radius),
Expand Down Expand Up @@ -209,7 +212,7 @@ int aliceVision_main(int argc, char** argv)
std::vector<double> exposures = getExposures(exposuresSetting);

image::ImageReadOptions imgReadOptions;
imgReadOptions.workingColorSpace = image::EImageColorSpace::SRGB;
imgReadOptions.workingColorSpace = workingColorSpace;
imgReadOptions.rawColorInterpretation = rawColorInterpretation;
imgReadOptions.colorProfileFileName = colorProfileFileName;

Expand Down
27 changes: 21 additions & 6 deletions src/software/pipeline/main_cameraInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -452,6 +452,8 @@ int aliceVision_main(int argc, char **argv)

std::string imgFormat = in->format_name();

bool dcpError = false;
demoulinv marked this conversation as resolved.
Show resolved Hide resolved

// 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 ||
demoulinv marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -465,7 +467,7 @@ int aliceVision_main(int argc, char **argv)
// No color profile available
boost::atomic_ref<char>{allColorProfilesFound} = 0;
}
else if (!dcpDatabase.empty())
else if (!dcpDatabase.empty() || (dcpDatabase.empty() && !errorOnMissingColorProfile))
demoulinv marked this conversation as resolved.
Show resolved Hide resolved
{
image::DCPProfile dcpProf;

Expand All @@ -476,17 +478,29 @@ int aliceVision_main(int argc, char **argv)
#pragma omp critical
viewsWithDCPMetadata++;
}
else if (allColorProfilesFound)
else
{
// there is a missing color profile for one image or more
boost::atomic_ref<char>{allColorProfilesFound} = 0;
dcpError = true;
if (allColorProfilesFound)
{
// there is a missing color profile for one image or more
boost::atomic_ref<char>{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));
ALICEVISION_LOG_WARNING("DCP Profile not found. Use LibRawWhiteBalancing option for raw color processing.");
demoulinv marked this conversation as resolved.
Show resolved Hide resolved
}

// check if the view intrinsic is already defined
if(intrinsicId != UndefinedIndexT)
Expand Down Expand Up @@ -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.");
}
}

Expand Down