Message ID | 20241206145242.827886-3-stefan.klug@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
On Fri, Dec 06, 2024 at 03:52:22PM +0100, Stefan Klug wrote: > For the implementation of a manual colour temperature setting, it is > necessary to read predefined colour gains per colour temperature from > the tuning file. Implement this in a backwards compatible way. If no > gains are contained in the tuning file, loading just continues as > before. > > 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> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > Changes in v5: > - Replace Interpolator<Matrix> with Interpolator<Vector> > --- > src/ipa/rkisp1/algorithms/awb.cpp | 18 ++++++++++++++++++ > src/ipa/rkisp1/algorithms/awb.h | 7 +++++++ > 2 files changed, 25 insertions(+) > > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp > index 4bb4f5b88375..23a81e75d3d3 100644 > --- a/src/ipa/rkisp1/algorithms/awb.cpp > +++ b/src/ipa/rkisp1/algorithms/awb.cpp > @@ -41,6 +41,24 @@ Awb::Awb() > { > } > > +/** > + * \copydoc libcamera::ipa::Algorithm::init > + */ > +int Awb::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) > +{ > + Interpolator<Vector<double, 2>> gains; > + int ret = gains.readYaml(tuningData["gains"], "ct", "gains"); > + if (ret < 0) > + LOG(RkISP1Awb, Warning) > + << "Failed to parse 'gains' " > + << "parameter from tuning file; " > + << "manual colour temperature will not work properly"; > + else > + gains_ = gains; I got a bit confused by gains_ when reviewing 3/8 as I had forgotten about this change. I'm wondering if the code (and tuning data) would be clearer if we used CT curve ("ct-curve", ctCurve_) instead of gains. > + > + return 0; > +} > + > /** > * \copydoc libcamera::ipa::Algorithm::configure > */ > diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h > index 6ac3a5c3838b..a7e0537c66d9 100644 > --- a/src/ipa/rkisp1/algorithms/awb.h > +++ b/src/ipa/rkisp1/algorithms/awb.h > @@ -7,6 +7,11 @@ > > #pragma once > > +#include <optional> > + > +#include "libipa/interpolator.h" > +#include "libipa/vector.h" > + > #include "algorithm.h" > > namespace libcamera { > @@ -19,6 +24,7 @@ public: > Awb(); > ~Awb() = default; > > + int init(IPAContext &context, const YamlObject &tuningData) override; > int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; > void queueRequest(IPAContext &context, const uint32_t frame, > IPAFrameContext &frameContext, > @@ -32,6 +38,7 @@ public: > ControlList &metadata) override; > > private: > + std::optional<Interpolator<Vector<double, 2>>> gains_; > bool rgbMode_; > }; >
diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 4bb4f5b88375..23a81e75d3d3 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -41,6 +41,24 @@ Awb::Awb() { } +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int Awb::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) +{ + Interpolator<Vector<double, 2>> gains; + int ret = gains.readYaml(tuningData["gains"], "ct", "gains"); + if (ret < 0) + LOG(RkISP1Awb, Warning) + << "Failed to parse 'gains' " + << "parameter from tuning file; " + << "manual colour temperature will not work properly"; + else + gains_ = gains; + + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::configure */ diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index 6ac3a5c3838b..a7e0537c66d9 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -7,6 +7,11 @@ #pragma once +#include <optional> + +#include "libipa/interpolator.h" +#include "libipa/vector.h" + #include "algorithm.h" namespace libcamera { @@ -19,6 +24,7 @@ public: Awb(); ~Awb() = default; + int init(IPAContext &context, const YamlObject &tuningData) override; int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; void queueRequest(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, @@ -32,6 +38,7 @@ public: ControlList &metadata) override; private: + std::optional<Interpolator<Vector<double, 2>>> gains_; bool rgbMode_; };