43 #include <visp/vpTemplateTracker.h>
44 #include <visp/vpTemplateTrackerBSpline.h>
47 : nbLvlPyr(1), l0Pyr(0), pyrInitialised(false), ptTemplate(NULL), ptTemplatePyr(NULL),
48 ptTemplateInit(false), templateSize(0), templateSizePyr(NULL),
49 ptTemplateSelect(NULL), ptTemplateSelectPyr(NULL), ptTemplateSelectInit(false),
50 templateSelectSize(0), ptTemplateSupp(NULL), ptTemplateSuppPyr(NULL),
51 ptTemplateCompo(NULL), ptTemplateCompoPyr(NULL), zoneTracked(NULL), zoneTrackedPyr(NULL),
52 pyr_IDes(NULL), H(), Hdesire(), HdesirePyr(), HLM(), HLMdesire(), HLMdesirePyr(),
53 HLMdesireInverse(), HLMdesireInversePyr(), G(), gain(1.), thresholdGradient(40),
54 costFunctionVerification(false), blur(true), useBrent(false), nbIterBrent(3),
55 taillef(7), fgG(NULL), fgdG(NULL), ratioPixelIn(0), mod_i(1), mod_j(1), nbParam(0),
56 lambdaDep(0.001), iterationMax(30), iterationGlobale(0), diverge(false), nbIteration(0),
57 useCompositionnal(true), useInverse(false), Warp(_warp), p(0), dp(), X1(), X2(),
58 dW(), BI(), dIx(), dIy(), zoneRef_()
91 unsigned int NbPointDsZone=0;
96 for(
int i=0;i<hauteur_im;i+=mod_fi) {
97 for(
int j=0;j<largeur_im;j+=mod_fj) {
122 unsigned int cpt_point=0;
124 for(
int i=0;i<hauteur_im;i+=
mod_i)
127 for(
int j=0;j<largeur_im;j+=
mod_j)
151 pt.
val=vpTemplateTrackerBSpline::getSubPixBspline4(GaussI,i,j);
189 for(
unsigned int i=0;i<
nbLvlPyr;i++)
205 for(
unsigned int i=0;i<
nbLvlPyr;i++)
218 if (ptTemplateSuppPyr) {
219 for(
unsigned int i=0;i<
nbLvlPyr;i++)
221 if (ptTemplateSuppPyr[i]) {
223 delete[] ptTemplateSuppPyr[i][point].Bt;
224 delete[] ptTemplateSuppPyr[i][point].BtInit;
225 delete[] ptTemplateSuppPyr[i][point].dBt;
226 delete[] ptTemplateSuppPyr[i][point].d2W;
227 delete[] ptTemplateSuppPyr[i][point].d2Wx;
228 delete[] ptTemplateSuppPyr[i][point].d2Wy;
230 delete[] ptTemplateSuppPyr[i];
233 delete[] ptTemplateSuppPyr;
234 ptTemplateSuppPyr = NULL;
238 for(
unsigned int i=0;i<
nbLvlPyr;i++){
297 if (ptTemplateSupp) {
300 delete[] ptTemplateSupp[point].Bt;
301 delete[] ptTemplateSupp[point].BtInit;
302 delete[] ptTemplateSupp[point].dBt;
303 delete[] ptTemplateSupp[point].d2W;
304 delete[] ptTemplateSupp[point].d2Wx;
305 delete[] ptTemplateSupp[point].d2Wy;
307 delete[] ptTemplateSupp;
308 ptTemplateSupp = NULL;
356 zoneWarped.
display(I, col, thickness);
398 zoneWarped.
display(I, col, thickness);
430 adpt=alpha*direction;
439 p2=tp+alpha*direction;
448 double *Cost=
new double[4];
455 double *talpha=
new double[4];
475 for(
unsigned int i=0;i<3;i++){A[i][0]=talpha[i]*talpha[i];A[i][1]=talpha[i];A[i][2]=1.;}
477 vpColVector B(3);
for(
unsigned int i=0;i<3;i++)B[i]=Cost[i];
478 vpColVector parabol(3);parabol=(A.
t()*A).inverseByLU()*A.
t()*B;
484 talpha[3]=-0.5*parabol[1]/parabol[0];
494 if(talpha[i]<talpha[tindic_x_min])
496 if(talpha[i]>talpha[tindic_x_max])
500 if(Cost[tindic_x_max]<Cost[tindic_x_min])
503 talpha[3]=talpha[tindic_x_max]+1.;
512 talpha[3]=talpha[tindic_x_min]-1.;
525 if(talpha[i]<talpha[indic_x_min])
527 if(talpha[i]>talpha[indic_x_max])
531 if(talpha[3]>talpha[indic_x_max])
532 if((talpha[3]-talpha[indic_x_max])>alpha)talpha[3]=talpha[indic_x_max]+4.;
533 if(talpha[3]<talpha[indic_x_min])
534 if((talpha[indic_x_min]-talpha[3])>alpha)talpha[3]=talpha[indic_x_min]-4.;
559 adpt=talpha[3]*direction;
568 p3=tp+talpha[3]*direction;
576 if(Cost[i]>Cost[indice_f_max])
580 *ptp[indice_f_max]=*ptp[3];
581 Cost[indice_f_max]=Cost[3];
582 talpha[indice_f_max]=talpha[3];
590 if(Cost[i]<Cost[indice_f_min])
593 alpha=talpha[indice_f_min];
617 ptTemplateSuppPyr=
new vpTemplateTrackerPointSuppMIInv*[
nbLvlPyr];
619 for(
unsigned int i=0; i<
nbLvlPyr; i++) {
621 ptTemplateSuppPyr[i] = NULL;
649 for(
unsigned int i=1;i<
nbLvlPyr;i++)
764 ptTemplateSuppPyr[0]=ptTemplateSupp;
771 for(
unsigned int i=1;i<
nbLvlPyr;i++)
779 ptTemplateSuppPyr[i]=ptTemplateSupp;
798 ptTemplateSuppPyr[0]=ptTemplateSupp;
805 ptTemplateSuppPyr[0]=ptTemplateSupp;
816 for(
unsigned int i=1;i<
nbLvlPyr;i++)
827 ptTemplateSuppPyr[i]=ptTemplateSupp;
834 ptTemplateSuppPyr[i]=ptTemplateSupp;
875 for(
unsigned int i=1;i<
nbLvlPyr;i++)
902 for(
int i=(
int)nbLvlPyr-1;i>=0;i--)
909 ptTemplateSupp=ptTemplateSuppPyr[i];
931 ptTemplateSupp=ptTemplateSuppPyr[0];
976 if(pre_fcost<post_fcost)
const char * getMessage(void)
static void getGaussPyramidal(const vpImage< unsigned char > &I, vpImage< unsigned char > &GI)
bool ptTemplateSelectInit
Definition of the vpMatrix class.
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
virtual void getParamPyramidDown(const vpColVector &p, vpColVector &pdown)=0
virtual void trackPyr(const vpImage< unsigned char > &I)
bool costFunctionVerification
unsigned int templateSelectSize
unsigned int getWidth() const
void getGaussianBluredImage(const vpImage< unsigned char > &I)
vpTemplateTrackerPoint * ptTemplate
vpTemplateTrackerPoint ** ptTemplatePyr
Class to define colors available for display functionnalities.
static void getGaussianKernel(double *filter, unsigned int size, double sigma=0., bool normalize=true)
virtual void initTrackingPyr(const vpImage< unsigned char > &I, vpTemplateTrackerZone &zone)
void computeOptimalBrentGain(const vpImage< unsigned char > &I, vpColVector &tp, double tMI, vpColVector &direction, double &alpha)
error that can be emited by ViSP classes.
void initClick(const vpImage< unsigned char > &I, bool delaunay=false)
void display(const vpImage< unsigned char > &I, const vpColor &col=vpColor::green, const unsigned int thickness=3)
static void getGradYGauss2D(const vpImage< unsigned char > &I, vpImage< double > &dIy, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size)
vpMatrix * HLMdesireInversePyr
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
void copy(const vpTemplateTrackerZone &z)
unsigned int templateSize
virtual void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &pres) const =0
void initTracking(const vpImage< unsigned char > &I, vpTemplateTrackerZone &zone)
Error that can be emited by the vpTracker class and its derivates.
vpTemplateTrackerZone * zoneTrackedPyr
virtual ~vpTemplateTracker()
virtual void initHessienDesired(const vpImage< unsigned char > &I)=0
static void filter(const vpImage< double > &I, vpImage< double > &Iu, vpImage< double > &Iv, const vpMatrix &M)
vpTemplateTrackerZone zoneRef_
void setGaussianFilterSize(unsigned int new_taill)
void initFromZone(const vpImage< unsigned char > &I, const vpTemplateTrackerZone &zone)
virtual void initHessienDesiredPyr(const vpImage< unsigned char > &I)
void initClick(const vpImage< unsigned char > &I, bool delaunay=false)
virtual void getParamPyramidUp(const vpColVector &p, vpColVector &pup)=0
unsigned int getNbParam() const
void initFromPoints(const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &ip, bool delaunay=false)
void initFromPoints(const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &v_ip, bool delaunay=false)
unsigned int * templateSizePyr
vpMatrix HLMdesireInverse
virtual void initPyramidal(unsigned int nbLvl, unsigned int l0)
bool inZone(const int &i, const int &j) const
vpTemplateTracker(vpTemplateTrackerWarp *_warp)
vpTemplateTrackerZone getPyramidDown() const
void warpZone(const vpTemplateTrackerZone &in, const vpColVector &p, vpTemplateTrackerZone &out)
static void getGaussianDerivativeKernel(double *filter, unsigned int size, double sigma=0., bool normalize=true)
vpTemplateTrackerPointCompo * ptTemplateCompo
Class that provides a data structure for the column vectors as well as a set of operations on these v...
void track(const vpImage< unsigned char > &I)
virtual void trackNoPyr(const vpImage< unsigned char > &I)=0
vpTemplateTrackerZone * zoneTracked
bool ** ptTemplateSelectPyr
unsigned int getHeight() const
void trackRobust(const vpImage< unsigned char > &I)
vpImage< unsigned char > * pyr_IDes
vpTemplateTrackerWarp * Warp
virtual void initCompInversePyr(const vpImage< unsigned char > &I)
vpTemplateTrackerPointCompo ** ptTemplateCompoPyr
virtual double getCost(const vpImage< unsigned char > &I, vpColVector &tp)=0
void resize(const unsigned int i, const bool flagNullify=true)
void display(const vpImage< unsigned char > &I, const vpColor &col=vpColor::green, const unsigned int thickness=3)