@@ -20,7 +20,7 @@ LOG_DEFINE_CATEGORY(RPiLux)
#define NAME "rpi.lux"
Lux::Lux(Controller *controller)
- : Algorithm(controller)
+ : Algorithm(controller), sensitivity_(1.0)
{
/*
* Put in some defaults as there will be no meaningful values until
@@ -68,6 +68,13 @@ void Lux::setCurrentAperture(double aperture)
currentAperture_ = aperture;
}
+void Lux::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata)
+{
+ /* We will need to compensate for the camera sensitivity. */
+ ASSERT(cameraMode.sensitivity);
+ sensitivity_ = cameraMode.sensitivity;
+}
+
void Lux::prepare(Metadata *imageMetadata)
{
std::unique_lock<std::mutex> lock(mutex_);
@@ -88,10 +95,12 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata)
double yRatio = currentY * (65536 / stats->yHist.bins()) / referenceY_;
double estimatedLux = exposureTimeRatio * gainRatio *
apertureRatio * apertureRatio *
- yRatio * referenceLux_;
+ yRatio * referenceLux_ / sensitivity_;
+
LuxStatus status;
status.lux = estimatedLux;
status.aperture = currentAperture;
+
LOG(RPiLux, Debug) << ": estimated lux " << estimatedLux;
{
std::unique_lock<std::mutex> lock(mutex_);
@@ -10,6 +10,7 @@
#include <libcamera/base/utils.h>
+#include "../camera_mode.h"
#include "../lux_status.h"
#include "../algorithm.h"
@@ -23,6 +24,7 @@ public:
Lux(Controller *controller);
char const *name() const override;
int read(const libcamera::YamlObject ¶ms) override;
+ void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;
void prepare(Metadata *imageMetadata) override;
void process(StatisticsPtr &stats, Metadata *imageMetadata) override;
void setCurrentAperture(double aperture);
@@ -40,6 +42,7 @@ private:
double currentAperture_;
LuxStatus status_;
std::mutex mutex_;
+ double sensitivity_;
};
} /* namespace RPiController */
The camera mode sensitivity needs to be taken into account for the lux calculation. For example, the IMX708 binned mode (with a sensitivity of 2.0) would otherwise show double the correct lux value. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> --- src/ipa/rpi/controller/rpi/lux.cpp | 13 +++++++++++-- src/ipa/rpi/controller/rpi/lux.h | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-)