libipa: awb: Make result of gainsFromColourTemp optional

In the grey world AWB case, if no colour gains are contained in the
tuning file, the colour gains get reset to 1 when the colour temperature
is set manually. This is unexpected and undesirable. Allow the
gainsFromColourTemp() function to return a std::nullopt to handle that
case.

While at it, remove an unnecessary import from rkisp1/algorithms/awb.h.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
Stefan Klug 2025-04-03 17:49:18 +02:00
parent 66e9604684
commit c699d26573
8 changed files with 22 additions and 17 deletions

View file

@ -270,7 +270,7 @@ void AwbBayes::handleControls(const ControlList &controls)
}
}
RGB<double> AwbBayes::gainsFromColourTemperature(double colourTemperature)
std::optional<RGB<double>> AwbBayes::gainsFromColourTemperature(double colourTemperature)
{
/*
* \todo In the RaspberryPi code, the ct curve was interpolated in
@ -278,7 +278,7 @@ RGB<double> AwbBayes::gainsFromColourTemperature(double colourTemperature)
* intuitive, as the gains are in linear space. But I can't prove it.
*/
const auto &gains = colourGainCurve_.getInterpolated(colourTemperature);
return { { gains[0], 1.0, gains[1] } };
return RGB<double>{ { gains[0], 1.0, gains[1] } };
}
AwbResult AwbBayes::calculateAwb(const AwbStats &stats, unsigned int lux)