libcamera  v0.5.0+37-12007759
Supporting cameras in Linux since 2019
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
awb_bayes.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2024 Ideas on Board Oy
4  *
5  * Base class for bayes AWB algorithms
6  */
7 
8 #pragma once
9 
10 #include <libcamera/controls.h>
11 
14 
15 #include "awb.h"
16 #include "interpolator.h"
17 #include "pwl.h"
18 
19 namespace libcamera {
20 
21 namespace ipa {
22 
23 class AwbBayes : public AwbAlgorithm
24 {
25 public:
26  AwbBayes() = default;
27 
28  int init(const YamlObject &tuningData) override;
29  AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) override;
30  RGB<double> gainsFromColourTemperature(double temperatureK) override;
31  void handleControls(const ControlList &controls) override;
32 
33 private:
34  int readPriors(const YamlObject &tuningData);
35 
36  void fineSearch(double &t, double &r, double &b, ipa::Pwl const &prior,
37  const AwbStats &stats) const;
38  double coarseSearch(const ipa::Pwl &prior, const AwbStats &stats) const;
39  double interpolateQuadratic(ipa::Pwl::Point const &a,
40  ipa::Pwl::Point const &b,
41  ipa::Pwl::Point const &c) const;
42 
43  Interpolator<Pwl> priors_;
44  Interpolator<Vector<double, 2>> colourGainCurve_;
45 
46  ipa::Pwl ctR_;
47  ipa::Pwl ctB_;
48  ipa::Pwl ctRInverse_;
49  ipa::Pwl ctBInverse_;
50 
51  double transversePos_;
52  double transverseNeg_;
53 
54  ModeConfig *currentMode_ = nullptr;
55 };
56 
57 } /* namespace ipa */
58 
59 } /* namespace libcamera */
Piecewise linear functions.
Holds the configuration of a single AWB mode.
Definition: awb.h:55
AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) override
Calculate AWB data from the given statistics.
Definition: awb_bayes.cpp:284
Top-level libcamera namespace.
Definition: backtrace.h:17
Class for storing, retrieving, and interpolating objects.
Definition: interpolator.h:27
Describe a univariate piecewise linear function in two-dimensional real space.
Definition: pwl.h:21
int init(const YamlObject &tuningData) override
Initialize the algorithm with the given tuning data.
Definition: awb_bayes.cpp:146
RGB< double > gainsFromColourTemperature(double temperatureK) override
Compute white balance gains from a colour temperature.
Definition: awb_bayes.cpp:273
Implementation of a bayesian auto white balance algorithm.
Definition: awb_bayes.h:23
Vector class.
A class representing the tree structure of the YAML content.
Definition: yaml_parser.h:27
An abstraction class wrapping hardware-specific AWB statistics.
Definition: awb.h:27
The result of an AWB calculation.
Definition: awb.h:22
Associate a list of ControlId with their values for an object.
Definition: controls.h:410
Framework to manage controls related to an object.
A base class for auto white balance algorithms.
Definition: awb.h:35
Helper class for linear interpolating a set of objects.
Vector class.
Definition: vector.h:33
const ControlInfoMap::Map & controls() const
Get the controls info map for this algorithm.
Definition: awb.h:44
A YAML parser helper.