42 #include <visp/vpTemplateTrackerWarpHomographySL3.h>
47 const double *u,
const double *v,
int nb_pt,
vpColVector& p)
57 double **dW_ddp0=
new double*[(
unsigned int)nb_pt];
58 for(
int i=0;i<nb_pt;i++)
61 dW_ddp0[i]=
new double[2*
nbParam];
73 double lambda=0.00001;
81 for(
int i=0;i<nb_pt;i++)
89 for(
unsigned int ip=0;ip<
nbParam;ip++)
91 dW_[0][ip]=dW_ddp0[i][ip];
92 dW_[1][ip]=dW_ddp0[i][ip+
nbParam];
103 erreur+=((u[i]-fX1[0])*(u[i]-fX1[0])+(v[i]-fX1[1])*(v[i]-fX1[1]));
111 std::cout<<
"Cannot inverse the matrix by LU "<<std::endl;
120 while((cpt<150)&&(sqrt((erreur_prec-erreur)*(erreur_prec-erreur))>1e-20));
123 for(
int i=0;i<nb_pt;i++)
137 for(
unsigned int i=0;i<8;i++)
162 double *u,*v;u=
new double[4];v=
new double[4];
164 u[0]=0;v[0]=0;u[1]=160;v[1]=0;u[2]=160;v[2]=120;u[3]=0;v[3]=120;
165 double *u2,*v2;u2=
new double[4];v2=
new double[4];
186 double *u,*v;u=
new double[4];v=
new double[4];
188 u[0]=0;v[0]=0;u[1]=160;v[1]=0;u[2]=160;v[2]=120;u[3]=0;v[3]=120;
190 double *u2,*v2;u2=
new double[4];v2=
new double[4];
224 denom=vX[0]*
G[2][0]+vX[1]*
G[2][1]+
G[2][2];
248 double i=vX[1],j=vX[0];
249 vXres[0]=(j*
G[0][0]+i*
G[0][1]+
G[0][2])/
denom;
250 vXres[1]=(j*
G[1][0]+i*
G[1][1]+
G[1][2])/
denom;
254 j2=(j*
G[0][0]+i*
G[0][1]+
G[0][2])/
denom;
255 i2=(j*
G[1][0]+i*
G[1][1]+
G[1][2])/
denom;
261 for (
unsigned int i=0; i<3; i++)
262 for (
unsigned int j=0; j<3; j++)
273 for(
unsigned int i=0;i<3;i++)
277 dGx[i][2]=
G[i][0]*X1[1];
278 dGx[i][3]=
G[i][1]*X1[0];
279 dGx[i][4]=
G[i][0]*X1[0]-
G[i][1]*X1[1];
280 dGx[i][5]=
G[i][2]-
G[i][1]*X1[1];
281 dGx[i][6]=
G[i][2]*X1[0];
282 dGx[i][7]=
G[i][2]*X1[1];
294 dhdx[0][0]=dx;dhdx[0][1]=dy;dhdx[0][2]=-j*dx-i*dy;
298 for(
unsigned int par=0;par<3;par++)
300 dGx[par][0]=
G[par][0];
301 dGx[par][1]=
G[par][1];
302 dGx[par][2]=
G[par][0]*i;
303 dGx[par][3]=
G[par][1]*j;
304 dGx[par][4]=
G[par][0]*j-
G[par][1]*i;
305 dGx[par][5]=
G[par][2]-
G[par][1]*i;
306 dGx[par][6]=
G[par][2]*j;
307 dGx[par][7]=
G[par][2]*i;
310 for(
unsigned int par=0;par<
nbParam;par++)
313 for(
unsigned int par2=0;par2<3;par2++)
314 res+=dhdx[0][par2]*
dGx[par2][par];
326 dhdx[0][0]=1.;dhdx[1][1]=1.;dhdx[0][2]=-j;dhdx[1][2]=-i;
330 for(
unsigned int par=0;par<3;par++)
332 dGx[par][0]=
G[par][0];
333 dGx[par][1]=
G[par][1];
334 dGx[par][2]=
G[par][0]*i;
335 dGx[par][3]=
G[par][1]*j;
336 dGx[par][4]=
G[par][0]*j-
G[par][1]*i;
337 dGx[par][5]=
G[par][2]-
G[par][1]*i;
338 dGx[par][6]=
G[par][2]*j;
339 dGx[par][7]=
G[par][2]*i;
344 for(
unsigned int par=0;par<
nbParam;par++)
346 dIdW[par]=dIdW_temp[0][par];
347 dIdW[par+
nbParam]=dIdW_temp[1][par];
355 dhdx[0][0]=1.;dhdx[1][1]=1.;dhdx[0][2]=-j;dhdx[1][2]=-i;
359 for(
unsigned int par=0;par<3;par++)
361 dGx[par][0]=
G[par][0];
362 dGx[par][1]=
G[par][1];
363 dGx[par][2]=
G[par][0]*i;
364 dGx[par][3]=
G[par][1]*j;
365 dGx[par][4]=
G[par][0]*j-
G[par][1]*i;
366 dGx[par][5]=
G[par][2]-
G[par][1]*i;
367 dGx[par][6]=
G[par][2]*j;
368 dGx[par][7]=
G[par][2]*i;
373 for(
unsigned int par=0;par<
nbParam;par++)
375 dIdW[par]=dIdW_temp[0][par];
376 dIdW[par+
nbParam]=dIdW_temp[1][par];
386 for(
unsigned int i=0;i<
nbParam;i++)
388 dW_[0][i]=
denom*((
G[0][0]-X2[0]*
G[2][0])*dwdp0[i]+(
G[0][1]-X2[0]*
G[2][1])*dwdp0[i+
nbParam]);
389 dW_[1][i]=
denom*((G[1][0]-X2[1]*G[2][0])*dwdp0[i]+(G[1][1]-X2[1]*G[2][1])*dwdp0[i+
nbParam]);
void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &pres) const
Definition of the vpMatrix class.
void computeDenom(vpColVector &vX, const vpColVector &ParamM)
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
void getParamPyramidDown(const vpColVector &p, vpColVector &pdown)
void computeCoeff(const vpColVector &p)
void getdW0(const int &i, const int &j, const double &dy, const double &dx, double *dIdW)
void dWarpCompo(const vpColVector &X1, const vpColVector &X2, const vpColVector &ParamM, const double *dwdp0, vpMatrix &dW)
std::vector< vpMatrix > A
void findWarp(const double *ut0, const double *vt0, const double *u, const double *v, int nb_pt, vpColVector &p)
vpHomography getHomography() const
void getdWdp0(const int &i, const int &j, double *dIdW)
This class aims to compute the homography wrt.two images.
void setIdentity(const double &val=1.0)
void warpX(const vpColVector &vX, vpColVector &vXres, const vpColVector &ParamM)
void getParamInverse(const vpColVector &ParamM, vpColVector &ParamMinv) const
~vpTemplateTrackerWarpHomographySL3()
void getParamPyramidUp(const vpColVector &p, vpColVector &pup)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpTemplateTrackerWarpHomographySL3()
vpMatrix inverseByLU() const
void dWarp(const vpColVector &X1, const vpColVector &X2, const vpColVector &ParamM, vpMatrix &dW)
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
void warp(const double *ut0, const double *vt0, int nb_pt, const vpColVector &p, double *u, double *v)