@@ -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 sensors gain
+ * is set to gainCode(gain).
+ *
+ * It shall be guaranteed that gainCode(gain) == gainCode(quantizeGain(gain)).
+ *
+ * If \a quantizationGain is provided it is filled with the gain that must be
+ * applied to correct 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 {