41 #include <visp3/tt/vpTemplateTrackerZNCCInverseCompositional.h>
42 #include <visp3/core/vpImageFilter.h>
46 evolRMS(0), x_pos(), y_pos(), threshold_RMS(1e-8), moydIrefdp()
93 Warp->computeCoeff(
p);
94 double Ic,dIcx=0.,dIcy=0.;
130 for(
unsigned int it=0;it<
nbParam;it++)
135 double *tempt=
new double[
nbParam];
136 for(
unsigned int it=0;it<
nbParam;it++)
137 tempt[it]=
dW[0][it]*dIcx+
dW[1][it]*dIcy;
142 for(
unsigned int it=0;it<
nbParam;it++)
143 for(
unsigned int jt=0;jt<
nbParam;jt++)
145 moyd2Iref[it][jt] +=(
dW[0][it]*(
dW[0][jt]*d_Ixx+
dW[1][jt]*d_Ixy)
146 +
dW[1][it]*(
dW[0][jt]*d_Ixy+
dW[1][jt]*d_Iyy));
155 moyIref=moyIref/Nbpoint;
157 moyd2Iref=moyd2Iref/Nbpoint;
160 double covarIref=0,covarIc=0;
190 double *tempt=
new double[
nbParam];
191 for(
unsigned int it=0;it<
nbParam;it++)
192 tempt[it]=
dW[0][it]*dIcx+
dW[1][it]*dIcy;
194 double prodIc=(Ic-moyIc);
200 for(
unsigned int it=0;it<
nbParam;it++)
201 for(
unsigned int jt=0;jt<
nbParam;jt++)
203 sIcd2Iref[it][jt] +=prodIc*(
dW[0][it]*(
dW[0][jt]*d_Ixx+
dW[1][jt]*d_Ixy)
204 +
dW[1][it]*(
dW[0][jt]*d_Ixy+
dW[1][jt]*d_Iyy)-moyd2Iref[it][jt]);
211 for(
unsigned int it=0;it<
nbParam;it++)
214 covarIref+=(Iref-moyIref)*(Iref-moyIref);
215 covarIc+=(Ic-moyIc)*(Ic-moyIc);
216 sIcIref+=(Iref-moyIref)*(Ic-moyIc);
221 covarIref=sqrt(covarIref);
222 covarIc=sqrt(covarIc);
224 denom=covarIref*covarIc;
226 double NCC=sIcIref/denom;
232 d2covarIref=-(sIcd2Iref-sdIrefdIref+dcovarIref*dcovarIref.
t())/covarIref;
236 Hdesire=(sIcd2Iref-sdIrefdIref+dcovarIref*dcovarIref.
t())/denom;
252 unsigned int iteration=0;
258 unsigned int Nbpoint=0;
261 Warp->computeCoeff(
p);
292 moyIref=moyIref/Nbpoint;
295 double covarIref=0,covarIc=0;
320 double prod=(Ic-moyIc);
321 for(
unsigned int it=0;it<
nbParam;it++)
323 for(
unsigned int it=0;it<
nbParam;it++)
329 covarIref+=(Iref-moyIref)*(Iref-moyIref);
330 covarIc+=(Ic-moyIc)*(Ic-moyIc);
331 sIcIref+=(Iref-moyIref)*(Ic-moyIc);
336 covarIref=sqrt(covarIref);
337 covarIc=sqrt(covarIc);
338 double denom=covarIref*covarIc;
341 if (std::fabs(denom) <= std::numeric_limits<double>::epsilon())
347 double NCC=sIcIref/denom;
349 G=1.*(sIcdIref/denom-NCC*dcovarIref/covarIref);
358 std::cout<<
"probleme inversion"<<std::endl;
384 x_pos.resize(nb_corners);
385 y_pos.resize(nb_corners);
387 Warp->computeCoeff(
p);
393 for (
unsigned int j=0; j<3; j++) {
396 Warp->computeDenom(
X1,p_);
408 Warp->computeCoeff(p_);
415 for (
unsigned int j=0; j<3; j++) {
418 Warp->computeDenom(
X1,p_);
Implementation of a matrix and operations on matrices.
void initPosEvalRMS(const vpColVector &p)
void getTriangle(unsigned int i, vpTemplateTrackerTriangle &T) const
void initCompInverse(const vpImage< unsigned char > &I)
unsigned int getWidth() const
static void getGradX(const vpImage< unsigned char > &I, vpImage< double > &dIx)
vpTemplateTrackerPoint * ptTemplate
static void getGradY(const vpImage< unsigned char > &I, vpImage< double > &dIy)
virtual void warpX(const int &i, const int &j, double &i2, double &j2, const vpColVector &ParamM)=0
void initHessienDesired(const vpImage< unsigned char > &I)
std::vector< double > x_pos
Type getValue(double i, double j) const
vpColVector getCorner(unsigned int i) const
static void getGradYGauss2D(const vpImage< unsigned char > &I, vpImage< double > &dIy, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size)
static void getGradXGauss2D(const vpImage< unsigned char > &I, vpImage< double > &dIx, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size)
virtual void getParamInverse(const vpColVector &ParamM, vpColVector &ParamMinv) const =0
unsigned int templateSize
unsigned int iterationMax
void trackNoPyr(const vpImage< unsigned char > &I)
virtual void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &pres) const =0
vpTemplateTrackerZNCCInverseCompositional(vpTemplateTrackerWarp *warp)
unsigned int getNbTriangle() const
virtual void getdW0(const int &i, const int &j, const double &dy, const double &dx, double *dIdW)=0
vpMatrix HLMdesireInverse
std::vector< double > y_pos
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
vpTemplateTrackerZone * zoneTracked
unsigned int getHeight() const
static void filter(const vpImage< double > &I, vpImage< double > &Iu, vpImage< double > &Iv, const vpMatrix &M, const bool convolve=false)
void computeEvalRMS(const vpColVector &p)
vpTemplateTrackerWarp * Warp
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
virtual void dWarp(const vpColVector &X1, const vpColVector &X2, const vpColVector &ParamM, vpMatrix &dW)=0
void resize(const unsigned int i, const bool flagNullify=true)