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

Fix crash when output extension is missing in image processing #1395

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/aliceVision/image/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void readImage(const std::string& path,
}
}

ALICEVISION_LOG_INFO("Neutral from camera = {" << neutral[0] << ", " << neutral[1] << ", " << neutral[2] << "}");
ALICEVISION_LOG_TRACE("Neutral from camera = {" << neutral[0] << ", " << neutral[1] << ", " << neutral[2] << "}");

// libRAW configuration
// See https://openimageio.readthedocs.io/en/master/builtinplugins.html#raw-digital-camera-files
Expand Down Expand Up @@ -607,7 +607,7 @@ void readImage(const std::string& path,
neutral[i] = v_mult[i] / v_mult[1];
}

ALICEVISION_LOG_INFO("Apply DCP Linear processing with neutral = " << neutral);
ALICEVISION_LOG_TRACE("Apply DCP Linear processing with neutral = " << neutral);

dcpProfile.applyLinear(inBuf, neutral, imageReadOptions.doWBAfterDemosaicing, imageReadOptions.useDCPColorMatrixOnly);
}
Expand Down
20 changes: 10 additions & 10 deletions src/software/utils/main_imageProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,14 @@ int aliceVision_main(int argc, char * argv[])
const std::string viewPath = viewIt.second;
sfmData::View& view = sfmData.getView(viewId);

const std::unique_ptr<oiio::ImageInput> in(oiio::ImageInput::open(viewPath));
const std::string imgFormat = in->format_name();
const bool isRAW = imgFormat.compare("raw") == 0;

const fs::path fsPath = viewPath;
const std::string fileName = fsPath.stem().string();
const std::string fileExt = fsPath.extension().string();
const std::string outputExt = extension.empty() ? fileExt : (std::string(".") + extension);
const std::string outputExt = extension.empty() ? (isRAW ? ".exr" : fileExt) : (std::string(".") + extension);
const std::string outputfilePath = (fs::path(outputPath) / ((pParams.keepImageFilename ? fileName : std::to_string(viewId)) + outputExt)).generic_string();

ALICEVISION_LOG_INFO(++i << "/" << size << " - Process view '" << viewId << "'.");
Expand All @@ -1003,10 +1007,6 @@ int aliceVision_main(int argc, char * argv[])
ALICEVISION_LOG_WARNING("A dcp profile will be applied on an image containing non raw data!");
}

const std::unique_ptr<oiio::ImageInput> in(oiio::ImageInput::open(viewPath));
const std::string imgFormat = in->format_name();
const bool isRAW = imgFormat.compare("raw") == 0;

image::ImageReadOptions options;
options.workingColorSpace = pParams.applyDcpMetadata ? image::EImageColorSpace::NO_CONVERSION : workingColorSpace;

Expand Down Expand Up @@ -1157,10 +1157,14 @@ int aliceVision_main(int argc, char * argv[])
int i = 0;
for (const std::string& inputFilePath : filesStrPaths)
{
const std::unique_ptr<oiio::ImageInput> in(oiio::ImageInput::open(inputFilePath));
const std::string imgFormat = in->format_name();
const bool isRAW = imgFormat.compare("raw") == 0;

const fs::path path = fs::path(inputFilePath);
const std::string filename = path.stem().string();
const std::string fileExt = path.extension().string();
const std::string outputExt = extension.empty() ? fileExt : (std::string(".") + extension);
const std::string outputExt = extension.empty() ? (isRAW ? ".exr" : fileExt) : (std::string(".") + extension);

ALICEVISION_LOG_INFO(++i << "/" << size << " - Process image '" << filename << fileExt << "'.");

Expand Down Expand Up @@ -1191,10 +1195,6 @@ int aliceVision_main(int argc, char * argv[])
const auto metadata = image::readImageMetadata(inputFilePath, width, height);
view.setMetadata(image::getMapFromMetadata(metadata));

const std::unique_ptr<oiio::ImageInput> in(oiio::ImageInput::open(inputFilePath));
const std::string imgFormat = in->format_name();
const bool isRAW = imgFormat.compare("raw") == 0;

if (isRAW && (rawColorInterpretation == image::ERawColorInterpretation::DcpLinearProcessing ||
rawColorInterpretation == image::ERawColorInterpretation::DcpMetadata))
{
Expand Down