summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/focus.cpp
blob: a87ec802b964024bd2ad36baed02aa26d8abd450 (plain)
1
2
3
4
5
6
7
8
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# gen-ipa-priv-key.sh - Generate an RSA private key to sign IPA modules

key="$1"

openssl genpkey -algorithm RSA -out "${key}" -pkeyopt rsa_keygen_bits:2048
47 48 49 50
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2020, Raspberry Pi (Trading) Limited
 *
 * focus.cpp - focus algorithm
 */
#include <stdint.h>

#include <libcamera/base/log.h>

#include "../focus_status.h"
#include "focus.hpp"

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 *image_metadata)
{
	FocusStatus status;
	unsigned int i;
	for (i = 0; i < FOCUS_REGIONS; i++)
		status.focus_measures[i] = stats->focus_stats[i].contrast_val[1][1] / 1000;
	status.num = i;
	image_metadata->Set("focus.status", status);

	LOG(RPiFocus, Debug)
		<< "Focus contrast measure: "
		<< (status.focus_measures[5] + status.focus_measures[6]) / 10;
}

/* Register algorithm with the system. */
static Algorithm *Create(Controller *controller)
{
	return new Focus(controller);
}
static RegisterAlgorithm reg(NAME, &Create);