@@ -82,10 +82,10 @@ bool CamHelper::SensorEmbeddedDataPresent() const
unsigned int CamHelper::HideFramesStartup() const
{
/*
- * By default, hide 6 frames completely at start-up while AGC etc. sort
- * themselves out (converge).
+ * The number of frames when a camera first starts that shouldn't be
+ * displayed as they are invalid in some way.
*/
- return 6;
+ return 0;
}
unsigned int CamHelper::HideFramesModeSwitch() const
@@ -19,6 +19,7 @@ public:
uint32_t GainCode(double gain) const override;
double Gain(uint32_t gain_code) const override;
void GetDelays(int &exposure_delay, int &gain_delay) const override;
+ unsigned int HideFramesStartup() const override;
unsigned int HideFramesModeSwitch() const override;
unsigned int MistrustFramesStartup() const override;
unsigned int MistrustFramesModeSwitch() const override;
@@ -54,6 +55,15 @@ void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay) const
gain_delay = 2;
}
+unsigned int CamHelperOv5647::HideFramesStartup() const
+{
+ /*
+ * On startup, we get a couple of under-exposed frames which
+ * we don't want shown.
+ */
+ return 2;
+}
+
unsigned int CamHelperOv5647::HideFramesModeSwitch() const
{
/*
@@ -194,6 +194,34 @@ int IPARPi::start(const IPAOperationData &data, IPAOperationData *result)
if (firstStart_) {
dropFrame = helper_->HideFramesStartup();
mistrustCount_ = helper_->MistrustFramesStartup();
+
+ /*
+ * Query the AGC/AWB for how many frames they may take to
+ * converge sufficiently. Where these numbers are non-zero
+ * we must allow for the frames with bad statistics
+ * (mistrustCount_) that they won't see. But if zero (i.e.
+ * no convergence necessary), no frames need to be dropped.
+ */
+ unsigned int agcConvergenceFrames = 0;
+ RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
+ controller_.GetAlgorithm("agc"));
+ if (agc) {
+ agcConvergenceFrames = agc->GetConvergenceFrames();
+ if (agcConvergenceFrames)
+ agcConvergenceFrames += mistrustCount_;
+ }
+
+ unsigned int awbConvergenceFrames = 0;
+ RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(
+ controller_.GetAlgorithm("awb"));
+ if (awb) {
+ awbConvergenceFrames = awb->GetConvergenceFrames();
+ if (awbConvergenceFrames)
+ awbConvergenceFrames += mistrustCount_;
+ }
+
+ dropFrame = std::max({ dropFrame, agcConvergenceFrames, awbConvergenceFrames });
+ LOG(IPARPI, Debug) << "Drop " << dropFrame << " frames on startup";
} else {
dropFrame = helper_->HideFramesModeSwitch();
mistrustCount_ = helper_->MistrustFramesModeSwitch();