[libcamera-devel,v4,28/32] ipa: rkisp1: awb: Log means, gains and temperature in debug message
diff mbox series

Message ID 20220908014200.28728-29-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements
Related show

Commit Message

Laurent Pinchart Sept. 8, 2022, 1:41 a.m. UTC
Extend the debug message in Awb::process() to log the means and color
temperature in addition to the gains. This is useful for debugging the
algorithm behaviour. While at it, set the showpoint flag to print a
fixed number of digits after the decimal point, making logs more
readable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Sept. 20, 2022, 11:34 p.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2022-09-08 02:41:56)
> Extend the debug message in Awb::process() to log the means and color
> temperature in addition to the gains. This is useful for debugging the
> algorithm behaviour. While at it, set the showpoint flag to print a
> fixed number of digits after the decimal point, making logs more
> readable.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index 2ff67ed98221..ed91e9277a16 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -9,6 +9,7 @@
>  
>  #include <algorithm>
>  #include <cmath>
> +#include <iomanip>
>  
>  #include <libcamera/base/log.h>
>  
> @@ -271,8 +272,12 @@ void Awb::process(IPAContext &context,
>         activeState.awb.gains.automatic.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
>         activeState.awb.gains.automatic.green = 1.0;
>  
> -       LOG(RkISP1Awb, Debug) << "Gain found for red: " << activeState.awb.gains.automatic.red
> -                             << " and for blue: " << activeState.awb.gains.automatic.blue;
> +       LOG(RkISP1Awb, Debug) << std::showpoint
> +               << "Means [" << redMean << ", " << greenMean << ", " << blueMean
> +               << "], gains [" << activeState.awb.gains.automatic.red << ", "
> +               << activeState.awb.gains.automatic.green << ", "
> +               << activeState.awb.gains.automatic.blue << "], temp "
> +               << frameContext.awb.temperatureK << "K";

That's ok I think - but 'metadata, metadata, metadata' ... although -
metadata should only report what the /actual/ frame uses - while we
might really want the algorithms to report what they calculate even when
we're in manual mode....

So I think this is good ...

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


>  }
>  
>  REGISTER_IPA_ALGORITHM(Awb, "Awb")
> -- 
> Regards,
> 
> Laurent Pinchart
>
Jacopo Mondi Sept. 22, 2022, 10:36 a.m. UTC | #2
On Thu, Sep 08, 2022 at 04:41:56AM +0300, Laurent Pinchart via libcamera-devel wrote:
> Extend the debug message in Awb::process() to log the means and color
> temperature in addition to the gains. This is useful for debugging the
> algorithm behaviour. While at it, set the showpoint flag to print a

"The character to use as decimal point character is determined by the
numpunct facet of the locale imbued in the stream at the time of
output, as described in std::num_put::put"

How not to love C++


> fixed number of digits after the decimal point, making logs more
> readable.

I still don't get how many characters are expected to be printed, but
that's ok

>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index 2ff67ed98221..ed91e9277a16 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -9,6 +9,7 @@
>
>  #include <algorithm>
>  #include <cmath>
> +#include <iomanip>
>
>  #include <libcamera/base/log.h>
>
> @@ -271,8 +272,12 @@ void Awb::process(IPAContext &context,
>  	activeState.awb.gains.automatic.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
>  	activeState.awb.gains.automatic.green = 1.0;
>
> -	LOG(RkISP1Awb, Debug) << "Gain found for red: " << activeState.awb.gains.automatic.red
> -			      << " and for blue: " << activeState.awb.gains.automatic.blue;
> +	LOG(RkISP1Awb, Debug) << std::showpoint
> +		<< "Means [" << redMean << ", " << greenMean << ", " << blueMean
> +		<< "], gains [" << activeState.awb.gains.automatic.red << ", "
> +		<< activeState.awb.gains.automatic.green << ", "
> +		<< activeState.awb.gains.automatic.blue << "], temp "
> +		<< frameContext.awb.temperatureK << "K";
>  }
>
>  REGISTER_IPA_ALGORITHM(Awb, "Awb")
> --
> Regards,
>
> Laurent Pinchart
>
Laurent Pinchart Sept. 22, 2022, 10:31 p.m. UTC | #3
Hi Kieran,

On Wed, Sep 21, 2022 at 12:34:31AM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-09-08 02:41:56)
> > Extend the debug message in Awb::process() to log the means and color
> > temperature in addition to the gains. This is useful for debugging the
> > algorithm behaviour. While at it, set the showpoint flag to print a
> > fixed number of digits after the decimal point, making logs more
> > readable.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> > index 2ff67ed98221..ed91e9277a16 100644
> > --- a/src/ipa/rkisp1/algorithms/awb.cpp
> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> > @@ -9,6 +9,7 @@
> >  
> >  #include <algorithm>
> >  #include <cmath>
> > +#include <iomanip>
> >  
> >  #include <libcamera/base/log.h>
> >  
> > @@ -271,8 +272,12 @@ void Awb::process(IPAContext &context,
> >         activeState.awb.gains.automatic.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
> >         activeState.awb.gains.automatic.green = 1.0;
> >  
> > -       LOG(RkISP1Awb, Debug) << "Gain found for red: " << activeState.awb.gains.automatic.red
> > -                             << " and for blue: " << activeState.awb.gains.automatic.blue;
> > +       LOG(RkISP1Awb, Debug) << std::showpoint
> > +               << "Means [" << redMean << ", " << greenMean << ", " << blueMean
> > +               << "], gains [" << activeState.awb.gains.automatic.red << ", "
> > +               << activeState.awb.gains.automatic.green << ", "
> > +               << activeState.awb.gains.automatic.blue << "], temp "
> > +               << frameContext.awb.temperatureK << "K";
> 
> That's ok I think - but 'metadata, metadata, metadata' ... although -
> metadata should only report what the /actual/ frame uses - while we
> might really want the algorithms to report what they calculate even when
> we're in manual mode....

Yes, that was the idea. We don't skip the calculation even in manual
mode in order to always have a colour temperature estimate, so I thought
we could as well always log the computed gains.

> So I think this is good ...
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> >  }
> >  
> >  REGISTER_IPA_ALGORITHM(Awb, "Awb")

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index 2ff67ed98221..ed91e9277a16 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -9,6 +9,7 @@ 
 
 #include <algorithm>
 #include <cmath>
+#include <iomanip>
 
 #include <libcamera/base/log.h>
 
@@ -271,8 +272,12 @@  void Awb::process(IPAContext &context,
 	activeState.awb.gains.automatic.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
 	activeState.awb.gains.automatic.green = 1.0;
 
-	LOG(RkISP1Awb, Debug) << "Gain found for red: " << activeState.awb.gains.automatic.red
-			      << " and for blue: " << activeState.awb.gains.automatic.blue;
+	LOG(RkISP1Awb, Debug) << std::showpoint
+		<< "Means [" << redMean << ", " << greenMean << ", " << blueMean
+		<< "], gains [" << activeState.awb.gains.automatic.red << ", "
+		<< activeState.awb.gains.automatic.green << ", "
+		<< activeState.awb.gains.automatic.blue << "], temp "
+		<< frameContext.awb.temperatureK << "K";
 }
 
 REGISTER_IPA_ALGORITHM(Awb, "Awb")