| Message ID | 20251114-exposure-limits-v3-7-b7c07feba026@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Jacopo Mondi (2025-11-14 23:17:02) > After having introduced CameraSensorHelper::maxShutterTime() which > calculates the maximum shutter time which can be achieved given > a frame duration, this patch introduces the opposite operation, that > given a desired shutter time calculates what is the minimum frame > duration required to achieve it. > > The intended users of this function are IPA modules that after having > calculated a new exposure time need to regulate the frame duration to > achieve it. > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > --- > src/ipa/libipa/camera_sensor_helper.cpp | 33 +++++++++++++++++++++++++++++++++ > src/ipa/libipa/camera_sensor_helper.h | 2 ++ > 2 files changed, 35 insertions(+) > > diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp > index 3c3e24c1cdefa4bca059352482bb29654a37b42f..a38f1eb40446b98a0db4642f086742674a13854f 100644 > --- a/src/ipa/libipa/camera_sensor_helper.cpp > +++ b/src/ipa/libipa/camera_sensor_helper.cpp > @@ -184,6 +184,39 @@ utils::Duration CameraSensorHelper::maxShutterTime(utils::Duration maxFrameDurat > return maxFrameDuration - exposureMargin * lineDuration; > } > > +/** > + * \brief Compute the minimum frame duration required for a desired exposure > + * \param[in] shutterTime The shutter time > + * \param[in] lineDuration The current sensor line duration > + * > + * This function returns the minimum frame duration required to achieve the > + * desired \a shutterTime. The frame duration is calculated by adding to > + * \a shutterTime the difference between the frame length and the maximum > + * achievable integration time. > + * > + * The intended users of this function are IPA modules that want to calculate > + * the minium required frame duration give a newly calculated shutter time. s/minium/minimum/ s/give/given/ Otherwise, looks good to me. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > + * > + * \todo The line duration should be a property of the CameraSensorHelper class > + * instead of being provided by the IPA. > + * > + * \return The minimum frame duration required to achieve the desired shutter > + * time > + */ > +utils::Duration CameraSensorHelper::minFrameDuration(utils::Duration shutterTime, > + utils::Duration lineDuration) const > +{ > + /* Use a static to rate-limit the error message. */ > + static uint32_t exposureMargin = exposureMargin_.has_value() > + ? exposureMargin_.value() : 0; > + if (!exposureMargin_.has_value() && !exposureMargin) { > + LOG(CameraSensorHelper, Warning) > + << "Exposure margin not known. Default to 4"; > + exposureMargin = 4; > + } > + > + return shutterTime + exposureMargin * lineDuration; > +} > /** > * \struct CameraSensorHelper::AnalogueGainLinear > * \brief Analogue gain constants for the linear gain model > diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h > index a1cf4bc334ad3b9a51d26b345bd5f0630c7ae87c..e9b53f183e8e6d305b50b5f3b46dc0199efee018 100644 > --- a/src/ipa/libipa/camera_sensor_helper.h > +++ b/src/ipa/libipa/camera_sensor_helper.h > @@ -33,6 +33,8 @@ public: > double quantizeGain(double gain, double *quantizationGain) const; > utils::Duration maxShutterTime(utils::Duration maxFrameDuration, > utils::Duration lineDuration) const; > + utils::Duration minFrameDuration(utils::Duration exposureTime, > + utils::Duration lineDuration) const; > > protected: > struct AnalogueGainLinear { > > -- > 2.51.1 >
diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 3c3e24c1cdefa4bca059352482bb29654a37b42f..a38f1eb40446b98a0db4642f086742674a13854f 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -184,6 +184,39 @@ utils::Duration CameraSensorHelper::maxShutterTime(utils::Duration maxFrameDurat return maxFrameDuration - exposureMargin * lineDuration; } +/** + * \brief Compute the minimum frame duration required for a desired exposure + * \param[in] shutterTime The shutter time + * \param[in] lineDuration The current sensor line duration + * + * This function returns the minimum frame duration required to achieve the + * desired \a shutterTime. The frame duration is calculated by adding to + * \a shutterTime the difference between the frame length and the maximum + * achievable integration time. + * + * The intended users of this function are IPA modules that want to calculate + * the minium required frame duration give a newly calculated shutter time. + * + * \todo The line duration should be a property of the CameraSensorHelper class + * instead of being provided by the IPA. + * + * \return The minimum frame duration required to achieve the desired shutter + * time + */ +utils::Duration CameraSensorHelper::minFrameDuration(utils::Duration shutterTime, + utils::Duration lineDuration) const +{ + /* Use a static to rate-limit the error message. */ + static uint32_t exposureMargin = exposureMargin_.has_value() + ? exposureMargin_.value() : 0; + if (!exposureMargin_.has_value() && !exposureMargin) { + LOG(CameraSensorHelper, Warning) + << "Exposure margin not known. Default to 4"; + exposureMargin = 4; + } + + return shutterTime + exposureMargin * lineDuration; +} /** * \struct CameraSensorHelper::AnalogueGainLinear * \brief Analogue gain constants for the linear gain model diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h index a1cf4bc334ad3b9a51d26b345bd5f0630c7ae87c..e9b53f183e8e6d305b50b5f3b46dc0199efee018 100644 --- a/src/ipa/libipa/camera_sensor_helper.h +++ b/src/ipa/libipa/camera_sensor_helper.h @@ -33,6 +33,8 @@ public: double quantizeGain(double gain, double *quantizationGain) const; utils::Duration maxShutterTime(utils::Duration maxFrameDuration, utils::Duration lineDuration) const; + utils::Duration minFrameDuration(utils::Duration exposureTime, + utils::Duration lineDuration) const; protected: struct AnalogueGainLinear {
After having introduced CameraSensorHelper::maxShutterTime() which calculates the maximum shutter time which can be achieved given a frame duration, this patch introduces the opposite operation, that given a desired shutter time calculates what is the minimum frame duration required to achieve it. The intended users of this function are IPA modules that after having calculated a new exposure time need to regulate the frame duration to achieve it. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> --- src/ipa/libipa/camera_sensor_helper.cpp | 33 +++++++++++++++++++++++++++++++++ src/ipa/libipa/camera_sensor_helper.h | 2 ++ 2 files changed, 35 insertions(+)