[libcamera-devel] libcamera: ipa: raspberrypi: Enable focus measure without recompile

Message ID 20200701085356.3626-1-david.plowman@raspberrypi.com
State Superseded
Headers show
Series
  • [libcamera-devel] libcamera: ipa: raspberrypi: Enable focus measure without recompile
Related show

Commit Message

David Plowman July 1, 2020, 8:53 a.m. UTC
Previously output of the focus measure could be enabled without
recompiling (because of the RPI_LOGGING_ENABLE macro). Here we disable
it in the imx477 tuning, but if re-enabled there it will now be output
to the console (much more helpful behaviour).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +-
 src/ipa/raspberrypi/data/imx477.json         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart July 1, 2020, 9:11 a.m. UTC | #1
Hi David,

Thank you for the patch.

On Wed, Jul 01, 2020 at 09:53:56AM +0100, David Plowman wrote:
> Previously output of the focus measure could be enabled without
> recompiling (because of the RPI_LOGGING_ENABLE macro). Here we disable
> it in the imx477 tuning, but if re-enabled there it will now be output
> to the console (much more helpful behaviour).
> 
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> ---
>  src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +-
>  src/ipa/raspberrypi/data/imx477.json         | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp
> index 1e2b649..133ea6f 100644
> --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp
> +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp
> @@ -39,7 +39,7 @@ void Focus::Process(StatisticsPtr &stats, Metadata *image_metadata)
>  	image_metadata->Set("focus.status", status);
>  	if (print_) {
>  		uint32_t value = (status.focus_measures[5] + status.focus_measures[6]) / 10;
> -		RPI_LOG("Focus contrast measure: " << value);
> +		std::cout << "Focus contrast measure: " << value << std::endl;

How about using the libcamera logging infrastructure ? It would give you
runtime-controllable log categories and levels.

>  	}
>  }
>  
> diff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json
> index 389e8ce..8976e31 100644
> --- a/src/ipa/raspberrypi/data/imx477.json
> +++ b/src/ipa/raspberrypi/data/imx477.json
> @@ -415,6 +415,6 @@
>      },
>      "rpi.focus":
>      {
> -	"print": 1
> +	"print": 0
>      }
>  }
David Plowman July 1, 2020, 11:43 a.m. UTC | #2
HI Laurent

On Wed, 1 Jul 2020 at 10:11, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi David,
>
> Thank you for the patch.
>
> On Wed, Jul 01, 2020 at 09:53:56AM +0100, David Plowman wrote:
> > Previously output of the focus measure could be enabled without
> > recompiling (because of the RPI_LOGGING_ENABLE macro). Here we disable
> > it in the imx477 tuning, but if re-enabled there it will now be output
> > to the console (much more helpful behaviour).
> >
> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> > ---
> >  src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +-
> >  src/ipa/raspberrypi/data/imx477.json         | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp
> > index 1e2b649..133ea6f 100644
> > --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp
> > +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp
> > @@ -39,7 +39,7 @@ void Focus::Process(StatisticsPtr &stats, Metadata *image_metadata)
> >       image_metadata->Set("focus.status", status);
> >       if (print_) {
> >               uint32_t value = (status.focus_measures[5] + status.focus_measures[6]) / 10;
> > -             RPI_LOG("Focus contrast measure: " << value);
> > +             std::cout << "Focus contrast measure: " << value << std::endl;
>
> How about using the libcamera logging infrastructure ? It would give you
> runtime-controllable log categories and levels.

Yes, thank you for the thought. I spent way longer trying to make up
my mind than such a trivial and unimportant thing really warrants! But
I think I've eventually come down on the side of using the libcamera
logging, so expect a v2 patch momentarily.

Best regards
David

>
> >       }
> >  }
> >
> > diff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json
> > index 389e8ce..8976e31 100644
> > --- a/src/ipa/raspberrypi/data/imx477.json
> > +++ b/src/ipa/raspberrypi/data/imx477.json
> > @@ -415,6 +415,6 @@
> >      },
> >      "rpi.focus":
> >      {
> > -     "print": 1
> > +     "print": 0
> >      }
> >  }
>
> --
> Regards,
>
> Laurent Pinchart
Laurent Pinchart July 1, 2020, 11:50 a.m. UTC | #3
Hi David,

On Wed, Jul 01, 2020 at 12:43:47PM +0100, David Plowman wrote:
> On Wed, 1 Jul 2020 at 10:11, Laurent Pinchart wrote:
> > On Wed, Jul 01, 2020 at 09:53:56AM +0100, David Plowman wrote:
> > > Previously output of the focus measure could be enabled without
> > > recompiling (because of the RPI_LOGGING_ENABLE macro). Here we disable
> > > it in the imx477 tuning, but if re-enabled there it will now be output
> > > to the console (much more helpful behaviour).
> > >
> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> > > ---
> > >  src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +-
> > >  src/ipa/raspberrypi/data/imx477.json         | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp
> > > index 1e2b649..133ea6f 100644
> > > --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp
> > > +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp
> > > @@ -39,7 +39,7 @@ void Focus::Process(StatisticsPtr &stats, Metadata *image_metadata)
> > >       image_metadata->Set("focus.status", status);
> > >       if (print_) {
> > >               uint32_t value = (status.focus_measures[5] + status.focus_measures[6]) / 10;
> > > -             RPI_LOG("Focus contrast measure: " << value);
> > > +             std::cout << "Focus contrast measure: " << value << std::endl;
> >
> > How about using the libcamera logging infrastructure ? It would give you
> > runtime-controllable log categories and levels.
> 
> Yes, thank you for the thought. I spent way longer trying to make up
> my mind than such a trivial and unimportant thing really warrants! But
> I think I've eventually come down on the side of using the libcamera
> logging, so expect a v2 patch momentarily.

Nice to hear :-) Feel free to define different log categories for
different algorithms, that could even allow dropping the print options
from the json file completely. Categories have to be valid C++ symbol
names so RPI.Focus wouldn't be valid unfortunately.

Additionally, we're thinking about adding a tracing mechanism that would
work similarly to the log but would be more lightweight, it could be
used in the future for such messages. Or maybe we'll just improve the
efficiency of the logging system.

> > >       }
> > >  }
> > >
> > > diff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json
> > > index 389e8ce..8976e31 100644
> > > --- a/src/ipa/raspberrypi/data/imx477.json
> > > +++ b/src/ipa/raspberrypi/data/imx477.json
> > > @@ -415,6 +415,6 @@
> > >      },
> > >      "rpi.focus":
> > >      {
> > > -     "print": 1
> > > +     "print": 0
> > >      }
> > >  }

Patch

diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp
index 1e2b649..133ea6f 100644
--- a/src/ipa/raspberrypi/controller/rpi/focus.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp
@@ -39,7 +39,7 @@  void Focus::Process(StatisticsPtr &stats, Metadata *image_metadata)
 	image_metadata->Set("focus.status", status);
 	if (print_) {
 		uint32_t value = (status.focus_measures[5] + status.focus_measures[6]) / 10;
-		RPI_LOG("Focus contrast measure: " << value);
+		std::cout << "Focus contrast measure: " << value << std::endl;
 	}
 }
 
diff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json
index 389e8ce..8976e31 100644
--- a/src/ipa/raspberrypi/data/imx477.json
+++ b/src/ipa/raspberrypi/data/imx477.json
@@ -415,6 +415,6 @@ 
     },
     "rpi.focus":
     {
-	"print": 1
+	"print": 0
     }
 }