[v2,00/17] Add Bayesian AWB algorithm to libipa and rkisp1
mbox series

Message ID 20250123114204.79321-1-stefan.klug@ideasonboard.com
Headers show
Series
  • Add Bayesian AWB algorithm to libipa and rkisp1
Related show

Message

Stefan Klug Jan. 23, 2025, 11:40 a.m. UTC
The Bayesian AWB algorithm improves the AWB performance by taking prior
likelihoods for a colour temperature given a measured lux level into
account.

The algorithm was first implemented by RaspberryPi and is documented in
the RaspberryPi camera guide. This series takes that implementation and
adapts it for the use on libipa and the rkisp1 pipeline. It still keeps
the grey world algorithm as a fallback or as a simple alternative that
does not require any tuning.

Patches 1-2 add small utility functions in lipia.

Patches 3-7 prepare for the bayes AWB integration. First some base
classes are added to be able to implement different AWB algorithms with
a common interface. Then the grey world algorithm from rkisp1 is moved
into libipa.

Patches 8-10 add the bayes AWB algorithm to libtuning and libipa and
integrate it into the rkisp1 IPA.

Patch 11 is a small fix to start the camera with better default gains.

In version 2 the review comments were handled. Additionally the lux
support was completed with a tuning module and corresponding plumbing
(patches 12-14). On top of that the bayesian AWB algorithm logging was
further improved and the scale of the priors was changed to be linear. I
kept the last three patches at the end because they show structural
changes made compared to the original version (which was already
reviewed). I could squash them into the corresponding earlier patches if
needed.

Please see the individual patches for a detailed changelog.

Best regards,
Stefan


Stefan Klug (17):
  libipa: interpolator: Add accessor to internal data
  libipa: pwl: Add clear() function
  libipa: Add AWB algorithm base class
  libipa: awb: Add helper functions for AWB mode support
  libipa: Add grey world AWB algorithm
  ipa: rkisp1: Move calculation of RGB means into own function
  ipa: rkisp1: Use grey world algorithm from libipa
  libtuning: module: awb: Add bayes AWB support
  libipa: Add bayesian AWB algorithm
  ipa: rkisp1: Add support for bayes AWB algorithm from libipa
  ipa: rkisp1: awb: Apply gains based on default colour temperature on
    start
  libtuning: Add module for lux calibration
  utils: tuning: rkisp1: Add lux module
  libipa: lux: Update for a normalized referenceY to 1
  libipa: awb_bayes: Add logging of value limits
  libipa: awb_bayes: Remove overly verbose log messages
  libipa: awb_bayes: Change the probabilities from log space into linear
    space

 src/ipa/libipa/awb.cpp                        | 265 ++++++++++
 src/ipa/libipa/awb.h                          |  64 +++
 src/ipa/libipa/awb_bayes.cpp                  | 500 ++++++++++++++++++
 src/ipa/libipa/awb_bayes.h                    |  67 +++
 src/ipa/libipa/awb_grey.cpp                   | 114 ++++
 src/ipa/libipa/awb_grey.h                     |  35 ++
 src/ipa/libipa/interpolator.cpp               |  10 +-
 src/ipa/libipa/interpolator.h                 |   5 +
 src/ipa/libipa/lux.cpp                        |  16 +-
 src/ipa/libipa/lux.h                          |   3 +-
 src/ipa/libipa/meson.build                    |   6 +
 src/ipa/libipa/pwl.cpp                        |   5 +
 src/ipa/libipa/pwl.h                          |   1 +
 src/ipa/rkisp1/algorithms/awb.cpp             | 166 ++++--
 src/ipa/rkisp1/algorithms/awb.h               |   7 +-
 src/ipa/rkisp1/algorithms/lux.cpp             |   4 -
 utils/tuning/config-example.yaml              |  44 +-
 utils/tuning/libtuning/modules/awb/awb.py     |  16 +-
 utils/tuning/libtuning/modules/awb/rkisp1.py  |  21 +-
 .../tuning/libtuning/modules/lux/__init__.py  |   6 +
 utils/tuning/libtuning/modules/lux/lux.py     |  70 +++
 utils/tuning/libtuning/modules/lux/rkisp1.py  |  22 +
 utils/tuning/rkisp1.py                        |  14 +-
 23 files changed, 1367 insertions(+), 94 deletions(-)
 create mode 100644 src/ipa/libipa/awb.cpp
 create mode 100644 src/ipa/libipa/awb.h
 create mode 100644 src/ipa/libipa/awb_bayes.cpp
 create mode 100644 src/ipa/libipa/awb_bayes.h
 create mode 100644 src/ipa/libipa/awb_grey.cpp
 create mode 100644 src/ipa/libipa/awb_grey.h
 create mode 100644 utils/tuning/libtuning/modules/lux/__init__.py
 create mode 100644 utils/tuning/libtuning/modules/lux/lux.py
 create mode 100644 utils/tuning/libtuning/modules/lux/rkisp1.py