[v4,1/3] libcamera: Add gamma control id
diff mbox series

Message ID 20240605095417.157703-2-stefan.klug@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Add gamma control for rkisp1
Related show

Commit Message

Stefan Klug June 5, 2024, 9:53 a.m. UTC
A camera gamma of roughly 2.2 is necessary to produce correct output
images on a standard monitor. Add a control for that.

Further information is available here:
https://en.wikipedia.org/wiki/SRGB
https://www.cambridgeincolour.com/tutorials/gamma-correction.htm

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/control_ids_core.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Kieran Bingham June 5, 2024, 10:45 a.m. UTC | #1
Quoting Stefan Klug (2024-06-05 10:53:49)
> A camera gamma of roughly 2.2 is necessary to produce correct output
> images on a standard monitor. Add a control for that.
> 
> Further information is available here:
> https://en.wikipedia.org/wiki/SRGB
> https://www.cambridgeincolour.com/tutorials/gamma-correction.htm
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/control_ids_core.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
> index bf1f1a839f6a..303b0d32e020 100644
> --- a/src/libcamera/control_ids_core.yaml
> +++ b/src/libcamera/control_ids_core.yaml
> @@ -243,6 +243,13 @@ controls:
>          Specify a fixed contrast parameter. Normal contrast is given by the
>          value 1.0; larger values produce images with more contrast.
>  
> +  - Gamma:
> +      type: float
> +      description:  |
> +        Specify a fixed gamma value. Default must be 2.2 which closely mimics 
> +        sRGB gamma. Note that this is camera gamma, so it is applied as 
> +        1.0/gamma
> +

Aha - one small issue here.

Can you append the control instead of adding it in alphabetically?
(Yeah, normally we'd definitely sort things alphabetically...)

That will prevent an ABI breakage. I think we can run a sort operation
on any occasion where we do an ABI breaking release - but hopefully
there's no need to introduce an ABI break here.

--
Kieran


>    - Lux:
>        type: float
>        description: |
> -- 
> 2.43.0
>
Stefan Klug June 6, 2024, 6:23 a.m. UTC | #2
Hi Kieran,

On Wed, Jun 05, 2024 at 11:45:58AM +0100, Kieran Bingham wrote:
> Quoting Stefan Klug (2024-06-05 10:53:49)
> > A camera gamma of roughly 2.2 is necessary to produce correct output
> > images on a standard monitor. Add a control for that.
> > 
> > Further information is available here:
> > https://en.wikipedia.org/wiki/SRGB
> > https://www.cambridgeincolour.com/tutorials/gamma-correction.htm
> > 
> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> > Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> >  src/libcamera/control_ids_core.yaml | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
> > index bf1f1a839f6a..303b0d32e020 100644
> > --- a/src/libcamera/control_ids_core.yaml
> > +++ b/src/libcamera/control_ids_core.yaml
> > @@ -243,6 +243,13 @@ controls:
> >          Specify a fixed contrast parameter. Normal contrast is given by the
> >          value 1.0; larger values produce images with more contrast.
> >  
> > +  - Gamma:
> > +      type: float
> > +      description:  |
> > +        Specify a fixed gamma value. Default must be 2.2 which closely mimics 
> > +        sRGB gamma. Note that this is camera gamma, so it is applied as 
> > +        1.0/gamma
> > +
> 
> Aha - one small issue here.
> 
> Can you append the control instead of adding it in alphabetically?
> (Yeah, normally we'd definitely sort things alphabetically...)
> 
> That will prevent an ABI breakage. I think we can run a sort operation
> on any occasion where we do an ABI breaking release - but hopefully
> there's no need to introduce an ABI break here.

I wasn't aware of that. Changed it locally. Will be fixed when applying.

Cheers,
Stefan

> 
> --
> Kieran
> 
> 
> >    - Lux:
> >        type: float
> >        description: |
> > -- 
> > 2.43.0
> >
Paul Elder June 10, 2024, 10:27 a.m. UTC | #3
On Wed, Jun 05, 2024 at 11:53:49AM +0200, Stefan Klug wrote:
> A camera gamma of roughly 2.2 is necessary to produce correct output
> images on a standard monitor. Add a control for that.
> 
> Further information is available here:
> https://en.wikipedia.org/wiki/SRGB
> https://www.cambridgeincolour.com/tutorials/gamma-correction.htm
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/libcamera/control_ids_core.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
> index bf1f1a839f6a..303b0d32e020 100644
> --- a/src/libcamera/control_ids_core.yaml
> +++ b/src/libcamera/control_ids_core.yaml
> @@ -243,6 +243,13 @@ controls:
>          Specify a fixed contrast parameter. Normal contrast is given by the
>          value 1.0; larger values produce images with more contrast.
>  
> +  - Gamma:
> +      type: float
> +      description:  |
> +        Specify a fixed gamma value. Default must be 2.2 which closely mimics 
> +        sRGB gamma. Note that this is camera gamma, so it is applied as 
> +        1.0/gamma
> +
>    - Lux:
>        type: float
>        description: |
> -- 
> 2.43.0
>
Laurent Pinchart June 11, 2024, 8:16 p.m. UTC | #4
On Wed, Jun 05, 2024 at 11:53:49AM +0200, Stefan Klug wrote:
> A camera gamma of roughly 2.2 is necessary to produce correct output
> images on a standard monitor. Add a control for that.
> 
> Further information is available here:
> https://en.wikipedia.org/wiki/SRGB
> https://www.cambridgeincolour.com/tutorials/gamma-correction.htm
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/control_ids_core.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
> index bf1f1a839f6a..303b0d32e020 100644
> --- a/src/libcamera/control_ids_core.yaml
> +++ b/src/libcamera/control_ids_core.yaml
> @@ -243,6 +243,13 @@ controls:
>          Specify a fixed contrast parameter. Normal contrast is given by the
>          value 1.0; larger values produce images with more contrast.
>  
> +  - Gamma:
> +      type: float
> +      description:  |
> +        Specify a fixed gamma value. Default must be 2.2 which closely mimics 
> +        sRGB gamma. Note that this is camera gamma, so it is applied as 
> +        1.0/gamma

Small typo here, missing period at the end of the line.

It would be nice to tell a bit more about the lower and upper bounds,
but that can come later. We should also document the camera pipeline at
some point, to show where gamma is applied.

> +
>    - Lux:
>        type: float
>        description: |

Patch
diff mbox series

diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
index bf1f1a839f6a..303b0d32e020 100644
--- a/src/libcamera/control_ids_core.yaml
+++ b/src/libcamera/control_ids_core.yaml
@@ -243,6 +243,13 @@  controls:
         Specify a fixed contrast parameter. Normal contrast is given by the
         value 1.0; larger values produce images with more contrast.
 
+  - Gamma:
+      type: float
+      description:  |
+        Specify a fixed gamma value. Default must be 2.2 which closely mimics 
+        sRGB gamma. Note that this is camera gamma, so it is applied as 
+        1.0/gamma
+
   - Lux:
       type: float
       description: |