ipa: raspberrypi: Generalise the focus reporting code
Use the generalised focus statistics structure to compute the centre window focus FoM value. This avoids needed to hard-code a specific grid size. Remove the focus reporting algorithm as the functionality is duplicated by this bit of IPA code. Remove focus_status.h as it is no longer needed. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
43f57f26b4
commit
ac7511dc4c
16 changed files with 24 additions and 112 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue