summaryrefslogtreecommitdiff
path: root/src/ipa/libipa/awb.h
blob: 95be01b06b72cb3583cbb95640f01d1221f28233 (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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2024 Ideas on Board Oy
 *
 * Generic AWB algorithms
 */

#pragma once

#include <libcamera/controls.h>
#include "libcamera/internal/vector.h"
#include "libcamera/internal/yaml_parser.h"

namespace libcamera {

namespace ipa {

struct AwbResult {
	RGB<double> gains;
	double colourTemperature;
};

struct AwbStats {
	virtual double computeColourError(const RGB<double> &gains) const = 0;
	virtual RGB<double> getRGBMeans() const = 0;
};

class AwbAlgorithm
{
public:
	virtual ~AwbAlgorithm() = default;

	virtual int init(const YamlObject &tuningData) = 0;
	virtual AwbResult calculateAwb(const AwbStats &stats, int lux) = 0;
	virtual RGB<double> gainsFromColourTemperature(double colourTemperature) = 0;

	const ControlInfoMap::Map &controls() const
	{
		return controls_;
	}

	virtual void handleControls([[maybe_unused]] const ControlList &controls) {}

protected:
	ControlInfoMap::Map controls_;
};

} /* namespace ipa */

} /* namespace libcamera */