libcamera  v0.5.0+11-5d1380f7
Supporting cameras in Linux since 2019
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
awb.h
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 
12 #include <libcamera/control_ids.h>
13 #include <libcamera/controls.h>
14 
17 
18 namespace libcamera {
19 
20 namespace ipa {
21 
22 struct AwbResult {
25 };
26 
27 struct AwbStats {
28  virtual double computeColourError(const RGB<double> &gains) const = 0;
29  virtual RGB<double> rgbMeans() const = 0;
30 
31 protected:
32  ~AwbStats() = default;
33 };
34 
36 {
37 public:
38  virtual ~AwbAlgorithm() = default;
39 
40  virtual int init(const YamlObject &tuningData) = 0;
41  virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;
42  virtual RGB<double> gainsFromColourTemperature(double colourTemperature) = 0;
43 
45  {
46  return controls_;
47  }
48 
49  virtual void handleControls([[maybe_unused]] const ControlList &controls) {}
50 
51 protected:
52  int parseModeConfigs(const YamlObject &tuningData,
53  const ControlValue &def = {});
54 
55  struct ModeConfig {
56  double ctHi;
57  double ctLo;
58  };
59 
61  std::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;
62 };
63 
64 } /* namespace ipa */
65 
66 } /* namespace libcamera */
double ctLo
The lowest valid colour temperature of that mode.
Definition: awb.h:57
Holds the configuration of a single AWB mode.
Definition: awb.h:55
RGB< double > gains
The calculated white balance gains.
Definition: awb.h:23
Camera controls identifiers.
Top-level libcamera namespace.
Definition: backtrace.h:17
Abstract type representing the value of a control.
Definition: controls.h:133
std::map< controls::AwbModeEnum, AwbAlgorithm::ModeConfig > modes_
Map of all configured modes.
Definition: awb.h:61
std::unordered_map< const ControlId *, ControlInfo > Map
The base std::unsorted_map<> container.
Definition: controls.h:369
ControlInfoMap::Map controls_
Controls info map for the controls provided by the algorithm.
Definition: awb.h:60
Vector class.
A class representing the tree structure of the YAML content.
Definition: yaml_parser.h:27
double colourTemperature
The calculated colour temperature in Kelvin.
Definition: awb.h:24
An abstraction class wrapping hardware-specific AWB statistics.
Definition: awb.h:27
const ControlIdMap controls
List of all supported libcamera controls.
Definition: control_ids.cpp:2205
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
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.
double ctHi
The highest valid colour temperature of that mode.
Definition: awb.h:56
virtual void handleControls([[maybe_unused]] const ControlList &controls)
Handle the controls supplied in a request.
Definition: awb.h:49