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

Update compensation of aperture and ISO change in HDR fusion #863

Merged
merged 5 commits into from
Sep 8, 2020
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
35 changes: 30 additions & 5 deletions src/aliceVision/sfmData/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,43 @@
namespace aliceVision {
namespace sfmData {

float View::getCameraExposureSetting() const
float View::getCameraExposureSetting(const float referenceISO, const float referenceFNumber) const
{
const float shutter = getMetadataShutter();
const float fnumber = getMetadataFNumber();
if(shutter < 0 || fnumber < 0)
if(shutter <= 0.0f || fnumber <= 0.0f)
return -1.f;

float lReferenceFNumber = referenceFNumber;
if (lReferenceFNumber <= 0.0f)
{
lReferenceFNumber = fnumber;
}

const float iso = getMetadataISO();
const float isoRatio = (iso < 0.f) ? 1.0 : (iso / 100.f);
/*
iso = qLt / aperture^2
isoratio = iso2 / iso1 = (qLt / aperture1^2) / (qLt / aperture2^2)
isoratio = aperture2^2 / aperture1^2
aperture2^2 = iso2 / iso1 * 1
aperture2 = sqrt(iso2 / iso1)
*/
float iso_2_aperture = 1.0f;
if(iso > 1e-6f && referenceISO > 1e-6f)
{
// Need to have both iso and reference iso to use it
iso_2_aperture = std::sqrt(iso / referenceISO);
}

/*
aperture = f / diameter
aperture2 / aperture1 = diameter2 / diameter1
(aperture2 / aperture1)^2 = (area2 / pi) / (area1 / pi)
*/
float new_fnumber = fnumber * iso_2_aperture;
float exp_increase = (new_fnumber / lReferenceFNumber) * (new_fnumber / lReferenceFNumber);

float cameraExposure = (shutter * isoRatio) / (fnumber * fnumber);
return cameraExposure;
return shutter * exp_increase;
}

float View::getEv() const
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/sfmData/View.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class View
* For the same scene, this value is linearly proportional to the amount of light captured by the camera according to
* the shooting parameters (shutter speed, f-number, iso).
*/
float getCameraExposureSetting() const;
float getCameraExposureSetting(const float referenceISO = 100.0f, const float referenceFNumber = 8.0f) const;

/**
* @brief Get the Exposure Value. EV is a number that represents a combination of a camera's shutter speed and
Expand Down
5 changes: 3 additions & 2 deletions src/software/pipeline/main_LdrToHdrCalibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,9 @@ int aliceVision_main(int argc, char** argv)
std::vector<float> exposures;

for(int j = 0; j < group.size(); ++j)
{
float etime = group[j]->getCameraExposureSetting();
{

float etime = group[j]->getCameraExposureSetting(/*group[0]->getMetadataISO(), group[0]->getMetadataFNumber()*/);
exposures.push_back(etime);
}
groupedExposures.push_back(exposures);
Expand Down
2 changes: 1 addition & 1 deletion src/software/pipeline/main_LdrToHdrMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ int aliceVision_main(int argc, char** argv)
ALICEVISION_LOG_INFO("Load " << filepath);
image::readImage(filepath, images[i], image::EImageColorSpace::SRGB);

exposures[i] = group[i]->getCameraExposureSetting();
exposures[i] = group[i]->getCameraExposureSetting(/*targetView->getMetadataISO(), targetView->getMetadataFNumber()*/);
}

// Merge HDR images
Expand Down