ipa: rkisp1: awb: Avoid division by zero

As the gains can also be specified manually, the regulation can run into
numeric instabilities by dividing by near zero. Mitigate that by
applying a small minium value.

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:21 +02:00
parent 7991293cec
commit 969df3db31

View file

@ -413,9 +413,9 @@ RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rk
/* /*
* The ISP computes the AWB means after applying the colour gains, * The ISP computes the AWB means after applying the colour gains,
* divide by the gains that were used to get the raw means from the * divide by the gains that were used to get the raw means from the
* sensor. * sensor. Apply a minimum value to avoid divisions by near-zero.
*/ */
rgbMeans /= frameContext.awb.gains; rgbMeans /= frameContext.awb.gains.max(0.01);
return rgbMeans; return rgbMeans;
} }