OpenCV Distortion Model

struct OpenCVCoefficients : public huira::DistortionCoefficients

Coefficients for OpenCV lens distortion model.

Holds the radial, tangential, and thin prism distortion coefficients for the OpenCV model.

Public Functions

OpenCVCoefficients() = default
inline constexpr OpenCVCoefficients(double k1_val, double k2_val, double k3_val, double k4_val, double k5_val, double k6_val, double p1_val, double p2_val, double s1_val, double s2_val, double s3_val, double s4_val)

Public Members

double k1 = 0
double k2 = 0
double k3 = 0
double k4 = 0
double k5 = 0
double k6 = 0
double p1 = 0
double p2 = 0
double s1 = 0
double s2 = 0
double s3 = 0
double s4 = 0
template<IsSpectral TSpectral>
class OpenCVDistortion : public huira::Distortion<TSpectral>

OpenCV lens distortion model.

Implements the OpenCV distortion model with rational radial, tangential, and thin prism coefficients.

Template Parameters:

TSpectral – The spectral representation type.

Public Functions

OpenCVDistortion() = default
explicit OpenCVDistortion(OpenCVCoefficients coefficients)

Constructs an OpenCVDistortion with the given coefficients.

Parameters:

coefficients – The OpenCV distortion coefficients (radial, tangential, thin prism).

virtual Pixel distort(Pixel homogeneous_coords) const override

Applies OpenCV distortion to the given pixel coordinates.

Computes the distorted coordinates by adding the OpenCV distortion delta.

Parameters:

homogeneous_coords – The input pixel coordinates (homogeneous).

Returns:

The distorted pixel coordinates.

virtual Pixel undistort(Pixel homogeneous_coords) const override

Removes OpenCV distortion from the given pixel coordinates.

Iteratively computes the undistorted coordinates using the OpenCV model.

Parameters:

homogeneous_coords – The distorted pixel coordinates (homogeneous).

Returns:

The undistorted pixel coordinates.

inline virtual std::string get_type_name() const override
inline virtual DistortionCoefficients *get_coefficients() override
inline virtual const DistortionCoefficients *get_coefficients() const override
inline void set_max_iterations(std::size_t max_iters)
inline std::size_t get_max_iterations() const
inline void set_tolerance(float tol)
inline float get_tolerance() const

Protected Attributes

std::size_t max_iterations_ = 20
double tol_sq_ = 1e-12
double tolerance_ = 1e-6