libcamera: src/ipa/libipa/awb_bayes.h Source File

libcamera v0.5.1 Supporting cameras in Linux since 2019 |

Loading...
Searching...
No Matches
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
12#include "libcamera/internal/vector.h"
13#include "libcamera/internal/yaml_parser.h"
14
15#include "awb.h"
16#include "interpolator.h"
17#include "pwl.h"
18
19namespace libcamera {
20
21namespace ipa {
22
23 class AwbBayes : public AwbAlgorithm
24{
25public:
26 AwbBayes() = default;
27
28 int init(const YamlObject &tuningData) override;
29 AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) override;
30 std::optional<RGB<double>> gainsFromColourTemperature(double temperatureK) override;
31 void handleControls(const ControlList &controls) override;
32
33private:
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 */
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:411
libcamera::YamlObject
A class representing the tree structure of the YAML content.
Definition yaml_parser.h:28
libcamera::ipa::AwbAlgorithm
A base class for auto white balance algorithms.
Definition awb.h:37
libcamera::ipa::AwbAlgorithm::controls
const ControlInfoMap::Map & controls() const
Get the controls info map for this algorithm.
Definition awb.h:45
libcamera::ipa::AwbBayes::init
int init(const YamlObject &tuningData) override
Initialize the algorithm with the given tuning data.
Definition awb_bayes.cpp:146
libcamera::ipa::AwbBayes::gainsFromColourTemperature
std::optional< RGB< double > > gainsFromColourTemperature(double temperatureK) override
Compute white balance gains from a colour temperature.
Definition awb_bayes.cpp:273
libcamera::ipa::AwbBayes::calculateAwb
AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) override
Calculate AWB data from the given statistics.
Definition awb_bayes.cpp:284
libcamera::ipa::AwbBayes::handleControls
void handleControls(const ControlList &controls) override
Handle the controls supplied in a request.
Definition awb_bayes.cpp:261
libcamera::ipa::Interpolator
Class for storing, retrieving, and interpolating objects.
Definition interpolator.h:28
libcamera::ipa::Pwl
Describe a univariate piecewise linear function in two-dimensional real space.
Definition pwl.h:22
libcamera::ipa::Pwl::Point
Vector< double, 2 > Point
Describe a point in two-dimensional real space.
Definition pwl.h:24
controls.h
Framework to manage controls related to an object.
interpolator.h
Helper class for linear interpolating a set of objects.
awb.h
Base classes for AWB algorithms.
libcamera::ipa
The IPA (Image Processing Algorithm) namespace.
Definition af.cpp:58
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
pwl.h
Piecewise linear functions.
libcamera::ipa::AwbAlgorithm::ModeConfig
Holds the configuration of a single AWB mode.
Definition awb.h:56
libcamera::ipa::AwbResult
The result of an AWB calculation.
Definition awb.h:23
libcamera::ipa::AwbStats
An abstraction class wrapping hardware-specific AWB statistics.
Definition awb.h:28
vector.h
Vector class.
yaml_parser.h
A YAML parser helper.