28template<
typename T,
unsigned int R,
unsigned int C,
29 std::enable_if_t<std::is_arithmetic_v<T>> * =
nullptr>
31template<
typename T,
unsigned int R,
unsigned int C>
43 for (
const auto &pair : matrices)
44 matrices_[pair.first] = pair.second;
56 const std::string &key_name,
57 const std::string &matrix_name)
66 for (
const auto &value : yaml.
asList()) {
68 std::optional<Matrix<T, R, C>> matrix =
75 matrices_[ct] = *matrix;
78 <<
"Read matrix '" << matrix_name <<
"' for key '"
79 << key_name <<
"' " << ct <<
": "
80 << matrices_[ct].toString();
83 if (matrices_.size() < 1) {
93 ASSERT(matrices_.size() > 0);
95 if (matrices_.size() == 1 ||
96 ct <= matrices_.begin()->first)
97 return matrices_.begin()->second;
99 if (ct >= matrices_.rbegin()->first)
100 return matrices_.rbegin()->second;
102 if (matrices_.find(ct) != matrices_.end())
103 return matrices_[ct];
106 auto iter = matrices_.upper_bound(ct);
107 unsigned int ctUpper = iter->first;
108 unsigned int ctLower = (--iter)->first;
110 double lambda = (ct - ctLower) /
static_cast<double>(ctUpper - ctLower);
112 lambda * matrices_[ctUpper] + (1.0 - lambda) * matrices_[ctLower];
117 std::map<unsigned int, Matrix<T, R, C>> matrices_;
A class representing the tree structure of the YAML content.
Definition yaml_parser.h:26
ListAdapter asList() const
Wrap a list YamlObject in an adapter that exposes iterators.
Definition yaml_parser.h:196
bool isList() const
Return whether the YamlObject is a list.
Definition yaml_parser.h:153
Class for storing, retrieving, and interpolating matrices.
Definition matrix_interpolator.h:34
int readYaml(const libcamera::YamlObject &yaml, const std::string &key_name, const std::string &matrix_name)
Initialize an MatrixInterpolator instance from yaml.
Definition matrix_interpolator.h:55
void reset()
Reset the matrix interpolator content to a single identity matrix.
Definition matrix_interpolator.h:49
MatrixInterpolator(const std::map< unsigned int, Matrix< T, R, C > > &matrices)
Construct a matrix interpolator from a map of matrices.
Definition matrix_interpolator.h:41
Matrix< T, R, C > get(unsigned int ct)
Retrieve a matrix from the list of matrices, interpolating if necessary.
Definition matrix_interpolator.h:91
Matrix class.
Definition matrix.h:32
static Matrix identity()
Construct an identity matrix.
Definition matrix.h:44
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:47
#define LOG(category, severity)
Log a message.
Definition log.h:123
#define ASSERT(condition)
Abort program execution if assertion fails.
Definition log.h:127
Top-level libcamera namespace.
Definition backtrace.h:17