15 #include <libcamera/base/span.h> 29 double k1 = 0.0,
double k2 = 0.0,
double k3 = 0.0,
31 : cx_(cx), cy_(cy), cnx_(0), cny_(0),
32 coefficients_({ k0, k1, k2, k3, k4 })
40 double r = sqrt(dx * dx + dy * dy);
42 for (
unsigned int i = 0; i < coefficients_.size(); i++) {
43 res += coefficients_[i] * std::pow(r, (i + 1) * 2);
50 double cpx = imageSize_.
width * cx_;
51 double cpy = imageSize_.
height * cy_;
52 double mx = std::max(cpx, std::fabs(imageSize_.
width - cpx));
53 double my = std::max(cpy, std::fabs(imageSize_.
height - cpy));
55 return sqrt(mx * mx + my * my);
65 cnx_ = (size.
width * cx_) / m;
66 cny_ = (size.
height * cy_) / m;
74 std::array<double, 5> coefficients_;
85 std::optional<ipa::LscPolynomial>
get(
const YamlObject &obj)
const 87 std::optional<double> cx = obj[
"cx"].get<
double>();
88 std::optional<double> cy = obj[
"cy"].get<
double>();
89 std::optional<double> k0 = obj[
"k0"].get<
double>();
90 std::optional<double> k1 = obj[
"k1"].get<
double>();
91 std::optional<double> k2 = obj[
"k2"].get<
double>();
92 std::optional<double> k3 = obj[
"k3"].get<
double>();
93 std::optional<double> k4 = obj[
"k4"].get<
double>();
95 if (!(cx && cy && k0 && k1 && k2 && k3 && k4))
97 <<
"Polynomial is missing a parameter";
double sampleAtNormalizedPixelPos(double x, double y) const
Sample the polynomial at the given normalized pixel position.
Definition: lsc_polynomial.h:36
#define LOG(category, severity)
Log a message.
Top-level libcamera namespace.
Definition: backtrace.h:17
Describe a two-dimensional size.
Definition: geometry.h:52
bool isNull() const
Check if the size is null.
Definition: geometry.h:68
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
unsigned int width
The Size width.
Definition: geometry.h:65
unsigned int height
The Size height.
Definition: geometry.h:66
double getM() const
Get the value m as described in the dng specification.
Definition: lsc_polynomial.h:48
A class representing the tree structure of the YAML content.
Definition: yaml_parser.h:27
LscPolynomial(double cx=0.0, double cy=0.0, double k0=0.0, double k1=0.0, double k2=0.0, double k3=0.0, double k4=0.0)
Construct a polynomial using the given coefficients.
Definition: lsc_polynomial.h:28
Class for handling even polynomials used in lens shading correction.
Definition: lsc_polynomial.h:25
void setReferenceImageSize(const Size &size)
Set the reference image size.
Definition: lsc_polynomial.h:58