[0/2] CameraSensorHelper measurement tool and guide
mbox series

Message ID 20260808125915.974559-1-john.cronin@opcenter.com
Headers show
Series
  • CameraSensorHelper measurement tool and guide
Related show

Message

John Cronin Aug. 8, 2026, 12:59 p.m. UTC
Hi,

Following up on the imx471 helper series that Jacopo applied:

  https://lists.libcamera.org/pipermail/libcamera-devel/2026-August/060718.html

Jacopo asked whether the measurement script used for imx471 could live
in utils/ with a few lines under Documentation/guides. This series does
that in a sensor-agnostic form.

This is a clean resend with git-send-email (previous offer was a git-am
gist only, because Gmail had mangled format-patch).

  utils/measure-analogue-gain.py
    -> installed as libcamera-measure-analogue-gain
  Documentation/guides/camera-sensor-helper.rst

The tool locks exposure (and optional digital gain) via v4l2-ctl, steps
V4L2_CID_ANALOGUE_GAIN, captures raw frames with the libcamera cam
utility, and reports mean/percentile stats plus a fit of
G = k/(k-code). Flags cover width/height/stride/bit-depth and sensor
name so other sensors can reuse it.

The guide covers helper + properties placement, the measurement
procedure, and points at the utility.

Tested locally on ThinkPad X9-15 Gen 1 / imx471 (same method as the
earlier measurement write-up):

  https://gist.github.com/johncronin3/15d9eacbf64f91ecc600fe583686325f

Happy to rework naming, install path, or docs structure if preferred.

Thanks,
John Cronin

John Cronin (2):
  utils: Add measure-analogue-gain helper
  Documentation: Add Camera Sensor Helper guide

 Documentation/guides/camera-sensor-helper.rst | 146 ++++++
 Documentation/index.rst                       |   1 +
 Documentation/meson.build                     |   1 +
 utils/measure-analogue-gain.py                | 466 ++++++++++++++++++
 utils/meson.build                             |   7 +
 5 files changed, 621 insertions(+)
 create mode 100644 Documentation/guides/camera-sensor-helper.rst
 create mode 100755 utils/measure-analogue-gain.py

Comments

Laurent Pinchart Aug. 10, 2026, 11:09 a.m. UTC | #1
Hi John,

(CC'ing Barnabás and Stefan)

On Sat, Aug 08, 2026 at 08:59:12AM -0400, John Cronin wrote:
> Hi,
> 
> Following up on the imx471 helper series that Jacopo applied:
> 
>   https://lists.libcamera.org/pipermail/libcamera-devel/2026-August/060718.html
> 
> Jacopo asked whether the measurement script used for imx471 could live
> in utils/ with a few lines under Documentation/guides. This series does
> that in a sensor-agnostic form.

This fills a gap in libcamera, thank you for that. I'm sure Kieran will
be very excited when he comes back from holidays :-)

> This is a clean resend with git-send-email (previous offer was a git-am
> gist only, because Gmail had mangled format-patch).
> 
>   utils/measure-analogue-gain.py
>     -> installed as libcamera-measure-analogue-gain

I've long wondered if sensor gain model characterisation should be a
standalone script, or be integrated in camshark (or both). I'm leaning
more towards camshark, but could possibly be convinced otherwise. Asking
you to reimplement this in camshark would be way too much yak shaving,
even by my standards, so I'm fine with merging a standalone script
first. However, I would prefer not installing it. As it's a libcamera
developer tool, it can easily be run from the libcamera source tree.

Stefan, can the camshark plugin infrastructure support this use case ?

>   Documentation/guides/camera-sensor-helper.rst
> 
> The tool locks exposure (and optional digital gain) via v4l2-ctl, steps
> V4L2_CID_ANALOGUE_GAIN, captures raw frames with the libcamera cam
> utility, and reports mean/percentile stats plus a fit of
> G = k/(k-code). Flags cover width/height/stride/bit-depth and sensor
> name so other sensors can reuse it.

It would be nicer to set the analogue gain through libcamera. The
ongoing AGC rework by Barnabás should pave the way for that. Barnabás,
once your series is merged, will it expose the raw analogue gain through
the libcamera AnalogueGain control for sensors that lack gain
information in the camera helper ?

> The guide covers helper + properties placement, the measurement
> procedure, and points at the utility.
> 
> Tested locally on ThinkPad X9-15 Gen 1 / imx471 (same method as the
> earlier measurement write-up):
> 
>   https://gist.github.com/johncronin3/15d9eacbf64f91ecc600fe583686325f
> 
> Happy to rework naming, install path, or docs structure if preferred.
> 
> Thanks,
> John Cronin
> 
> John Cronin (2):
>   utils: Add measure-analogue-gain helper
>   Documentation: Add Camera Sensor Helper guide
> 
>  Documentation/guides/camera-sensor-helper.rst | 146 ++++++
>  Documentation/index.rst                       |   1 +
>  Documentation/meson.build                     |   1 +
>  utils/measure-analogue-gain.py                | 466 ++++++++++++++++++
>  utils/meson.build                             |   7 +
>  5 files changed, 621 insertions(+)
>  create mode 100644 Documentation/guides/camera-sensor-helper.rst
>  create mode 100755 utils/measure-analogue-gain.py