blob: 23bf88061118a5d70e6e7f416bcc0f1d9c364764 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2024 Ideas on Board Oy
*
* Base class for bayes AWB algorithms
*/
#pragma once
#include <map>
#include <memory>
#include <tuple>
#include <vector>
#include <libcamera/base/utils.h>
#include <libcamera/control_ids.h>
#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;
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 */
|