summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/raspberrypi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/raspberrypi/raspberrypi.cpp')
-rw-r--r--src/ipa/raspberrypi/raspberrypi.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index e2662938..9f3f3ac3 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -50,7 +50,6 @@
#include "denoise_algorithm.h"
#include "denoise_status.h"
#include "dpc_status.h"
-#include "focus_status.h"
#include "geq_status.h"
#include "lux_status.h"
#include "metadata.h"
@@ -642,14 +641,28 @@ void IPARPi::reportMetadata(unsigned int ipaContext)
static_cast<int32_t>(blackLevelStatus->blackLevelG),
static_cast<int32_t>(blackLevelStatus->blackLevelB) });
- FocusStatus *focusStatus = rpiMetadata.getLocked<FocusStatus>("focus.status");
- if (focusStatus && focusStatus->num == 12) {
+ RPiController::FocusRegions *focusStatus =
+ rpiMetadata.getLocked<RPiController::FocusRegions>("focus.status");
+ if (focusStatus) {
/*
- * We get a 4x3 grid of regions by default. Calculate the average
- * FoM over the central two positions to give an overall scene FoM.
- * This can change later if it is not deemed suitable.
+ * Calculate the average FoM over the central (symmetric) positions
+ * to give an overall scene FoM. This can change later if it is
+ * not deemed suitable.
*/
- int32_t focusFoM = (focusStatus->focusMeasures[5] + focusStatus->focusMeasures[6]) / 2;
+ libcamera::Size size = focusStatus->size();
+ unsigned rows = size.height;
+ unsigned cols = size.width;
+
+ uint64_t sum = 0;
+ unsigned int numRegions = 0;
+ for (unsigned r = rows / 3; r < rows - rows / 3; ++r) {
+ for (unsigned c = cols / 4; c < cols - cols / 4; ++c) {
+ sum += focusStatus->get({ (int)c, (int)r }).val;
+ numRegions++;
+ }
+ }
+
+ uint32_t focusFoM = (sum / numRegions) >> 16;
libcameraMetadata_.set(controls::FocusFoM, focusFoM);
}
@@ -1428,7 +1441,6 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co
statistics->focusRegions.set(i, { stats->focus_stats[i].contrast_val[1][1] / 1000,
stats->focus_stats[i].contrast_val_num[1][1],
stats->focus_stats[i].contrast_val_num[1][0] });
-
return statistics;
}
@@ -1445,6 +1457,10 @@ void IPARPi::processStats(unsigned int bufferId, unsigned int ipaContext)
Span<uint8_t> mem = it->second.planes()[0];
bcm2835_isp_stats *stats = reinterpret_cast<bcm2835_isp_stats *>(mem.data());
RPiController::StatisticsPtr statistics = fillStatistics(stats);
+
+ /* Save the focus stats in the metadata structure to report out later. */
+ rpiMetadata_[ipaContext].set("focus.status", statistics->focusRegions);
+
helper_->process(statistics, rpiMetadata);
controller_.process(statistics, &rpiMetadata);