libcamera v0.7.2+1-aebe4861-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 <memory>
12#include <vector>
13
15
17
19#include "histogram.h"
20#include "pwl.h"
21
22namespace libcamera {
23
24namespace ipa {
25
27{
28public:
31
33 enum class Bound {
34 Lower = 0,
35 Upper = 1
36 };
38 double qLo;
39 double qHi;
41 };
42
43 struct Traits {
44 virtual ~Traits() = default;
45 virtual double estimateLuminance(double gain) const = 0;
46 };
47
48 void configure(utils::Duration lineDuration, const CameraSensorHelper *sensorHelper);
49 int parseTuningData(const ValueNode &tuningData);
50
51 void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
52 double minGain, double maxGain, std::vector<AgcConstraint> constraints);
53
54 const std::map<int32_t, std::vector<AgcConstraint>> &constraintModes() const
55 {
56 return constraintModes_;
57 }
58
59 const std::map<int32_t, ExposureModeHelper> &exposureModeHelpers() const
60 {
61 return exposureModeHelpers_;
62 }
63
73
77
78 [[nodiscard]] Result calculateNewEv(const Params &params);
79
80 double effectiveYTarget(double lux, double exposureCompensation) const;
81
82private:
83 int parseRelativeLuminanceTarget(const ValueNode &tuningData);
84 int parseConstraint(const ValueNode &modeDict, int32_t id);
85 int parseConstraintModes(const ValueNode &tuningData);
86 int parseExposureModes(const ValueNode &tuningData);
87 double estimateInitialGain(const Traits &traits, double yTarget) const;
88 double constraintClampGain(const Params &params, double gain) const;
89 utils::Duration filterExposure(utils::Duration exposureValue);
90
91 utils::Duration filteredExposure_;
92 mutable bool luxWarningEnabled_;
93 Pwl relativeLuminanceTarget_;
94 uint64_t frameCount_;
95
96 std::vector<AgcConstraint> additionalConstraints_;
97 std::map<int32_t, std::vector<AgcConstraint>> constraintModes_;
98 std::map<int32_t, ExposureModeHelper> exposureModeHelpers_;
99};
100
101} /* namespace ipa */
102
103} /* 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:350
const std::map< int32_t, ExposureModeHelper > & exposureModeHelpers() const
Get the ExposureModeHelpers that have been parsed from tuning data.
Definition agc_mean_luminance.h:59
int parseTuningData(const ValueNode &tuningData)
Parse tuning data for AeConstraintMode and AeExposureMode controls.
Definition agc_mean_luminance.cpp:416
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:442
Result calculateNewEv(const Params &params)
Calculate the new exposure value and split it between exposure time and gain.
Definition agc_mean_luminance.cpp:660
double effectiveYTarget(double lux, double exposureCompensation) const
Get the currently effective y target.
Definition agc_mean_luminance.cpp:548
const std::map< int32_t, std::vector< AgcConstraint > > & constraintModes() const
Get the constraint modes that have been parsed from tuning data.
Definition agc_mean_luminance.h:54
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:32
double qHi
The upper quantile to use for the constraint.
Definition agc_mean_luminance.h:39
Bound
Specify whether the constraint defines a lower or upper bound.
Definition agc_mean_luminance.h:33
@ 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:38
Bound bound
The type of constraint bound.
Definition agc_mean_luminance.h:37
Pwl yTarget
The luminance target for the constraint.
Definition agc_mean_luminance.h:40
Collection of parameters for the mean luminance AGC algorithm.
Definition agc_mean_luminance.h:64
const Traits & traits
The traits object implementing the necessary functions.
Definition agc_mean_luminance.h:65
utils::Duration effectiveExposureValue
The EV applied to the frame from which the statistics in use derive.
Definition agc_mean_luminance.h:67
const Histogram & yHist
A histogram from the ISP statistics to use in constraining the calculated gain.
Definition agc_mean_luminance.h:66
uint32_t constraintModeIndex
The index of the constraint mode to use.
Definition agc_mean_luminance.h:68
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:71
uint32_t exposureModeIndex
The index of the exposure mode to use.
Definition agc_mean_luminance.h:69
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:70
Collection of results of the mean luminance AGC algorithm.
Definition agc_mean_luminance.h:74
double yTarget
The current y target including exposure compensation.
Definition agc_mean_luminance.h:75
A collection of callbacks.
Definition agc_mean_luminance.h:43
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:32
Miscellaneous utility functions.
Data structure to manage tree of values.