Loading...
Searching...
No Matches
algorithm.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2021, Ideas On Board
*
* ISP control algorithm interface
*/
#pragma once
#include <memory>
#include <stdint.h>
#include <string>
#include <libcamera/controls.h>
namespace libcamera {
class YamlObject;
namespace ipa {
template<typename _Module>
class Algorithm
{
public:
using Module = _Module;
virtual ~Algorithm() {}
virtual int init([[maybe_unused]] typename Module::Context &context,
[[maybe_unused]] const YamlObject &tuningData)
{
return 0;
}
virtual int configure([[maybe_unused]] typename Module::Context &context,
[[maybe_unused]] const typename Module::Config &configInfo)
{
return 0;
}
virtual void queueRequest([[maybe_unused]] typename Module::Context &context,
[[maybe_unused]] const uint32_t frame,
[[maybe_unused]] typename Module::FrameContext &frameContext,
[[maybe_unused]] const ControlList &controls)
{
}
virtual void prepare([[maybe_unused]] typename Module::Context &context,
[[maybe_unused]] const uint32_t frame,
[[maybe_unused]] typename Module::FrameContext &frameContext,
[[maybe_unused]] typename Module::Params *params)
{
}
virtual void process([[maybe_unused]] typename Module::Context &context,
[[maybe_unused]] const uint32_t frame,
[[maybe_unused]] typename Module::FrameContext &frameContext,
[[maybe_unused]] const typename Module::Stats *stats,
[[maybe_unused]] ControlList &metadata)
{
}
};
template<typename _Module>
class AlgorithmFactoryBase
{
public:
AlgorithmFactoryBase(const char *name)
: name_(name)
{
_Module::registerAlgorithm(this);
}
virtual ~AlgorithmFactoryBase() = default;
const std::string &name() const { return name_; }
virtual std::unique_ptr<Algorithm<_Module>> create() const = 0;
private:
std::string name_;
};
template<typename _Algorithm>
class AlgorithmFactory : public AlgorithmFactoryBase<typename _Algorithm::Module>
{
public:
AlgorithmFactory(const char *name)
: AlgorithmFactoryBase<typename _Algorithm::Module>(name)
{
}
~AlgorithmFactory() = default;
std::unique_ptr<Algorithm<typename _Algorithm::Module>> create() const override
{
return std::make_unique<_Algorithm>();
}
};
#define REGISTER_IPA_ALGORITHM(algorithm, name) \
static AlgorithmFactory<algorithm> global_##algorithm##Factory(name);
} /* namespace ipa */
} /* namespace libcamera */
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
libcamera::YamlObject
A class representing the tree structure of the YAML content.
Definition yaml_parser.h:28
libcamera::ipa::AlgorithmFactory
Registration of Algorithm classes and creation of instances.
Definition algorithm.h:86
libcamera::ipa::AlgorithmFactory::create
std::unique_ptr< Algorithm< typename _Algorithm::Module > > create() const override
Create an instance of the Algorithm corresponding to the factory.
Definition algorithm.h:95
libcamera::ipa::AlgorithmFactory::AlgorithmFactory
AlgorithmFactory(const char *name)
Construct an algorithm factory.
Definition algorithm.h:88
libcamera::ipa::Algorithm
The base class for all IPA algorithms.
Definition algorithm.h:23
libcamera::ipa::Algorithm::process
virtual void process(typename Module::Context &context, const uint32_t frame, typename Module::FrameContext &frameContext, const typename Module::Stats *stats, ControlList &metadata)
Process ISP statistics, and run algorithm operations.
Definition algorithm.h:55
libcamera::ipa::Algorithm::init
virtual int init(typename Module::Context &context, const YamlObject &tuningData)
Initialize the Algorithm with tuning data.
Definition algorithm.h:29
libcamera::ipa::Algorithm< Module >::Module
Module Module
Definition algorithm.h:25
libcamera::ipa::Algorithm::configure
virtual int configure(typename Module::Context &context, const typename Module::Config &configInfo)
Configure the Algorithm given an IPAConfigInfo.
Definition algorithm.h:35
libcamera::ipa::Algorithm::prepare
virtual void prepare(typename Module::Context &context, const uint32_t frame, typename Module::FrameContext &frameContext, typename Module::Params *params)
Fill the params buffer with ISP processing parameters for a frame.
Definition algorithm.h:48
libcamera::ipa::Algorithm::queueRequest
virtual void queueRequest(typename Module::Context &context, const uint32_t frame, typename Module::FrameContext &frameContext, const ControlList &controls)
Provide control values to the algorithm.
Definition algorithm.h:41
libcamera::ipa::Module
The base class for all IPA modules.
Definition module.h:31
libcamera::ipa::Module::FrameContext
_FrameContext FrameContext
The type of the frame context.
Definition module.h:34
libcamera::ipa::Module::Params
_Params Params
The type of the ISP specific parameters.
Definition module.h:36
libcamera::ipa::Module::Context
_Context Context
The type of the shared IPA context.
Definition module.h:33
libcamera::ipa::Module::Stats
_Stats Stats
The type of the IPA statistics and ISP results.
Definition module.h:37
libcamera::ipa::Module::Config
_Config Config
The type of the IPA configuration data.
Definition module.h:35
controls.h
Framework to manage controls related to an object.
libcamera::controls
Namespace for libcamera controls.
Definition control_ids.h:22
libcamera::ipa
The IPA (Image Processing Algorithm) namespace.
Definition af.cpp:58
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17