20 #include "algorithm.h" 28 template<
typename _Context,
typename _FrameContext,
typename _Config,
29 typename _Params,
typename _Stats>
41 const std::list<std::unique_ptr<Algorithm<Module>>> &
algorithms()
const 48 const auto &list = algorithms.
asList();
50 for (
const auto &[i, algo] : utils::enumerate(list)) {
51 if (!algo.isDictionary()) {
52 LOG(IPAModuleAlgo, Error)
53 <<
"Invalid YAML syntax for algorithm " << i;
58 int ret = createAlgorithm(context, algo);
70 factories().push_back(factory);
76 const auto &[name, algoData] = *data.
asDict().begin();
77 std::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);
79 LOG(IPAModuleAlgo, Error)
80 <<
"Algorithm '" << name <<
"' not found";
84 int ret = algo->init(context, algoData);
86 LOG(IPAModuleAlgo, Error)
87 <<
"Algorithm '" << name <<
"' failed to initialize";
91 LOG(IPAModuleAlgo, Debug)
92 <<
"Instantiated algorithm '" << name <<
"'";
94 algorithms_.push_back(std::move(algo));
98 static std::unique_ptr<Algorithm<Module>> createAlgorithm(
const std::string &name)
100 for (
const AlgorithmFactoryBase<Module> *factory : factories()) {
101 if (factory->name() == name)
102 return factory->create();
108 static std::vector<AlgorithmFactoryBase<Module> *> &factories()
115 static std::vector<AlgorithmFactoryBase<Module> *> factories;
119 std::list<std::unique_ptr<Algorithm<Module>>> algorithms_;
_Config Config
The type of the IPA configuration data.
Definition: module.h:35
#define LOG(category, severity)
Log a message.
_Params Params
The type of the ISP specific parameters.
Definition: module.h:36
const std::list< std::unique_ptr< Algorithm< Module > > > & algorithms() const
Retrieve the list of instantiated algorithms.
Definition: module.h:41
Base class to support log message extensions.
Definition: log.h:90
Top-level libcamera namespace.
Definition: backtrace.h:17
ListAdapter asList() const
Wrap a list YamlObject in an adapter that exposes iterators.
Definition: yaml_parser.h:206
_FrameContext FrameContext
The type of the frame context.
Definition: module.h:34
Miscellaneous utility functions.
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
_Stats Stats
The type of the IPA statistics and ISP results.
Definition: module.h:37
int createAlgorithms(Context &context, const YamlObject &algorithms)
Create algorithms from YAML configuration data.
Definition: module.h:46
static void registerAlgorithm(AlgorithmFactoryBase< Module > *factory)
Add an algorithm factory class to the list of available algorithms.
Definition: module.h:68
_Context Context
The type of the shared IPA context.
Definition: module.h:33
DictAdapter asDict() const
Wrap a dictionary YamlObject in an adapter that exposes iterators.
Definition: yaml_parser.h:205
A class representing the tree structure of the YAML content.
Definition: yaml_parser.h:27
The base class for all IPA modules.
Definition: module.h:30