138 v.K=1+
v.R*(cam.
k1()+
v.R*(cam.
k2()+
v.R*cam.
k3()));
139 T xy=
v.x_*
v.y_,p1=cam.
p1(),p2=cam.
p2();
140 v.x__=
v.x_*
v.K+2*p1*xy+p2*(3*
v.x_2+
v.y_2);
141 v.y__=
v.y_*
v.K+p1*(
v.x_2+3*
v.y_2)+2*p2*xy;
144 template<
typename T,
typename POINT,
typename PIXEL>
inline void getFullProjection(
const POINT &pIn,PIXEL &pOut)
const {
146 getTemporaryVariablesForTransform(pIn,tmp);
147 getFullProjectionT(tmp,pOut);
151 pOut[0]=cam.
fx()*tmp.
x__+cam.
cx();
152 pOut[1]=cam.
fy()*tmp.
y__+cam.
cy();
155 template<
typename T,
typename POINT,
typename MATRIX>
inline void getFullJacobian(
const POINT &pIn,MATRIX &mOut)
const {
157 getTemporaryVariablesForTransform(pIn,tmp);
158 getFullJacobianT(pIn,tmp,mOut);
166 T tmpK=2*(cam.
k1()+tmp.
R*(2*cam.
k2()+3*tmp.
R*cam.
k3()));
171 J21.set_unsafe(0,0,yx2);
172 J21.set_unsafe(0,1,x_);
173 J21.set_unsafe(0,2,0);
174 J21.set_unsafe(1,0,zx2);
175 J21.set_unsafe(1,1,0);
176 J21.set_unsafe(1,2,x_);
177 J21.set_unsafe(2,0,tmpKx*yx2+tmpKy*zx2);
178 J21.set_unsafe(2,1,tmpKx*x_);
179 J21.set_unsafe(2,2,tmpKy*x_);
181 T pxpy=2*(cam.
p1()*tmp.
x_+cam.
p2()*tmp.
y_);
182 T p1y=cam.
p1()*tmp.
y_;
183 T p2x=cam.
p2()*tmp.
x_;
185 T fx=cam.
fx(),fy=cam.
fy();
186 J43.set_unsafe(0,0,fx*(tmp.
K+2*p1y+6*p2x));
187 J43.set_unsafe(0,1,fx*pxpy);
188 J43.set_unsafe(0,2,fx*tmp.
x_);
189 J43.set_unsafe(1,0,fy*pxpy);
190 J43.set_unsafe(1,1,fy*(tmp.
K+6*p1y+2*p2x));
191 J43.set_unsafe(1,2,fy*tmp.
y_);
192 mOut.multiply(J43,J21);
202 res.set_unsafe(0,1,0);
203 res.set_unsafe(1,0,0);
208 res.set_unsafe(0,0,1);
209 res.set_unsafe(0,1,0);
210 res.set_unsafe(1,0,0);
211 res.set_unsafe(1,1,1);
216 res.set_unsafe(0,1,0);
217 res.set_unsafe(0,2,0);
218 res.set_unsafe(1,0,0);
219 res.set_unsafe(1,2,0);
220 res.set_unsafe(2,0,0);
221 res.set_unsafe(2,1,0);
222 res.set_unsafe(2,2,1);
223 res.set_unsafe(2,3,0);
240 double cx=cam.
cx(),cy=cam.
cy(),ifx=1/cam.
fx(),ify=1/cam.
fy();
241 double K1=cam.
k1(),K2=cam.
k2(),p1=cam.
p1(),p2=cam.
p2(),K3=cam.
k3();
243 tmp1[0]=(pIn[0]-cx)*ifx;
244 tmp1[1]=(pIn[1]-cy)*ify;
245 J1.set_unsafe(0,0,ifx);
246 J1.set_unsafe(1,1,ify);
251 double K123=-K1*sK1+2*K1*K2-K3;
253 tmp1[3]=1+tmp1[2]*(-K1+tmp1[2]*(K12+tmp1[2]*K123));
254 J2.set_unsafe(2,0,2*tmp1[0]);
255 J2.set_unsafe(2,1,2*tmp1[1]);
256 double jTemp=-2*K1+4*tmp1[2]*K12+6*
square(tmp1[2])*K123;
257 J2.set_unsafe(3,0,tmp1[0]*jTemp);
258 J2.set_unsafe(3,1,tmp1[1]*jTemp);
260 tmp2[0]=tmp1[0]*tmp1[3];
261 tmp2[1]=tmp1[1]*tmp1[3];
262 J3.set_unsafe(0,0,tmp1[3]);
263 J3.set_unsafe(0,3,tmp1[0]);
264 J3.set_unsafe(1,1,tmp1[3]);
265 J3.set_unsafe(1,3,tmp1[1]);
267 double prod=tmp2[0]*tmp2[1];
269 pOut[0]=tmp2[0]-p1*prod-p2*(tmp1[2]+2*
square(tmp2[0]));
270 pOut[1]=tmp2[1]-p1*(tmp1[2]+2*
square(tmp2[1]))-p2*prod;
271 J4.set_unsafe(0,0,1-p1*tmp2[1]-4*p2*tmp2[0]);
272 J4.set_unsafe(0,1,-p1*tmp2[0]);
273 J4.set_unsafe(0,2,-p2);
274 J4.set_unsafe(1,0,-p2*tmp2[1]);
275 J4.set_unsafe(1,1,1-4*p1*tmp2[1]-p2*tmp2[0]);
276 J4.set_unsafe(1,2,-p1);
278 jOut.multiply_ABC(J4,J3,J2);
279 jOut.multiply(jOut,J1);
286 #endif //__CCamModel_H mrpt::utils::TCamera cam
The parameters of a camera.
A pair (x,y) of pixel coordinates (subpixel resolution).
mrpt::math::CMatrixFixedNumeric< double, 2, 2 > firstInverseJacobian() const
void getFullProjection(const POINT &pIn, PIXEL &pOut) const
double p1() const
Get the value of the p1 distortion parameter.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
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...
void getFullInverseModelWithJacobian(const POINTIN &pIn, POINTOUT &pOut, MAT22 &jOut) const
This class allows loading and storing values and vectors of different types from a configuration text...
T square(const T x)
Inline function for the square of a number.
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).
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A numeric matrix of compile-time fixed size.
double k1() const
Get the value of the k1 distortion parameter.
void getTemporaryVariablesForTransform(const POINT &p, CameraTempVariables< T > &v) const
double p2() const
Get the value of the p2 distortion parameter.
void getFullProjectionT(const CameraTempVariables< T > &tmp, PIXEL &pOut) const
GLsizei const GLchar ** string
double cx() const
Get the value of the principal point x-coordinate (in pixels).
void getFullJacobian(const POINT &pIn, MATRIX &mOut) const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This class represent a pinhole camera model for Monocular SLAM and implements some associated Jacobia...
void VISION_IMPEXP undistort_point(const mrpt::utils::TPixelCoordf &inPt, mrpt::utils::TPixelCoordf &outPt, const mrpt::utils::TCamera &cameraModel)
Undistort one point given by its pixel coordinates and the camera parameters.
double k3() const
Get the value of the k3 distortion parameter.
T square(const T x)
Inline function for the square of a number.
GLsizei GLsizei GLchar * source
void getFullJacobianT(const POINT &pIn, const CameraTempVariables< T > &tmp, MATRIX &mOut) const
double k2() const
Get the value of the k2 distortion parameter.
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.
mrpt::math::CMatrixFixedNumeric< double, 3, 4 > thirdInverseJacobian() const
mrpt::math::CMatrixFixedNumeric< double, 4, 2 > secondInverseJacobian() const