c699d26573
In the grey world AWB case, if no colour gains are contained in the tuning file, the colour gains get reset to 1 when the colour temperature is set manually. This is unexpected and undesirable. Allow the gainsFromColourTemp() function to return a std::nullopt to handle that case. While at it, remove an unnecessary import from rkisp1/algorithms/awb.h. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
68 lines
1.3 KiB
C++
68 lines
1.3 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2024 Ideas on Board Oy
|
|
*
|
|
* Generic AWB algorithms
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <optional>
|
|
|
|
#include <libcamera/control_ids.h>
|
|
#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> rgbMeans() const = 0;
|
|
|
|
protected:
|
|
~AwbStats() = default;
|
|
};
|
|
|
|
class AwbAlgorithm
|
|
{
|
|
public:
|
|
virtual ~AwbAlgorithm() = default;
|
|
|
|
virtual int init(const YamlObject &tuningData) = 0;
|
|
virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;
|
|
virtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;
|
|
|
|
const ControlInfoMap::Map &controls() const
|
|
{
|
|
return controls_;
|
|
}
|
|
|
|
virtual void handleControls([[maybe_unused]] const ControlList &controls) {}
|
|
|
|
protected:
|
|
int parseModeConfigs(const YamlObject &tuningData,
|
|
const ControlValue &def = {});
|
|
|
|
struct ModeConfig {
|
|
double ctHi;
|
|
double ctLo;
|
|
};
|
|
|
|
ControlInfoMap::Map controls_;
|
|
std::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;
|
|
};
|
|
|
|
} /* namespace ipa */
|
|
|
|
} /* namespace libcamera */
|