ipa: rpi: lux: Use floating statistics region to obtain the current Y value
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> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
0810b8a70a
commit
36f9cdcdb4
@@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user