libcamera v0.8.0+1-3c8337a0-nvm
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
agc_mean_luminance.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 agc_mean_luminance.h - Base class for mean luminance AGC algorithms
6 */
7
8#pragma once
9
10#include <map>
11#include <optional>
12#include <vector>
13
15
17
19#include "histogram.h"
20#include "pwl.h"
21
22namespace libcamera {
23
24namespace ipa {
25
27{
28public:
30 enum class Bound {
31 Lower = 0,
32 Upper = 1
33 };
35 double qLo;
36 double qHi;
38 };
39
40 struct Traits {
41 virtual ~Traits() = default;
42 virtual double estimateLuminance(double gain) const = 0;
43 };
44
47 std::map<int32_t, std::vector<AgcConstraint>> constraintModes;
48 std::map<int32_t, ExposureModeHelper> exposureModeHelpers;
49
50 [[nodiscard]]
51 static std::optional<Configuration> parse(const ValueNode &tuningData);
52 };
53
56
57 void configure(utils::Duration lineDuration, const CameraSensorHelper *sensorHelper);
58 void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
59 double minGain, double maxGain, std::vector<AgcConstraint> constraints);
60
61 const std::map<int32_t, std::vector<AgcConstraint>> &constraintModes() const
62 {
63 return constraintModes_;
64 }
65
66 const std::map<int32_t, ExposureModeHelper> &exposureModeHelpers() const
67 {
68 return exposureModeHelpers_;
69 }
70
80
84
85 [[nodiscard]] Result calculateNewEv(const Params &params);
86
87 double effectiveYTarget(double lux, double exposureCompensation) const;
88
89private:
90 double estimateInitialGain(const Traits &traits, double yTarget) const;
91 double constraintClampGain(const Params &params, double gain) const;
92 utils::Duration filterExposure(utils::Duration exposureValue);
93
94 utils::Duration filteredExposure_;
95 mutable bool luxWarningEnabled_;
96 uint64_t frameCount_;
97
98 std::vector<AgcConstraint> additionalConstraints_;
99
100 Pwl relativeLuminanceTarget_;
101 std::map<int32_t, std::vector<AgcConstraint>> constraintModes_;
102 std::map<int32_t, ExposureModeHelper> exposureModeHelpers_;
103};
104
105} /* namespace ipa */
106
107} /* namespace libcamera */
A class representing a tree structure of values.
Definition value_node.h:27
A mean-based auto-exposure algorithm.
Definition agc_mean_luminance.h:27
void configure(utils::Duration lineDuration, const CameraSensorHelper *sensorHelper)
Configure the exposure mode helpers.
Definition agc_mean_luminance.cpp:518
const std::map< int32_t, ExposureModeHelper > & exposureModeHelpers() const
Get the available ExposureModeHelpers.
Definition agc_mean_luminance.h:66
void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime, double minGain, double maxGain, std::vector< AgcConstraint > constraints)
Set the ExposureModeHelper limits for this class.
Definition agc_mean_luminance.cpp:540
Result calculateNewEv(const Params &params)
Calculate the new exposure value and split it between exposure time and gain.
Definition agc_mean_luminance.cpp:759
double effectiveYTarget(double lux, double exposureCompensation) const
Get the currently effective y target.
Definition agc_mean_luminance.cpp:647
const std::map< int32_t, std::vector< AgcConstraint > > & constraintModes() const
Get the available constraint modes.
Definition agc_mean_luminance.h:61
Base class for computing sensor tuning parameters using sensor-specific constants.
Definition camera_sensor_helper.h:24
The base class for creating histograms.
Definition histogram.h:23
Describe a univariate piecewise linear function in two-dimensional real space.
Definition pwl.h:22
Helper class from std::chrono::duration that represents a time duration in nanoseconds with double pr...
Definition utils.h:331
Helper class that performs computations relating to exposure.
Class to represent Histograms and manipulate them.
Top-level libcamera namespace.
Definition backtrace.h:17
Piecewise linear functions.
The boundaries and target for an AeConstraintMode constraint.
Definition agc_mean_luminance.h:29
double qHi
The upper quantile to use for the constraint.
Definition agc_mean_luminance.h:36
Bound
Specify whether the constraint defines a lower or upper bound.
Definition agc_mean_luminance.h:30
@ Upper
The constraint defines an upper bound.
@ Lower
The constraint defines a lower bound.
double qLo
The lower quantile to use for the constraint.
Definition agc_mean_luminance.h:35
Bound bound
The type of constraint bound.
Definition agc_mean_luminance.h:34
Pwl yTarget
The luminance target for the constraint.
Definition agc_mean_luminance.h:37
A collection of parameters.
Definition agc_mean_luminance.h:45
Pwl relativeLuminanceTarget
The relative mean luminance target by lux value.
Definition agc_mean_luminance.h:46
static std::optional< Configuration > parse(const ValueNode &tuningData)
Parse tuning data.
Definition agc_mean_luminance.cpp:442
std::map< int32_t, ExposureModeHelper > exposureModeHelpers
The available exposure modes.
Definition agc_mean_luminance.h:48
std::map< int32_t, std::vector< AgcConstraint > > constraintModes
The available constraint modes.
Definition agc_mean_luminance.h:47
Collection of parameters for the mean luminance AGC algorithm.
Definition agc_mean_luminance.h:71
const Traits & traits
The traits object implementing the necessary functions.
Definition agc_mean_luminance.h:72
utils::Duration effectiveExposureValue
The EV applied to the frame from which the statistics in use derive.
Definition agc_mean_luminance.h:74
const Histogram & yHist
A histogram from the ISP statistics to use in constraining the calculated gain.
Definition agc_mean_luminance.h:73
uint32_t constraintModeIndex
The index of the constraint mode to use.
Definition agc_mean_luminance.h:75
double exposureCompensation
The exposure compensation value to be used in the AGC calculations It is expressed as gain instead of...
Definition agc_mean_luminance.h:78
uint32_t exposureModeIndex
The index of the exposure mode to use.
Definition agc_mean_luminance.h:76
double lux
The lux level to be used in the AGC calculations. A value of 0 means no measurement and a default val...
Definition agc_mean_luminance.h:77
Collection of results of the mean luminance AGC algorithm.
Definition agc_mean_luminance.h:81
double yTarget
The current y target including exposure compensation.
Definition agc_mean_luminance.h:82
A collection of callbacks.
Definition agc_mean_luminance.h:40
virtual double estimateLuminance(double gain) const =0
Estimate the luminance of an image, adjusted by a given gain.
Result of splitExposure()
Definition exposure_mode_helper.h:34
Miscellaneous utility functions.
Data structure to manage tree of values.