@@ -42,7 +42,7 @@ public:
* \param rgbMeans A vector of doubles representing the RGB mean values
*/
Ipu3AwbStats(const RGB<double> &rgbMeans)
- : rgbMeans_(rgbMeans)
+ : rgbMeans_(rgbMeans), valid_(true)
{
rg_ = rgbMeans_.r() / rgbMeans_.g();
bg_ = rgbMeans_.b() / rgbMeans_.g();
@@ -54,8 +54,9 @@ public:
private:
RGB<double> rgbMeans_;
- double rg_;
- double bg_;
+ double rg_ = 0.0;
+ double bg_ = 0.0;
+ bool valid_ = false;
};
double Ipu3AwbStats::computeColourError(const RGB<double> &gains) const
@@ -78,10 +79,11 @@ bool Ipu3AwbStats::valid() const
* whether there's enough information in the statistics for a frame to
* be useful. The IPU3 implementation already drops any statistics zone
* with an average value below a threshold though so we don't need to do
- * it in libipa. Report all stats as valid.
+ * it in libipa. The statistics are only invalid when too few zones
+ * are left to compute RGB means.
*/
- return true;
+ return valid_;
}
RGB<double> Ipu3AwbStats::rgbMeans() const
When too few statistics zones are usable, for instance in a very dark frame, calculateRgbMeans() returns a default constructed Ipu3AwbStats with zero RGB means. Ipu3AwbStats::valid() always returns true, so AwbAlgorithm processes these zero means as real data: the estimated colour temperature drops to 0K and the gains are computed from zero means. On an OV9734 this happens for one dark frame at stream start. The reported colour temperature drops from about 3200K to 0K, and the CCM and the gains of the following frames are computed from it. Track whether the statistics hold RGB means, and report them as invalid otherwise, so that AwbAlgorithm skips the frame as the IPU3 AWB did before it was ported to AwbAlgorithm. Fixes: b95dd9d14963 ("ipa: ipu3: awb: Port to the new libipa AwbAlgorithm") Signed-off-by: GuyliandeJong <guyliandejong@proton.me> --- src/ipa/ipu3/algorithms/awb.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)