@@ -16,6 +16,8 @@
#include <libcamera/ipa/core_ipa_interface.h>
+#include "libipa/helpers.h"
+
/**
* \file awb.h
*/
@@ -178,22 +180,6 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
}
}
-uint32_t Awb::estimateCCT(double red, double green, double blue)
-{
- /* Convert the RGB values to CIE tristimulus values (XYZ) */
- double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);
- double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);
- double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);
-
- /* Calculate the normalized chromaticity values */
- double x = X / (X + Y + Z);
- double y = Y / (X + Y + Z);
-
- /* Calculate CCT */
- double n = (x - 0.3320) / (0.1858 - y);
- return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;
-}
-
/**
* \copydoc libcamera::ipa::Algorithm::process
*/
@@ -279,7 +265,7 @@ void Awb::process(IPAContext &context,
blueMean < kMeanMinThreshold)
return;
- activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);
+ activeState.awb.temperatureK = ipa::estimateCCT(redMean, greenMean, blueMean);
/* Metadata shall contain the up to date measurement */
metadata.set(controls::ColourTemperature, activeState.awb.temperatureK);
@@ -32,8 +32,6 @@ public:
ControlList &metadata) override;
private:
- uint32_t estimateCCT(double red, double green, double blue);
-
bool rgbMode_;
};
Use the centralised libipa helpers instead of open-coding common functions. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> --- src/ipa/rkisp1/algorithms/awb.cpp | 20 +++----------------- src/ipa/rkisp1/algorithms/awb.h | 2 -- 2 files changed, 3 insertions(+), 19 deletions(-)