61 void loadFromConfigFile(
63 const std::string §ion);
66 void dumpToTextStream(
CStream &out)
const;
162 v.
K=1+v.
R*(cam.k1()+v.
R*(cam.k2()+v.
R*cam.k3()));
163 T xy=v.
x_*v.
y_,p1=cam.p1(),p2=cam.p2();
168 template<
typename T,
typename POINT,
typename PIXEL>
inline void getFullProjection(
const POINT &pIn,PIXEL &pOut)
const {
170 getTemporaryVariablesForTransform(pIn,tmp);
171 getFullProjectionT(tmp,pOut);
175 pOut[0]=cam.fx()*tmp.
x__+cam.cx();
176 pOut[1]=cam.fy()*tmp.
y__+cam.cy();
179 template<
typename T,
typename POINT,
typename MATRIX>
inline void getFullJacobian(
const POINT &pIn,MATRIX &mOut)
const {
181 getTemporaryVariablesForTransform(pIn,tmp);
182 getFullJacobianT(pIn,tmp,mOut);
189 CMatrixFixedNumeric<T,3,3> J21;
190 T tmpK=2*(cam.k1()+tmp.
R*(2*cam.k2()+3*tmp.
R*cam.k3()));
195 J21.set_unsafe(0,0,yx2);
196 J21.set_unsafe(0,1,x_);
197 J21.set_unsafe(0,2,0);
198 J21.set_unsafe(1,0,zx2);
199 J21.set_unsafe(1,1,0);
200 J21.set_unsafe(1,2,x_);
201 J21.set_unsafe(2,0,tmpKx*yx2+tmpKy*zx2);
202 J21.set_unsafe(2,1,tmpKx*x_);
203 J21.set_unsafe(2,2,tmpKy*x_);
205 T pxpy=2*(cam.p1()*tmp.
x_+cam.p2()*tmp.
y_);
206 T p1y=cam.p1()*tmp.
y_;
207 T p2x=cam.p2()*tmp.
x_;
208 CMatrixFixedNumeric<T,2,3> J43;
209 T fx=cam.fx(),fy=cam.fy();
210 J43.set_unsafe(0,0,fx*(tmp.
K+2*p1y+6*p2x));
211 J43.set_unsafe(0,1,fx*pxpy);
212 J43.set_unsafe(0,2,fx*tmp.
x_);
213 J43.set_unsafe(1,0,fy*pxpy);
214 J43.set_unsafe(1,1,fy*(tmp.
K+6*p1y+2*p2x));
215 J43.set_unsafe(1,2,fy*tmp.
y_);
216 mOut.multiply(J43,J21);
225 CMatrixFixedNumeric<double,2,2> res;
226 res.set_unsafe(0,1,0);
227 res.set_unsafe(1,0,0);
231 CMatrixFixedNumeric<double,4,2> res;
232 res.set_unsafe(0,0,1);
233 res.set_unsafe(0,1,0);
234 res.set_unsafe(1,0,0);
235 res.set_unsafe(1,1,1);
239 CMatrixFixedNumeric<double,3,4> res;
240 res.set_unsafe(0,1,0);
241 res.set_unsafe(0,2,0);
242 res.set_unsafe(1,0,0);
243 res.set_unsafe(1,2,0);
244 res.set_unsafe(2,0,0);
245 res.set_unsafe(2,1,0);
246 res.set_unsafe(2,2,1);
247 res.set_unsafe(2,3,0);
256 static CMatrixFixedNumeric<double,2,2> J1(firstInverseJacobian());
257 static CMatrixFixedNumeric<double,4,2> J2(secondInverseJacobian());
258 static CMatrixFixedNumeric<double,3,4> J3(thirdInverseJacobian());
259 static CMatrixFixedNumeric<double,2,3> J4;
260 CArray<double,4> tmp1;
261 CArray<double,2> tmp2;
263 double cx=cam.cx(),cy=cam.cy(),ifx=1/cam.fx(),ify=1/cam.fy();
264 double K1=cam.k1(),K2=cam.k2(),p1=cam.p1(),p2=cam.p2(),K3=cam.k3();
266 tmp1[0]=(pIn[0]-cx)*ifx;
267 tmp1[1]=(pIn[1]-cy)*ify;
268 J1.set_unsafe(0,0,ifx);
269 J1.set_unsafe(1,1,ify);
274 double K123=-K1*sK1+2*K1*K2-K3;
276 tmp1[3]=1+tmp1[2]*(-K1+tmp1[2]*(K12+tmp1[2]*K123));
277 J2.set_unsafe(2,0,2*tmp1[0]);
278 J2.set_unsafe(2,1,2*tmp1[1]);
279 double jTemp=-2*K1+4*tmp1[2]*K12+6*
square(tmp1[2])*K123;
280 J2.set_unsafe(3,0,tmp1[0]*jTemp);
281 J2.set_unsafe(3,1,tmp1[1]*jTemp);
283 tmp2[0]=tmp1[0]*tmp1[3];
284 tmp2[1]=tmp1[1]*tmp1[3];
285 J3.set_unsafe(0,0,tmp1[3]);
286 J3.set_unsafe(0,3,tmp1[0]);
287 J3.set_unsafe(1,1,tmp1[3]);
288 J3.set_unsafe(1,3,tmp1[1]);
290 double prod=tmp2[0]*tmp2[1];
292 pOut[0]=tmp2[0]-p1*prod-p2*(tmp1[2]+2*
square(tmp2[0]));
293 pOut[1]=tmp2[1]-p1*(tmp1[2]+2*
square(tmp2[1]))-p2*prod;
294 J4.set_unsafe(0,0,1-p1*tmp2[1]-4*p2*tmp2[0]);
295 J4.set_unsafe(0,1,-p1*tmp2[0]);
296 J4.set_unsafe(0,2,-p2);
297 J4.set_unsafe(1,0,-p2*tmp2[1]);
298 J4.set_unsafe(1,1,1-4*p1*tmp2[1]-p2*tmp2[0]);
299 J4.set_unsafe(1,2,-p1);
301 jOut.multiply_ABC(J4,J3,J2);
302 jOut.multiply(jOut,J1);
309 #endif //__CCamModel_H