@@ -7,15 +7,16 @@
*/
#pragma once
+#include <libcamera/control_ids.h>
+#include <libcamera/controls.h>
#include <libcamera/geometry.h>
/*
* The focus algorithm should post the following structure into the image's
* "af.status" metadata.
*/
-
struct AfStatus {
uint32_t lensPosition;
- uint32_t state;
+ libcamera::controls::AfStateEnum state;
libcamera::Rectangle windows;
};
@@ -78,7 +78,7 @@ void Af::Initialise()
{
status_.lensPosition = 0.0;
maxContrast_ = 0.0;
- status_.state = 1;
+ status_.state = libcamera::controls::AfStateScanning;
}
void Af::Prepare(Metadata *image_metadata)
@@ -109,7 +109,7 @@ void Af::afFineScan()
if (afScan(kFineSearchStep)) {
LOG(IoBAf, Debug) << "AF found the best focus position !";
- status_.state = 2;
+ status_.state = libcamera::controls::AfStateFocused;
fineCompleted_ = true;
}
}
@@ -162,7 +162,7 @@ void Af::afReset()
LOG(IoBAf, Debug) << "Reset AF parameters";
status_.lensPosition = 0;
focus_ = 0;
- status_.state = 0;
+ status_.state = libcamera::controls::AfStateIdle;
previousContrast_ = 0.0;
coarseCompleted_ = false;
fineCompleted_ = false;
@@ -195,7 +195,7 @@ void Af::Process(StatisticsPtr &stats, [[maybe_unused]] Metadata *image_metadata
currentContrast_ += stats->focus_stats[i].contrast_val[1][1]
/ stats->focus_stats[i].contrast_val_num[1][1];
- if (status_.state != 2) {
+ if (status_.state != libcamera::controls::AfStateFocused) {
afCoarseScan();
afFineScan();
} else {
Now that controls are introduced, use the AfState to control the algorithm. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> --- src/ipa/raspberrypi/controller/af_status.h | 5 +++-- src/ipa/raspberrypi/controller/iob/af.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-)