ipa: raspberrypi: awb: Add GetConvergenceFrames method to AWB base class

We add a GetConvergenceFrames method to the AwbAlgorithm class which
can be called when the AWB is started from scratch. It suggests how
many frames should be dropped before displaying any (while the AWB
converges).

The Raspberry Pi specific implementation makes this customisable from
the tuning file.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
David Plowman 2020-12-08 20:44:38 +00:00 committed by Laurent Pinchart
parent 748f48a006
commit dbcf4d8247
3 changed files with 14 additions and 0 deletions

View file

@ -15,6 +15,7 @@ class AwbAlgorithm : public Algorithm
public: public:
AwbAlgorithm(Controller *controller) : Algorithm(controller) {} AwbAlgorithm(Controller *controller) : Algorithm(controller) {}
// An AWB algorithm must provide the following: // An AWB algorithm must provide the following:
virtual unsigned int GetConvergenceFrames() const = 0;
virtual void SetMode(std::string const &mode_name) = 0; virtual void SetMode(std::string const &mode_name) = 0;
virtual void SetManualGains(double manual_r, double manual_b) = 0; virtual void SetManualGains(double manual_r, double manual_b) = 0;
}; };

View file

@ -59,6 +59,7 @@ void AwbConfig::Read(boost::property_tree::ptree const &params)
bayes = params.get<int>("bayes", 1); bayes = params.get<int>("bayes", 1);
frame_period = params.get<uint16_t>("frame_period", 10); frame_period = params.get<uint16_t>("frame_period", 10);
startup_frames = params.get<uint16_t>("startup_frames", 10); startup_frames = params.get<uint16_t>("startup_frames", 10);
convergence_frames = params.get<unsigned int>("convergence_frames", 3);
speed = params.get<double>("speed", 0.05); speed = params.get<double>("speed", 0.05);
if (params.get_child_optional("ct_curve")) if (params.get_child_optional("ct_curve"))
read_ct_curve(ct_r, ct_b, params.get_child("ct_curve")); read_ct_curve(ct_r, ct_b, params.get_child("ct_curve"));
@ -165,6 +166,16 @@ void Awb::Initialise()
prev_sync_results_ = sync_results_; prev_sync_results_ = sync_results_;
} }
unsigned int Awb::GetConvergenceFrames() const
{
// If colour gains have been explicitly set, there is no convergence
// to happen, so no need to drop any frames - return zero.
if (manual_r_ && manual_b_)
return 0;
else
return config_.convergence_frames;
}
void Awb::SetMode(std::string const &mode_name) void Awb::SetMode(std::string const &mode_name)
{ {
std::unique_lock<std::mutex> lock(settings_mutex_); std::unique_lock<std::mutex> lock(settings_mutex_);

View file

@ -37,6 +37,7 @@ struct AwbConfig {
uint16_t frame_period; uint16_t frame_period;
// number of initial frames for which speed taken as 1.0 (maximum) // number of initial frames for which speed taken as 1.0 (maximum)
uint16_t startup_frames; uint16_t startup_frames;
unsigned int convergence_frames; // approx number of frames to converge
double speed; // IIR filter speed applied to algorithm results double speed; // IIR filter speed applied to algorithm results
bool fast; // "fast" mode uses a 16x16 rather than 32x32 grid bool fast; // "fast" mode uses a 16x16 rather than 32x32 grid
Pwl ct_r; // function maps CT to r (= R/G) Pwl ct_r; // function maps CT to r (= R/G)
@ -82,6 +83,7 @@ public:
char const *Name() const override; char const *Name() const override;
void Initialise() override; void Initialise() override;
void Read(boost::property_tree::ptree const &params) override; void Read(boost::property_tree::ptree const &params) override;
unsigned int GetConvergenceFrames() const override;
void SetMode(std::string const &name) override; void SetMode(std::string const &name) override;
void SetManualGains(double manual_r, double manual_b) override; void SetManualGains(double manual_r, double manual_b) override;
void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override;