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

New LDR2HDR software #613

Merged
merged 24 commits into from
Jun 17, 2019
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
616a990
[hdr] New HDR module with Robertson calibration
ToukL Mar 28, 2019
f5b58d7
[software] New software for fusion of LDR images into HDR
ToukL Mar 28, 2019
66ab190
[hdr] add some arguments for HDR software
ToukL Mar 29, 2019
ca10227
[WIP] add Debevec algorithm
ToukL Apr 5, 2019
1bc7cc2
[hdr] add Grossberg algorithm
ToukL May 24, 2019
9996e35
[hdr] Add some parameters
ToukL Jun 3, 2019
ff885e8
[hdr] Fix Grossberg algorithm
ToukL Jun 3, 2019
850ed41
[hdr] Adapt weight curves to method
ToukL Jun 7, 2019
eeaf1c4
[hdr] Visual Studio build fixes
fabiencastan Jun 10, 2019
b9b0c7c
[cmake] new option ALICEVISION_BUILD_HDR
fabiencastan Jun 10, 2019
f808396
[image] clean log + remove unused code
ToukL Jun 11, 2019
44402a3
[hdr] rename arguments and add options
ToukL Jun 12, 2019
40a9ba2
[raw] bug fix: can now read several images in folder
ToukL Jun 12, 2019
45e1865
[hdr] add log infos and raw extensions
ToukL Jun 13, 2019
dacdbc6
[hdr] bug fix: can take input camera response instead of calibration
ToukL Jun 13, 2019
eb19a70
[hdr] add doxygen doc and correct some parameters
ToukL Jun 13, 2019
b1c7a2c
[hdr] add argument to recover the target source image
ToukL Jun 13, 2019
c2742eb
[hdr] correct some infos
ToukL Jun 14, 2019
9ce0481
[hdr] delete old file
ToukL Jun 14, 2019
7f4db7d
[hdr] correct codacy issues
ToukL Jun 14, 2019
cc41fa0
[hdr] correct codacy issue
ToukL Jun 14, 2019
050de85
[hdr] change cout to log info
ToukL Jun 14, 2019
f006315
[hdr] separate calibration method argument and input response file
ToukL Jun 14, 2019
a37b54c
[hdr] add log info and remove goto
ToukL Jun 14, 2019
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
90 changes: 46 additions & 44 deletions src/software/convert/main_convertLDRToHDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace fs = boost::filesystem;

enum class ECalibrationMethod
{
NONE,
LINEAR,
ROBERTSON,
DEBEVEC,
Expand All @@ -51,7 +50,6 @@ inline std::string ECalibrationMethod_enumToString(const ECalibrationMethod cali
{
switch(calibrationMethod)
{
case ECalibrationMethod::NONE: return "none";
case ECalibrationMethod::LINEAR: return "linear";
case ECalibrationMethod::ROBERTSON: return "robertson";
case ECalibrationMethod::DEBEVEC: return "debevec";
Expand Down Expand Up @@ -140,7 +138,8 @@ int main(int argc, char** argv)
std::vector<std::string> imagesFolder;
std::string outputHDRImagePath;
std::string outputResponsePath;
std::string responseCalibrationName = ECalibrationMethod_enumToString(ECalibrationMethod::LINEAR);
ECalibrationMethod calibrationMethod = ECalibrationMethod::LINEAR;
std::string inputResponsePath;
std::string calibrationWeightFunction = "default";
hdr::EFunctionType fusionWeightFunction = hdr::EFunctionType::GAUSSIAN;
std::string target;
Expand All @@ -160,8 +159,10 @@ int main(int argc, char** argv)
optionalParams.add_options()
("outputResponse", po::value<std::string>(&outputResponsePath),
"output response function path.")
("responseCalibration,r", po::value<std::string>(&responseCalibrationName )->default_value(responseCalibrationName ),
"method used for camera calibration (linear, robertson, debevec) or provide an external response file directly.")
("calibrationMethod,m", po::value<ECalibrationMethod>(&calibrationMethod )->default_value(calibrationMethod ),
"method used for camera calibration (linear, robertson, debevec).")
("inputResponse,r", po::value<std::string>(&inputResponsePath ),
"external camera response file path to fuse all LDR images together.")
("calibrationWeight,w", po::value<std::string>(&calibrationWeightFunction)->default_value(calibrationWeightFunction),
"weight function type (default, gaussian, triangle, plateau).")
("fusionWeight,W", po::value<hdr::EFunctionType>(&fusionWeightFunction)->default_value(fusionWeightFunction),
Expand Down Expand Up @@ -217,17 +218,15 @@ int main(int argc, char** argv)
std::vector<float> &ldrTimes = times.at(0);
// std::vector<float> &ldrEv = ev.at(0);

// set the correct calibration method corresponding to the string parameter
ECalibrationMethod calibrationMethod;
// read teh input response fiel or set the correct channel quantization according to the calibration method used
std::size_t channelQuantization;
if(fs::is_regular_file(fs::path(responseCalibrationName)))
if(!inputResponsePath.empty())
{
response = hdr::rgbCurve(responseCalibrationName); // use the camera response function set in "responseCalibration", calibrationMethod is set to "none"
response = hdr::rgbCurve(inputResponsePath); // use the camera response function set in "responseCalibration", calibrationMethod is set to "none"
channelQuantization = response.getSize();
}
else
{
calibrationMethod = ECalibrationMethod_stringToEnum(responseCalibrationName);
if(calibrationMethod == ECalibrationMethod::GROSSBERG)
channelQuantization = std::pow(2, 10); //RAW 10 bit precision, 2^10 values between black and white point
else
Expand All @@ -248,7 +247,6 @@ int main(int argc, char** argv)
{
switch(calibrationMethod)
{
case ECalibrationMethod::NONE: break;
case ECalibrationMethod::LINEAR: break;
case ECalibrationMethod::DEBEVEC: calibrationWeight.setTriangular();
case ECalibrationMethod::ROBERTSON: calibrationWeight.setRobertsonWeight();
Expand Down Expand Up @@ -399,52 +397,56 @@ int main(int argc, char** argv)
image::Image<image::RGBfColor> image(ldrImages.at(0).Width(), ldrImages.at(0).Height(), false);

// calculate the response function according to the method given in argument or take the response provided by the user
switch(calibrationMethod)
if(!inputResponsePath.empty())
{
goto MERGE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use goto.

}
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(inputResponsePath.empty())

{
case ECalibrationMethod::NONE:
switch(calibrationMethod)
{
case ECalibrationMethod::LINEAR:
{
// set the response function to linear
response.setLinear();
}
break;
}
case ECalibrationMethod::LINEAR:
{
// set the response function to linear
response.setLinear();
}
break;

case ECalibrationMethod::DEBEVEC:
{
case ECalibrationMethod::DEBEVEC:
{
ALICEVISION_LOG_INFO("Debevec calibration");
const float lambda = channelQuantization * 1.f;
const int nbPoints = 1000;
hdr::DebevecCalibrate calibration;
calibration.process(ldrImageGroups, channelQuantization, times, nbPoints, calibrationWeight, lambda, response);
const float lambda = channelQuantization * 1.f;
const int nbPoints = 1000;
hdr::DebevecCalibrate calibration;
calibration.process(ldrImageGroups, channelQuantization, times, nbPoints, calibrationWeight, lambda, response);

response.exponential();
response.scale();
}
break;
response.exponential();
response.scale();
}
break;

case ECalibrationMethod::ROBERTSON:
{
case ECalibrationMethod::ROBERTSON:
{
ALICEVISION_LOG_INFO("Robertson calibration");
hdr::RobertsonCalibrate calibration(40);
const int nbPoints = 1000000;
calibration.process(ldrImageGroups_sorted, channelQuantization, times_sorted, nbPoints, calibrationWeight, targetTime, response);
response.scale();
}
break;
hdr::RobertsonCalibrate calibration(40);
const int nbPoints = 1000000;
calibration.process(ldrImageGroups_sorted, channelQuantization, times_sorted, nbPoints, calibrationWeight, targetTime, response);
response.scale();
}
break;

case ECalibrationMethod::GROSSBERG:
{
case ECalibrationMethod::GROSSBERG:
{
ALICEVISION_LOG_INFO("Grossberg calibration");
const int nbPoints = 1000000;
hdr::GrossbergCalibrate calibration(5);
calibration.process(ldrImageGroups_sorted, channelQuantization, times_sorted, nbPoints, calibrationWeight, response);
const int nbPoints = 1000000;
hdr::GrossbergCalibrate calibration(5);
calibration.process(ldrImageGroups_sorted, channelQuantization, times_sorted, nbPoints, calibrationWeight, response);
}
break;
}
break;
}

MERGE:
ALICEVISION_LOG_INFO("hdr fusion");
hdr::hdrMerge merge;
merge.process(ldrImageGroups_sorted.at(0), ldrTimes_sorted, fusionWeight, response, image, targetTime, false, clampedValueCorrection);
Expand Down