@@ -44,6 +44,15 @@ static constexpr uint32_t kNumStartupFrames = 10;
44
44
*/
45
45
static constexpr double kDefaultRelativeLuminanceTarget = 0.16 ;
46
46
47
+ /*
48
+ * Maximum relative luminance target
49
+ *
50
+ * This value limits the relative luminance target after applying the exposure
51
+ * compensation. Targeting a value above this limit results in saturation
52
+ * and the inability to regulate properly.
53
+ */
54
+ static constexpr double kMaxRelativeLuminanceTarget = 0.95 ;
55
+
47
56
/* *
48
57
* \struct AgcMeanLuminance::AgcConstraint
49
58
* \brief The boundaries and target for an AeConstraintMode constraint
@@ -134,7 +143,8 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16;
134
143
*/
135
144
136
145
AgcMeanLuminance::AgcMeanLuminance ()
137
- : frameCount_(0 ), filteredExposure_(0s), relativeLuminanceTarget_(0 )
146
+ : exposureCompensation_(1.0 ), frameCount_(0 ), filteredExposure_(0s),
147
+ relativeLuminanceTarget_ (0 )
138
148
{
139
149
}
140
150
@@ -368,6 +378,15 @@ int AgcMeanLuminance::parseTuningData(const YamlObject &tuningData)
368
378
return parseExposureModes (tuningData);
369
379
}
370
380
381
+ /* *
382
+ * \fn AgcMeanLuminance::setExposureCompensation()
383
+ * \brief Set the exposure compensation value
384
+ * \param[in] gain The exposure compensation gain
385
+ *
386
+ * This function sets the exposure compensation value to be used in the
387
+ * AGC calculations. It is expressed as gain instead of EV.
388
+ */
389
+
371
390
/* *
372
391
* \brief Set the ExposureModeHelper limits for this class
373
392
* \param[in] minExposureTime Minimum exposure time to allow
@@ -424,7 +443,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime,
424
443
*/
425
444
double AgcMeanLuminance::estimateInitialGain () const
426
445
{
427
- double yTarget = relativeLuminanceTarget_;
446
+ double yTarget = std::min (relativeLuminanceTarget_ * exposureCompensation_,
447
+ kMaxRelativeLuminanceTarget );
428
448
double yGain = 1.0 ;
429
449
430
450
/*
@@ -467,12 +487,20 @@ double AgcMeanLuminance::constraintClampGain(uint32_t constraintModeIndex,
467
487
hist.interQuantileMean (constraint.qLo , constraint.qHi );
468
488
469
489
if (constraint.bound == AgcConstraint::Bound::Lower &&
470
- newGain > gain)
490
+ newGain > gain) {
471
491
gain = newGain;
492
+ LOG (AgcMeanLuminance, Debug)
493
+ << " Apply lower bound: " << gain << " to "
494
+ << newGain;
495
+ }
472
496
473
497
if (constraint.bound == AgcConstraint::Bound::Upper &&
474
- newGain < gain)
498
+ newGain < gain) {
475
499
gain = newGain;
500
+ LOG (AgcMeanLuminance, Debug)
501
+ << " Apply upper bound: " << gain << " to "
502
+ << newGain;
503
+ }
476
504
}
477
505
478
506
return gain;
0 commit comments