libcamera/src/ipa/raspberrypi/controller/rpi/focus.cpp
Naushir Patuck 6d60f264d1 ipa: raspberrypi: Use the generic statistics structure in the algorithms
Repurpose the StatisticsPtr type from being a shared_ptr<bcm2835_isp_stats> to
shared_ptr<RPiController::Statistics>. This removes any hardware specific header
files and structures from the algorithms source code.

Add a new function in the Raspberry Pi IPA to populate the generic statistics
structure from the values provided by the hardware in the bcm2835_isp_stats
structure.

Update the Lux, AWB, AGC, ALSC, Contrast, and Focus algorithms to use the
generic statistics structure appropriately in their calculations. Additionally,
remove references to any hardware specific headers and defines in these source
files.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 13:11:30 +00:00

49 lines
1 KiB
C++

/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
* focus.cpp - focus algorithm
*/
#include <stdint.h>
#include <libcamera/base/log.h>
#include "../focus_status.h"
#include "focus.h"
using namespace RPiController;
using namespace libcamera;
LOG_DEFINE_CATEGORY(RPiFocus)
#define NAME "rpi.focus"
Focus::Focus(Controller *controller)
: Algorithm(controller)
{
}
char const *Focus::name() const
{
return NAME;
}
void Focus::process(StatisticsPtr &stats, Metadata *imageMetadata)
{
FocusStatus status;
for (unsigned int i = 0; i < stats->focusRegions.numRegions(); i++)
status.focusMeasures[i] = stats->focusRegions.get(i).val;
status.num = stats->focusRegions.numRegions();
imageMetadata->set("focus.status", status);
LOG(RPiFocus, Debug)
<< "Focus contrast measure: "
<< (status.focusMeasures[5] + status.focusMeasures[6]) / 10;
}
/* Register algorithm with the system. */
static Algorithm *create(Controller *controller)
{
return new Focus(controller);
}
static RegisterAlgorithm reg(NAME, &create);