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 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
37 changes: 32 additions & 5 deletions src/aliceVision/sfmData/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,45 @@
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();
const float iso = getMetadataISO();

if(shutter < 0 || fnumber < 0)
This conversation was marked as resolved.
Show resolved Hide resolved
return -1.f;

const float iso = getMetadataISO();
const float isoRatio = (iso < 0.f) ? 1.0 : (iso / 100.f);
float lReferenceIso = referenceISO;
if (lReferenceIso < 0.0f) {
This conversation was marked as resolved.
Show resolved Hide resolved
lReferenceIso = iso;
fabiencastan marked this conversation as resolved.
Show resolved Hide resolved
}

float cameraExposure = (shutter * isoRatio) / (fnumber * fnumber);
return cameraExposure;
float lReferenceFNumber = referenceFNumber;
if (lReferenceFNumber < 0.0f) {
lReferenceFNumber = fnumber;
}

/*
iso = qLt / aperture^2
isoratio = iso2 / iso1 = qLt / aperture1² / (qLt / aperture2²)
This conversation was marked as resolved.
Show resolved Hide resolved
isoratio = aperture2² / aperture1²
aperture2² = iso2 / iso1 * 1
aperture2 = sqrt(iso2 / iso1)
*/
float iso_2_aperture = sqrt(iso / lReferenceIso);

/*
aperture = f / diameter
aperture2 / aperture1 = diameter2 / diameter1
(aperture2 / aperture1)² = (area2 / pi) / (area1 / pi)
*/

float new_fnumber = fnumber * iso_2_aperture;
float exp_increase = (new_fnumber / lReferenceFNumber) * (new_fnumber / lReferenceFNumber);


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 = -1.0f, const float referenceFNumber = -1.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());
This conversation was marked as resolved.
Show resolved Hide resolved
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