libcamera v0.8.0+1-3c8337a0-nvm
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
libcamera::ipa::AgcMeanLuminance Class Reference

A mean-based auto-exposure algorithm. More...

Classes

struct  AgcConstraint
 The boundaries and target for an AeConstraintMode constraint. More...
 
class  Configuration
 A collection of parameters. More...
 
struct  Params
 Collection of parameters for the mean luminance AGC algorithm. More...
 
struct  Result
 Collection of results of the mean luminance AGC algorithm. More...
 
class  Traits
 A collection of callbacks. More...
 

Public Member Functions

 AgcMeanLuminance (Configuration &&config)
 Construct an instance.
 
void configure (utils::Duration lineDuration, const CameraSensorHelper *sensorHelper)
 Configure the exposure mode helpers.
 
void setLimits (utils::Duration minExposureTime, utils::Duration maxExposureTime, double minGain, double maxGain, std::vector< AgcConstraint > constraints)
 Set the ExposureModeHelper limits for this class.
 
const std::map< int32_t, std::vector< AgcConstraint > > & constraintModes () const
 Get the available constraint modes.
 
const std::map< int32_t, ExposureModeHelper > & exposureModeHelpers () const
 Get the available ExposureModeHelpers.
 
Result calculateNewEv (const Params &params)
 Calculate the new exposure value and split it between exposure time and gain.
 
double effectiveYTarget (double lux, double exposureCompensation) const
 Get the currently effective y target.
 

Detailed Description

A mean-based auto-exposure algorithm.

This algorithm calculates an exposure time, analogue and digital gain such that the normalised mean luminance value of an image is driven towards a target, which itself is discovered from tuning data. The algorithm is a two-stage process.

In the first stage, an initial gain value is derived by iteratively comparing the gain-adjusted mean luminance across the entire image against a target, and selecting a value which pushes it as closely as possible towards the target.

In the second stage we calculate the gain required to drive the average of a section of a histogram to a target value, where the target and the boundaries of the section of the histogram used in the calculation are taken from the values defined for the currently configured AeConstraintMode within the configuration. The gain from the first stage is then clamped to the gain from this stage.

The final gain is used to adjust the effective exposure value of the image, and that new exposure value is divided into exposure time, analogue gain and digital gain according to the selected AeExposureMode. This class uses the ExposureModeHelper class to assist in that division, as provided by the configuration.

In order to be able to use this algorithm an IPA module needs to be able to do the following:

  1. Provide a luminance estimation across an entire image.
  2. Provide a luminance Histogram for the image to use in calculating constraint compliance. The precision of the Histogram that is available will determine the supportable precision of the constraints.

IPA modules that want to use this class to implement their AEGC algorithm should derive AgcMeanLuminance::Traits and override the necessary functions. The users can use AgcMeanLuminance::Configuration::parse() to parse the configuration from tuning data to pass to the constructor. Furthermore, they must call configure() and setLimits() in configure(). They may then use calculateNewEv() in process(). If the limits passed to setLimits() change for any reason (for example, in response to a FrameDurationLimit control being passed in queueRequest()) then setLimits() must be called again with the new values.

Constructor & Destructor Documentation

◆ AgcMeanLuminance()

libcamera::ipa::AgcMeanLuminance::AgcMeanLuminance ( Configuration &&  config)

Construct an instance.

Parameters
[in]configThe configuration

This function constructs and instance and initializes it with the configuration parameters specified in config.

Member Function Documentation

◆ calculateNewEv()

AgcMeanLuminance::Result libcamera::ipa::AgcMeanLuminance::calculateNewEv ( const Params &  params)

Calculate the new exposure value and split it between exposure time and gain.

Parameters
[in]paramsThe set of parameters for the exppsure value calculation

Calculate a new exposure value to try to obtain the target. The calculated exposure value is filtered to prevent rapid changes from frame to frame, and divided into exposure time, analogue, quantization and digital gain.

Returns
Tuple of exposure time, analogue gain, quantization gain and digital gain

◆ configure()

void libcamera::ipa::AgcMeanLuminance::configure ( utils::Duration  lineDuration,
const CameraSensorHelper *  sensorHelper 
)

Configure the exposure mode helpers.

Parameters
[in]lineDurationThe sensor line length
[in]sensorHelperThe sensor helper

This function configures the exposure mode helpers so they can correctly take quantization effects into account.

◆ effectiveYTarget()

double libcamera::ipa::AgcMeanLuminance::effectiveYTarget ( double  lux,
double  exposureCompensation 
) const

Get the currently effective y target.

Parameters
[in]luxThe effective lux value
[in]exposureCompensationThe exposure compensation value

This function returns the current y target including exposure compensation.

Returns
The y target value

◆ setLimits()

void libcamera::ipa::AgcMeanLuminance::setLimits ( utils::Duration  minExposureTime,
utils::Duration  maxExposureTime,
double  minGain,
double  maxGain,
std::vector< AgcConstraint >  constraints 
)

Set the ExposureModeHelper limits for this class.

Parameters
[in]minExposureTimeMinimum exposure time to allow
[in]maxExposureTimeMaximum ewposure time to allow
[in]minGainMinimum gain to allow
[in]maxGainMaximum gain to allow
[in]constraintsAdditional constraints to apply

This function calls ExposureModeHelper::setLimits() for each ExposureModeHelper that has been created for this class.


The documentation for this class was generated from the following files: