9 #include <aliceVision/camera/cameraCommon.hpp>
11 #include <aliceVision/numeric/numeric.hpp>
34 _pixelAspectRatio = 1.0;
35 _isDesqueezed =
false;
38 setSize(width, height);
39 setOffset({0.0, 0.0});
42 virtual EUNDISTORTION getType()
const = 0;
47 bool operator==(
const Undistortion& other)
const {
return _undistortionParams == other._undistortionParams; }
49 void setDesqueezed(
bool isDesqueezed)
51 _isDesqueezed = isDesqueezed;
53 double hh = _size.y();
56 hh = _size.y() / _pixelAspectRatio;
59 _diagonal = sqrt(_size.x() * _size.x() + hh * hh) * 0.5;
62 bool isDesqueezed()
const {
return _isDesqueezed; }
64 bool isLocked()
const {
return _isLocked; }
66 void setLocked(
bool lock) { _isLocked = lock; }
68 void setOffset(
const Vec2& offset) { _offset = offset; }
70 void setSize(
int width,
int height)
75 hh = height / _pixelAspectRatio;
78 _diagonal = sqrt(width * width + hh * hh) * 0.5;
79 _center = {width / 2, height / 2};
80 _size = {width, height};
83 void setDiagonal(
double diagonal)
89 void setPixelAspectRatio(
double pixelAspectRatio)
91 _pixelAspectRatio = pixelAspectRatio;
93 double hh = _size.y();
96 hh = _size.y() / _pixelAspectRatio;
99 _diagonal = sqrt(_size.x() * _size.x() + hh * hh) * 0.5;
102 inline Vec2 getOffset()
const {
return _offset; }
104 inline Vec2 getScaledOffset()
const {
return _offset / _diagonal; }
106 Vec2 getSize()
const {
return _size; }
108 Vec2 getCenter()
const {
return _center + _offset; }
110 inline double getDiagonal()
const {
return _diagonal; }
112 double getPixelAspectRatio()
const {
return _pixelAspectRatio; }
114 const std::vector<double>& getParameters()
const {
return _undistortionParams; }
116 void setParameters(
const std::vector<double>& params)
118 if (_undistortionParams.size() != params.size())
123 for (std::size_t i = 0; i < _undistortionParams.size(); i++)
125 _undistortionParams[i] = params[i];
129 std::size_t getUndistortionParametersCount()
const {
return _undistortionParams.size(); }
131 Vec2 undistort(
const Vec2& p)
const;
133 Eigen::Matrix<double, 2, Eigen::Dynamic> getDerivativeUndistortWrtParameters(
const Vec2& p);
135 Eigen::Matrix<double, 2, 2> getDerivativeUndistortWrtOffset(
const Vec2& p);
138 Vec2
inverse(
const Vec2& p)
const;
140 virtual Vec2 inverseNormalized(
const Vec2& p)
const = 0;
141 virtual Vec2 undistortNormalized(
const Vec2& p)
const = 0;
142 virtual Eigen::Matrix<double, 2, Eigen::Dynamic> getDerivativeUndistortNormalizedwrtParameters(
const Vec2& p)
const = 0;
143 virtual Eigen::Matrix<double, 2, 2> getDerivativeUndistortNormalizedwrtPoint(
const Vec2& p)
const = 0;
152 double _pixelAspectRatio;
154 std::vector<double> _undistortionParams{};