@@ -85,14 +85,21 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata)
{
DeviceStatus deviceStatus;
if (imageMetadata->get("device.status", deviceStatus) == 0) {
+ /*
+ * We've set up the first floating AGC region to collect full image stats. This
+ * is a better choice than the Y-histogram, for example, because it's invariant
+ * to the metering mode (and cheaper to evaluate).
+ */
+ auto const &fullImageStats = stats->agcRegions.getFloating(0);
+ double currentY = static_cast<double>(fullImageStats.val.ySum) / fullImageStats.counted;
+
double currentGain = deviceStatus.analogueGain;
double currentAperture = deviceStatus.aperture.value_or(currentAperture_);
- double currentY = stats->yHist.interQuantileMean(0, 1);
double gainRatio = referenceGain_ / currentGain;
double exposureTimeRatio =
referenceExposureTime_ / deviceStatus.exposureTime;
double apertureRatio = referenceAperture_ / currentAperture;
- double yRatio = currentY * (65536 / stats->yHist.bins()) / referenceY_;
+ double yRatio = currentY / referenceY_;
double estimatedLux = exposureTimeRatio * gainRatio *
apertureRatio * apertureRatio *
yRatio * referenceLux_ / sensitivity_;
The Y value from the first floating region is now a better choice for a Y value that is invariant to (for example) the metering mode. Both VC4 and PiSP platforms store full image Y statistics here. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> --- src/ipa/rpi/controller/rpi/lux.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)