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

libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
awb.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 * Generic AWB algorithms
6 */
7
8#pragma once
9
10#include <map>
11#include <optional>
12
13#include <libcamera/control_ids.h>
14#include <libcamera/controls.h>
15
16#include "libcamera/internal/value_node.h"
17#include "libcamera/internal/vector.h"
18
19namespace libcamera {
20
21namespace ipa {
22
23 struct AwbResult {
24 RGB<double> gains;
25 double colourTemperature;
26};
27
28 struct AwbStats {
29 virtual double computeColourError(const RGB<double> &gains) const = 0;
30 virtual RGB<double> rgbMeans() const = 0;
31
32protected:
33 ~AwbStats() = default;
34};
35
36 class AwbAlgorithm
37{
38public:
39 virtual ~AwbAlgorithm() = default;
40
41 virtual int init(const ValueNode &tuningData) = 0;
42 virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;
43 virtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;
44
45 const ControlInfoMap::Map &controls() const
46 {
47 return controls_;
48 }
49
50 virtual void handleControls([[maybe_unused]] const ControlList &controls) {}
51
52protected:
53 int parseModeConfigs(const ValueNode &tuningData,
54 const ControlValue &def = {});
55
56 struct ModeConfig {
57 double ctHi;
58 double ctLo;
59 };
60
61 ControlInfoMap::Map controls_;
62 std::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;
63};
64
65} /* namespace ipa */
66
67} /* namespace libcamera */
libcamera::ControlInfoMap::Map
std::unordered_map< const ControlId *, ControlInfo > Map
The base std::unsorted_map<> container.
Definition controls.h:367
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
libcamera::ControlValue
Abstract type representing the value of a control.
Definition controls.h:134
libcamera::ValueNode
A class representing a tree structure of values.
Definition value_node.h:27
libcamera::ipa::AwbAlgorithm
A base class for auto white balance algorithms.
Definition awb.h:37
libcamera::ipa::AwbAlgorithm::init
virtual int init(const ValueNode &tuningData)=0
Initialize the algorithm with the given tuning data.
libcamera::ipa::AwbAlgorithm::controls
const ControlInfoMap::Map & controls() const
Get the controls info map for this algorithm.
Definition awb.h:45
libcamera::ipa::AwbAlgorithm::controls_
ControlInfoMap::Map controls_
Controls info map for the controls provided by the algorithm.
Definition awb.h:61
libcamera::ipa::AwbAlgorithm::gainsFromColourTemperature
virtual std::optional< RGB< double > > gainsFromColourTemperature(double colourTemperature)=0
Compute white balance gains from a colour temperature.
libcamera::ipa::AwbAlgorithm::handleControls
virtual void handleControls(const ControlList &controls)
Handle the controls supplied in a request.
Definition awb.h:50
libcamera::ipa::AwbAlgorithm::parseModeConfigs
int parseModeConfigs(const ValueNode &tuningData, const ControlValue &def={})
Parse the mode configurations from the tuning data.
Definition awb.cpp:165
libcamera::ipa::AwbAlgorithm::calculateAwb
virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux)=0
Calculate AWB data from the given statistics.
libcamera::ipa::AwbAlgorithm::modes_
std::map< controls::AwbModeEnum, AwbAlgorithm::ModeConfig > modes_
Map of all configured modes.
Definition awb.h:62
control_ids.h
Camera controls identifiers.
controls.h
Framework to manage controls related to an object.
libcamera::ipa
The IPA (Image Processing Algorithm) namespace.
Definition af.cpp:58
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::RGB
Vector< T, 3 > RGB
A Vector of 3 elements representing an RGB pixel value.
Definition vector.h:318
libcamera::ipa::AwbAlgorithm::ModeConfig
Holds the configuration of a single AWB mode.
Definition awb.h:56
libcamera::ipa::AwbAlgorithm::ModeConfig::ctLo
double ctLo
The lowest valid colour temperature of that mode.
Definition awb.h:58
libcamera::ipa::AwbAlgorithm::ModeConfig::ctHi
double ctHi
The highest valid colour temperature of that mode.
Definition awb.h:57
libcamera::ipa::AwbResult
The result of an AWB calculation.
Definition awb.h:23
libcamera::ipa::AwbResult::colourTemperature
double colourTemperature
The calculated colour temperature in Kelvin.
Definition awb.h:25
libcamera::ipa::AwbResult::gains
RGB< double > gains
The calculated white balance gains.
Definition awb.h:24
libcamera::ipa::AwbStats
An abstraction class wrapping hardware-specific AWB statistics.
Definition awb.h:28
libcamera::ipa::AwbStats::computeColourError
virtual double computeColourError(const RGB< double > &gains) const =0
Compute an error value for when the given gains would be applied.
libcamera::ipa::AwbStats::rgbMeans
virtual RGB< double > rgbMeans() const =0
Get RGB means of the statistics.
value_node.h
Data structure to manage tree of values.
vector.h
Vector class.