Loading...
Searching...
No Matches
awb_bayes.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2024 Ideas on Board Oy
*
* Base class for bayes AWB algorithms
*/
#pragma once
#include <libcamera/controls.h>
#include "libcamera/internal/vector.h"
#include "libcamera/internal/yaml_parser.h"
#include "awb.h"
#include "interpolator.h"
#include "pwl.h"
namespace libcamera {
namespace ipa {
class AwbBayes : public AwbAlgorithm
{
public:
AwbBayes() = default;
int init(const YamlObject &tuningData) override;
AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) override;
std::optional<RGB<double>> gainsFromColourTemperature(double temperatureK) override;
void handleControls(const ControlList &controls) override;
private:
int readPriors(const YamlObject &tuningData);
void fineSearch(double &t, double &r, double &b, ipa::Pwl const &prior,
const AwbStats &stats) const;
double coarseSearch(const ipa::Pwl &prior, const AwbStats &stats) const;
double interpolateQuadratic(ipa::Pwl::Point const &a,
ipa::Pwl::Point const &b,
ipa::Pwl::Point const &c) const;
Interpolator<Pwl> priors_;
Interpolator<Vector<double, 2>> colourGainCurve_;
ipa::Pwl ctR_;
ipa::Pwl ctB_;
ipa::Pwl ctRInverse_;
ipa::Pwl ctBInverse_;
double transversePos_;
double transverseNeg_;
ModeConfig *currentMode_ = nullptr;
};
} /* namespace ipa */
} /* namespace libcamera */
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
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.