154 template <
typename T>
163 template <
typename T,
typename POINT>
174 v.x__ =
v.x_ *
v.K + 2 * p1 * xy + p2 * (3 *
v.x_2 +
v.y_2);
175 v.y__ =
v.y_ *
v.K + p1 * (
v.x_2 + 3 *
v.y_2) + 2 * p2 * xy;
178 template <
typename T,
typename POINT,
typename PIXEL>
186 template <
typename T,
typename PIXEL>
194 template <
typename T,
typename POINT,
typename MATRIX>
202 template <
typename T,
typename POINT,
typename MATRIX>
211 T tmpKx = tmpK * tmp.
x_;
212 T tmpKy = tmpK * tmp.
y_;
213 T yx2 = -pIn[1] * x_2;
214 T zx2 = -pIn[2] * x_2;
215 J21.set_unsafe(0, 0, yx2);
216 J21.set_unsafe(0, 1, x_);
217 J21.set_unsafe(0, 2, 0);
218 J21.set_unsafe(1, 0, zx2);
219 J21.set_unsafe(1, 1, 0);
220 J21.set_unsafe(1, 2, x_);
221 J21.set_unsafe(2, 0, tmpKx * yx2 + tmpKy * zx2);
222 J21.set_unsafe(2, 1, tmpKx * x_);
223 J21.set_unsafe(2, 2, tmpKy * x_);
230 J43.set_unsafe(0, 0, fx * (tmp.
K + 2 * p1y + 6 * p2x));
231 J43.set_unsafe(0, 1, fx * pxpy);
232 J43.set_unsafe(0, 2, fx * tmp.
x_);
233 J43.set_unsafe(1, 0, fy * pxpy);
234 J43.set_unsafe(1, 1, fy * (tmp.
K + 6 * p1y + 2 * p2x));
235 J43.set_unsafe(1, 2, fy * tmp.
y_);
236 mOut.multiply(J43, J21);
249 res.set_unsafe(0, 1, 0);
250 res.set_unsafe(1, 0, 0);
256 res.set_unsafe(0, 0, 1);
257 res.set_unsafe(0, 1, 0);
258 res.set_unsafe(1, 0, 0);
259 res.set_unsafe(1, 1, 1);
265 res.set_unsafe(0, 1, 0);
266 res.set_unsafe(0, 2, 0);
267 res.set_unsafe(1, 0, 0);
268 res.set_unsafe(1, 2, 0);
269 res.set_unsafe(2, 0, 0);
270 res.set_unsafe(2, 1, 0);
271 res.set_unsafe(2, 2, 1);
272 res.set_unsafe(2, 3, 0);
277 template <
typename POINTIN,
typename POINTOUT,
typename MAT22>
279 const POINTIN& pIn, POINTOUT& pOut, MAT22& jOut)
const
313 tmp1[0] = (pIn[0] - cx) * ifx;
314 tmp1[1] = (pIn[1] - cy) * ify;
315 J1.set_unsafe(0, 0, ifx);
316 J1.set_unsafe(1, 1, ify);
320 double K12 = sK1 - K2;
321 double K123 = -K1 * sK1 + 2 * K1 * K2 - K3;
323 tmp1[3] = 1 + tmp1[2] * (-K1 + tmp1[2] * (K12 + tmp1[2] * K123));
324 J2.set_unsafe(2, 0, 2 * tmp1[0]);
325 J2.set_unsafe(2, 1, 2 * tmp1[1]);
326 double jTemp = -2 * K1 + 4 * tmp1[2] * K12 + 6 *
square(tmp1[2]) * K123;
327 J2.set_unsafe(3, 0, tmp1[0] * jTemp);
328 J2.set_unsafe(3, 1, tmp1[1] * jTemp);
331 tmp2[0] = tmp1[0] * tmp1[3];
332 tmp2[1] = tmp1[1] * tmp1[3];
333 J3.set_unsafe(0, 0, tmp1[3]);
334 J3.set_unsafe(0, 3, tmp1[0]);
335 J3.set_unsafe(1, 1, tmp1[3]);
336 J3.set_unsafe(1, 3, tmp1[1]);
339 double prod = tmp2[0] * tmp2[1];
341 pOut[0] = tmp2[0] - p1 * prod - p2 * (tmp1[2] + 2 *
square(tmp2[0]));
342 pOut[1] = tmp2[1] - p1 * (tmp1[2] + 2 *
square(tmp2[1])) - p2 * prod;
343 J4.set_unsafe(0, 0, 1 - p1 * tmp2[1] - 4 * p2 * tmp2[0]);
344 J4.set_unsafe(0, 1, -p1 * tmp2[0]);
345 J4.set_unsafe(0, 2, -p2);
346 J4.set_unsafe(1, 0, -p2 * tmp2[1]);
347 J4.set_unsafe(1, 1, 1 - 4 * p1 * tmp2[1] - p2 * tmp2[0]);
348 J4.set_unsafe(1, 2, -p1);
351 jOut.multiply_ABC(J4, J3, J2);
355 jOut.multiply(jOut, J1);
This class allows loading and storing values and vectors of different types from a configuration text...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Structure to hold the parameters of a pinhole camera model.
double fx() const
Get the value of the focal length x-value (in pixels).
double fy() const
Get the value of the focal length y-value (in pixels).
double p1() const
Get the value of the p1 distortion parameter.
double cx() const
Get the value of the principal point x-coordinate (in pixels).
double k3() const
Get the value of the k3 distortion parameter.
double p2() const
Get the value of the p2 distortion parameter.
double k1() const
Get the value of the k1 distortion parameter.
double k2() const
Get the value of the k2 distortion parameter.
double cy() const
Get the value of the principal point y-coordinate (in pixels).
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
A numeric matrix of compile-time fixed size.
This class represent a pinhole camera model for Monocular SLAM and implements some associated Jacobia...
void getFullProjectionT(const CameraTempVariables< T > &tmp, PIXEL &pOut) const
void distort_a_point(const mrpt::img::TPixelCoordf &p, mrpt::img::TPixelCoordf &distorted_p)
Return the pixel position distorted by the camera.
void jacob_undistor_fm(const mrpt::img::TPixelCoordf &uvd, math::CMatrixDouble &J_undist)
Jacobian for undistortion the image coordinates.
void getFullJacobian(const POINT &pIn, MATRIX &mOut) const
mrpt::img::TCamera cam
The parameters of a camera.
mrpt::math::CMatrixFixedNumeric< double, 2, 2 > firstInverseJacobian() const
void unproject_3D_point(const mrpt::img::TPixelCoordf &distorted_p, mrpt::math::TPoint3D &p3D) const
Return the 3D location of a point (at a fixed distance z=1), for the given (distorted) pixel position...
void jacob_undistor(const mrpt::img::TPixelCoordf &p, mrpt::math::CMatrixDouble &J_undist)
Calculate the image coordinates undistorted.
void getTemporaryVariablesForTransform(const POINT &p, CameraTempVariables< T > &v) const
mrpt::math::CMatrixFixedNumeric< double, 4, 2 > secondInverseJacobian() const
void getFullInverseModelWithJacobian(const POINTIN &pIn, POINTOUT &pOut, MAT22 &jOut) const
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
void jacobian_unproject_with_distortion(const mrpt::img::TPixelCoordf &p, math::CMatrixDouble &dy_dh) const
Jacobian of the unprojection of a pixel (with distortion) back into a 3D point, as done in unproject_...
CCamModel()
Default Constructor.
void undistort_point(const mrpt::img::TPixelCoordf &p, mrpt::img::TPixelCoordf &undistorted_p)
Return the pixel position undistorted by the camera The input values 'col' and 'row' will be replace ...
mrpt::math::CMatrixFixedNumeric< double, 3, 4 > thirdInverseJacobian() const
CCamModel(const mrpt::config::CConfigFileBase &cfgIni)
Constructor from a ini file.
void getFullJacobianT(const POINT &pIn, const CameraTempVariables< T > &tmp, MATRIX &mOut) const
void dumpToTextStream(std::ostream &out) const override
This method displays clearly all the contents of the structure in textual form, sending it to a CStre...
void project_3D_point(const mrpt::math::TPoint3D &p3D, mrpt::img::TPixelCoordf &distorted_p) const
Return the (distorted) pixel position of a 3D point given in coordinates relative to the camera (+Z p...
void jacobian_project_with_distortion(const mrpt::math::TPoint3D &p3D, math::CMatrixDouble &dh_dy) const
Jacobian of the projection of 3D points (with distortion), as done in project_3D_point ,...
void getFullProjection(const POINT &pIn, PIXEL &pOut) const
GLsizei const GLchar ** string
GLsizei GLsizei GLchar * source
Classes for computer vision, detectors, features, etc.
T square(const T x)
Inline function for the square of a number.
A pair (x,y) of pixel coordinates (subpixel resolution).