libipa: agc_mean_luminance: Add exposure compensation support
Exposure compensation allows to over- or under-expose an image by a given value. Add support for that in agc_mean_luminance. The added exposure compensation can lead to luminance target values that are close or above saturation and are therefore never reachable. Add a fix for that by limiting the maximum luminance target to 0.95. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
@@ -44,6 +44,15 @@ static constexpr uint32_t kNumStartupFrames = 10;
|
|||||||
*/
|
*/
|
||||||
static constexpr double kDefaultRelativeLuminanceTarget = 0.16;
|
static constexpr double kDefaultRelativeLuminanceTarget = 0.16;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Maximum relative luminance target
|
||||||
|
*
|
||||||
|
* This value limits the relative luminance target after applying the exposure
|
||||||
|
* compensation. Targeting a value above this limit results in saturation
|
||||||
|
* and the inability to regulate properly.
|
||||||
|
*/
|
||||||
|
static constexpr double kMaxRelativeLuminanceTarget = 0.95;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct AgcMeanLuminance::AgcConstraint
|
* \struct AgcMeanLuminance::AgcConstraint
|
||||||
* \brief The boundaries and target for an AeConstraintMode constraint
|
* \brief The boundaries and target for an AeConstraintMode constraint
|
||||||
@@ -134,7 +143,8 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
AgcMeanLuminance::AgcMeanLuminance()
|
AgcMeanLuminance::AgcMeanLuminance()
|
||||||
: frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0)
|
: exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s),
|
||||||
|
relativeLuminanceTarget_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +378,15 @@ int AgcMeanLuminance::parseTuningData(const YamlObject &tuningData)
|
|||||||
return parseExposureModes(tuningData);
|
return parseExposureModes(tuningData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn AgcMeanLuminance::setExposureCompensation()
|
||||||
|
* \brief Set the exposure compensation value
|
||||||
|
* \param[in] gain The exposure compensation gain
|
||||||
|
*
|
||||||
|
* This function sets the exposure compensation value to be used in the
|
||||||
|
* AGC calculations. It is expressed as gain instead of EV.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the ExposureModeHelper limits for this class
|
* \brief Set the ExposureModeHelper limits for this class
|
||||||
* \param[in] minExposureTime Minimum exposure time to allow
|
* \param[in] minExposureTime Minimum exposure time to allow
|
||||||
@@ -424,7 +443,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime,
|
|||||||
*/
|
*/
|
||||||
double AgcMeanLuminance::estimateInitialGain() const
|
double AgcMeanLuminance::estimateInitialGain() const
|
||||||
{
|
{
|
||||||
double yTarget = relativeLuminanceTarget_;
|
double yTarget = std::min(relativeLuminanceTarget_ * exposureCompensation_,
|
||||||
|
kMaxRelativeLuminanceTarget);
|
||||||
double yGain = 1.0;
|
double yGain = 1.0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public:
|
|||||||
|
|
||||||
int parseTuningData(const YamlObject &tuningData);
|
int parseTuningData(const YamlObject &tuningData);
|
||||||
|
|
||||||
|
void setExposureCompensation(double gain)
|
||||||
|
{
|
||||||
|
exposureCompensation_ = gain;
|
||||||
|
}
|
||||||
|
|
||||||
void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
|
void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
|
||||||
double minGain, double maxGain);
|
double minGain, double maxGain);
|
||||||
|
|
||||||
@@ -84,6 +89,7 @@ private:
|
|||||||
double gain);
|
double gain);
|
||||||
utils::Duration filterExposure(utils::Duration exposureValue);
|
utils::Duration filterExposure(utils::Duration exposureValue);
|
||||||
|
|
||||||
|
double exposureCompensation_;
|
||||||
uint64_t frameCount_;
|
uint64_t frameCount_;
|
||||||
utils::Duration filteredExposure_;
|
utils::Duration filteredExposure_;
|
||||||
double relativeLuminanceTarget_;
|
double relativeLuminanceTarget_;
|
||||||
|
|||||||
Reference in New Issue
Block a user