summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1/algorithms
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-09-04 04:21:18 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-09-28 05:41:15 +0300
commit9b389ce79eb143a82e998bfe5b09470272a25600 (patch)
treefd25443e733ac13b5d42d090d7666d81a63fc88a /src/ipa/rkisp1/algorithms
parent7dc60a5a27f9f97fa78beb7d5a752e0cc88dcf29 (diff)
ipa: rkisp1: awb: Freeze AWB when means are too small
When the RGB means are too small, gains and color temperature can't be meaningfully calculated. Freeze the AWB in that case, using the previously calculated values. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/ipa/rkisp1/algorithms')
-rw-r--r--src/ipa/rkisp1/algorithms/awb.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index a3066fbb..eb32cd72 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -31,6 +31,9 @@ namespace ipa::rkisp1::algorithms {
LOG_DEFINE_CATEGORY(RkISP1Awb)
+/* Minimum mean value below which AWB can't operate. */
+constexpr double kMeanMinThreshold = 2.0;
+
Awb::Awb()
: rgbMode_(false)
{
@@ -263,7 +266,17 @@ void Awb::process(IPAContext &context,
greenMean /= frameContext.awb.gains.green;
blueMean /= frameContext.awb.gains.blue;
- frameContext.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);
+ /*
+ * If the means are too small we don't have enough information to
+ * meaningfully calculate gains. Freeze the algorithm in that case.
+ */
+ if (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold &&
+ blueMean < kMeanMinThreshold) {
+ frameContext.awb.temperatureK = activeState.awb.temperatureK;
+ return;
+ }
+
+ activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);
/*
* Estimate the red and blue gains to apply in a grey world. The green
@@ -290,6 +303,8 @@ void Awb::process(IPAContext &context,
activeState.awb.gains.automatic.blue = blueGain;
activeState.awb.gains.automatic.green = 1.0;
+ frameContext.awb.temperatureK = activeState.awb.temperatureK;
+
LOG(RkISP1Awb, Debug) << std::showpoint
<< "Means [" << redMean << ", " << greenMean << ", " << blueMean
<< "], gains [" << activeState.awb.gains.automatic.red << ", "