Skip to content
Open

Ipa #354

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ipa/rpi/cam_helper/cam_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ unsigned int CamHelper::hideFramesModeSwitch() const
return 0;
}

unsigned int CamHelper::mistrustFramesStartup() const
unsigned int CamHelper::mistrustMetadataStartup() const
{
/* Many sensors return a single bad frame on start-up. */
/* Many sensors return bad metadata on the first frame after start-up. */
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ipa/rpi/cam_helper/cam_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace RPiController {
* HideFramesModeSwitch(): Tell the pipeline handler not to return this
* many frames after a mode switch (other than start-up). Some sensors
* may produce innvalid frames after a mode switch; others may not.
* MistrustFramesStartup(): At start-up a sensor may return frames for
* mistrustMetadataStartup(): At start-up a sensor may return frames for
* which we should not run any control algorithms (for example, metadata
* may be invalid).
* MistrustFramesModeSwitch(): The number of frames, after a mode switch
Expand Down Expand Up @@ -96,7 +96,7 @@ class CamHelper
virtual double getModeSensitivity(const CameraMode &mode) const;
virtual unsigned int hideFramesStartup() const;
virtual unsigned int hideFramesModeSwitch() const;
virtual unsigned int mistrustFramesStartup() const;
virtual unsigned int mistrustMetadataStartup() const;
virtual unsigned int mistrustFramesModeSwitch() const;
virtual unsigned int getMinDebinFactor() const;

Expand Down
4 changes: 2 additions & 2 deletions src/ipa/rpi/cam_helper/cam_helper_ov5647.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CamHelperOv5647 : public CamHelper
double gain(uint32_t gainCode) const override;
unsigned int hideFramesStartup() const override;
unsigned int hideFramesModeSwitch() const override;
unsigned int mistrustFramesStartup() const override;
unsigned int mistrustMetadataStartup() const override;
unsigned int mistrustFramesModeSwitch() const override;

private:
Expand Down Expand Up @@ -68,7 +68,7 @@ unsigned int CamHelperOv5647::hideFramesModeSwitch() const
return 2;
}

unsigned int CamHelperOv5647::mistrustFramesStartup() const
unsigned int CamHelperOv5647::mistrustMetadataStartup() const
{
/*
* First couple of frames are under-exposed and are no good for control
Expand Down
25 changes: 9 additions & 16 deletions src/ipa/rpi/common/ipa_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,30 +359,20 @@ void IpaBase::start(const ControlList &controls, StartResult *result)
frameCount_ = 0;
if (firstStart_) {
invalidCount_ = helper_->hideFramesStartup();
mistrustCount_ = helper_->mistrustFramesStartup();

mistrustCount_ = helper_->mistrustMetadataStartup();
/*
* 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.
* converge sufficiently.
*/
RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
controller_.getAlgorithm("agc"));
if (agc) {
if (agc)
agcConvergenceFrames = agc->getConvergenceFrames();
if (agcConvergenceFrames)
agcConvergenceFrames += mistrustCount_;
}

RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(
controller_.getAlgorithm("awb"));
if (awb) {
if (awb)
awbConvergenceFrames = awb->getConvergenceFrames();
if (awbConvergenceFrames)
awbConvergenceFrames += mistrustCount_;
}
} else {
invalidCount_ = helper_->hideFramesModeSwitch();
mistrustCount_ = helper_->mistrustFramesModeSwitch();
Expand Down Expand Up @@ -479,8 +469,11 @@ void IpaBase::prepareIsp(const PrepareParams &params)
/*
* This may overwrite the DeviceStatus using values from the sensor
* metadata, and may also do additional custom processing.
*
* Only call CamHelper::prepare() when we know the metadata can be trusted.
*/
helper_->prepare(embeddedBuffer, rpiMetadata);
if (frameCount_ >= mistrustCount_)
helper_->prepare(embeddedBuffer, rpiMetadata);

bool delayedRequestControls = false;
delayedMetadata.get<bool>("ipa.request_controls", delayedRequestControls);
Expand Down Expand Up @@ -537,7 +530,7 @@ void IpaBase::processStats(const ProcessParams &params)
RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext];
Duration offset(0s);

if (processPending_ && frameCount_ >= mistrustCount_) {
if (processPending_) {
auto it = buffers_.find(params.buffers.stats);
if (it == buffers_.end()) {
LOG(IPARPI, Error) << "Could not find stats buffer!";
Expand Down