libcamera  v0.4.0
Supporting cameras in Linux since 2019
Public Member Functions | List of all members
libcamera::ipa::ExposureModeHelper Class Reference

Class for splitting exposure into exposure time and total gain. More...

Public Member Functions

 ExposureModeHelper (const Span< std::pair< utils::Duration, double >> stages)
 Construct an ExposureModeHelper instance. More...
 
void setLimits (utils::Duration minExposureTime, utils::Duration maxExposureTime, double minGain, double maxGain)
 Set the exposure time and gain limits. More...
 
std::tuple< utils::Duration, double, double > splitExposure (utils::Duration exposure) const
 Split exposure into exposure time and gain. More...
 
utils::Duration minExposureTime () const
 Retrieve the configured minimum exposure time limit set through setLimits() More...
 
utils::Duration maxExposureTime () const
 Retrieve the configured maximum exposure time set through setLimits() More...
 
double minGain () const
 Retrieve the configured minimum gain set through setLimits() More...
 
double maxGain () const
 Retrieve the configured maximum gain set through setLimits() More...
 

Detailed Description

Class for splitting exposure into exposure time and total gain.

The ExposureModeHelper class provides a standard interface through which an AEGC algorithm can divide exposure between exposure time and gain. It is configured with a set of exposure time and gain pairs and works by initially fixing gain at 1.0 and increasing exposure time up to the exposure time value from the first pair in the set in an attempt to meet the required exposure value.

If the required exposure is not achievable by the first exposure time value alone it ramps gain up to the value from the first pair in the set. If the required exposure is still not met it then allows exposure time to ramp up to the exposure time value from the second pair in the set, and continues in this vein until either the required exposure time is met, or else the hardware's exposure time or gain limits are reached.

This method allows users to strike a balance between a well-exposed image and an acceptable frame-rate, as opposed to simply maximising exposure time followed by gain. The same helpers can be used to perform the latter operation if needed by passing an empty set of pairs to the initialisation function.

The gain values may exceed a camera sensor's analogue gain limits if either it or the IPA is also capable of digital gain. The configure() function must be called with the hardware's limits to inform the helper of those constraints. Any gain that is needed will be applied as analogue gain first until the hardware's limit is reached, following which digital gain will be used.

Constructor & Destructor Documentation

◆ ExposureModeHelper()

libcamera::ipa::ExposureModeHelper::ExposureModeHelper ( const Span< std::pair< utils::Duration, double >>  stages)

Construct an ExposureModeHelper instance.

Parameters
[in]stagesThe vector of paired exposure time and gain limits

The input stages are exposure time and total gain pairs; the gain encompasses both analogue and digital gain.

The vector of stages may be empty. In that case, the helper will simply use the runtime limits set through setLimits() instead.

Member Function Documentation

◆ maxExposureTime()

libcamera::ipa::ExposureModeHelper::maxExposureTime ( ) const
inline

Retrieve the configured maximum exposure time set through setLimits()

Returns
The maxExposureTime_ value

◆ maxGain()

libcamera::ipa::ExposureModeHelper::maxGain ( ) const
inline

Retrieve the configured maximum gain set through setLimits()

Returns
The maxGain_ value

◆ minExposureTime()

libcamera::ipa::ExposureModeHelper::minExposureTime ( ) const
inline

Retrieve the configured minimum exposure time limit set through setLimits()

Returns
The minExposureTime_ value

◆ minGain()

libcamera::ipa::ExposureModeHelper::minGain ( ) const
inline

Retrieve the configured minimum gain set through setLimits()

Returns
The minGain_ value

◆ setLimits()

void libcamera::ipa::ExposureModeHelper::setLimits ( utils::Duration  minExposureTime,
utils::Duration  maxExposureTime,
double  minGain,
double  maxGain 
)

Set the exposure time and gain limits.

Parameters
[in]minExposureTimeThe minimum exposure time supported
[in]maxExposureTimeThe maximum exposure time supported
[in]minGainThe minimum analogue gain supported
[in]maxGainThe maximum analogue gain supported

This function configures the exposure time and analogue gain limits that need to be adhered to as the helper divides up exposure. Note that this function must be called whenever those limits change and before splitExposure() is used.

If the algorithm using the helpers needs to indicate that either exposure time or analogue gain or both should be fixed it can do so by setting both the minima and maxima to the same value.

◆ splitExposure()

std::tuple< utils::Duration, double, double > libcamera::ipa::ExposureModeHelper::splitExposure ( utils::Duration  exposure) const

Split exposure into exposure time and gain.

Parameters
[in]exposureExposure value

This function divides a given exposure into exposure time, analogue and digital gain by iterating through stages of exposure time and gain limits. At each stage the current stage's exposure time limit is multiplied by the previous stage's gain limit (or 1.0 initially) to see if the combination of the two can meet the required exposure. If they cannot then the current stage's exposure time limit is multiplied by the same stage's gain limit to see if that combination can meet the required exposure time. If they cannot then the function moves to consider the next stage.

When a combination of exposure time and gain stage limits are found that are sufficient to meet the required exposure, the function attempts to reduce exposure time as much as possible whilst fixing gain and still meeting the exposure. If a runtime limit prevents exposure time from being lowered enough to meet the exposure with gain fixed at the stage limit, gain is also lowered to compensate.

Once the exposure time and gain values are ascertained, gain is assigned as analogue gain as much as possible, with digital gain only in use if the maximum analogue gain runtime limit is unable to accommodate the exposure value.

If no combination of exposure time and gain limits is found that meets the required exposure, the helper falls-back to simply maximising the exposure time first, followed by analogue gain, followed by digital gain.

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

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