libipa: camera_sensor_helper: Add quantizeGain() function
Add a small utility function that calculates the quantized gain that gets applied by a sensor when the gain code is set to gainCode(gain). This is needed by algorithms to calculate a digital correction gain that gets applied to mitigate the error introduce by quantization. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
737f6f8da1
commit
1400058ed4
@@ -131,6 +131,29 @@ double CameraSensorHelper::gain(uint32_t gainCode) const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Quantize the given gain value
|
||||
* \param[in] _gain The real gain
|
||||
* \param[out] quantizationGain The gain that is lost due to quantization
|
||||
*
|
||||
* This function returns the actual gain that is applied when the sensor's gain
|
||||
* is set to gainCode(_gain).
|
||||
*
|
||||
* It shall be guaranteed that gainCode(_gain) == gainCode(quantizeGain(_gain)).
|
||||
*
|
||||
* If \a quantizationGain is provided it is populated with the gain that must be
|
||||
* applied on top to correct for the losses due to quantization.
|
||||
*
|
||||
* \return The quantized real gain
|
||||
*/
|
||||
double CameraSensorHelper::quantizeGain(double _gain, double *quantizationGain) const
|
||||
{
|
||||
double g = gain(gainCode(_gain));
|
||||
if (quantizationGain)
|
||||
*quantizationGain = _gain / g;
|
||||
return g;
|
||||
}
|
||||
|
||||
/**
|
||||
* \struct CameraSensorHelper::AnalogueGainLinear
|
||||
* \brief Analogue gain constants for the linear gain model
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
std::optional<int16_t> blackLevel() const { return blackLevel_; }
|
||||
virtual uint32_t gainCode(double gain) const;
|
||||
virtual double gain(uint32_t gainCode) const;
|
||||
double quantizeGain(double gain, double *quantizationGain) const;
|
||||
|
||||
protected:
|
||||
struct AnalogueGainLinear {
|
||||
|
||||
Reference in New Issue
Block a user