[libcamera-devel,v2,10/11] ipa: rkisp1: af: Skip few frames after changing lens position
diff mbox series

Message ID 20220713084317.24268-11-dse@thaumatec.com
State Superseded
Headers show
Series
  • ipa: rkisp1: Add autofocus algorithm
Related show

Commit Message

Daniel Semkowicz July 13, 2022, 8:43 a.m. UTC
With 30fps stream, lens movement takes more time than one frame. Skip
few frames to allow lens to stabilize before calculating next contrast
value.

Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
---
 src/ipa/rkisp1/algorithms/af.cpp | 5 ++++-
 src/ipa/rkisp1/algorithms/af.h   | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp
index cd4f0e08..a0d914e0 100644
--- a/src/ipa/rkisp1/algorithms/af.cpp
+++ b/src/ipa/rkisp1/algorithms/af.cpp
@@ -86,7 +86,10 @@  void Af::process(IPAContext &context,
 
 	uint32_t lensPosition = processAutofocus(sharpness);
 
-	context.frameContext.af.focus = lensPosition;
+	if (lensPosition != context.frameContext.af.focus) {
+		context.frameContext.af.focus = lensPosition;
+		setFramesToSkip(kFLensWaitFrames);
+	}
 }
 
 void Af::setMetering(controls::AfMeteringEnum metering)
diff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h
index eeb806c0..36d0c9b0 100644
--- a/src/ipa/rkisp1/algorithms/af.h
+++ b/src/ipa/rkisp1/algorithms/af.h
@@ -36,6 +36,8 @@  private:
 	Rectangle defaultWindow_;
 	Rectangle userWindow_;
 	bool updateAfwindow_ = false;
+
+	static constexpr uint32_t kFLensWaitFrames = 2;
 };
 
 } /* namespace libcamera::ipa::rkisp1::algorithms */