Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpTemplateTrackerMI.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Example of template tracking.
32  *
33  * Authors:
34  * Amaury Dame
35  * Aurelien Yol
36  * Fabien Spindler
37  *
38  *****************************************************************************/
39 #ifndef vpTemplateTrackerMI_hh
40 #define vpTemplateTrackerMI_hh
41 
42 #include <visp3/core/vpConfig.h>
43 
44 #include <visp3/tt/vpTemplateTracker.h>
45 #include <visp3/tt/vpTemplateTrackerHeader.h>
46 #include <visp3/core/vpImageFilter.h>
47 
52 class VISP_EXPORT vpTemplateTrackerMI: public vpTemplateTracker
53 {
54 public:
56  typedef enum {
57  HESSIAN_NONSECOND = -1,
62  HESSIAN_NEW
63  } vpHessienApproximationType;
64 
66  typedef enum {
69  USE_HESSIEN_BEST_COND
70  } vpHessienType;
71 
73  typedef enum {
74  BSPLINE_THIRD_ORDER = 3,
75  BSPLINE_FOURTH_ORDER = 4
76  } vpBsplineType;
77 
78 protected:
81  double lambda;
82 
83  double *temp;
84  double *Prt;
85  double *dPrt;
86  double *Pt;
87  double *Pr;
88  double *d2Prt;
89  double *PrtTout;
90  double *dprtemp;
91 
92  double *PrtD;
93  double *dPrtD;
95 
96  int bspline;
97  //Nombre de couleur concidere dans l'histogramme
98  int Nc;
99  int Ncb;
100 
104 
107 
110 
113 
114 protected:
115  void computeGradient();
116  void computeHessien(vpMatrix &H);
117  void computeHessienNormalized(vpMatrix &H);
118  void computeMI(double &MI);
119  void computeProba(int &nbpoint);
120  double getCost(const vpImage<unsigned char> &I, const vpColVector &tp);
121  double getCost(const vpImage<unsigned char> &I){return getCost(I,p);}
122  double getNormalizedCost(const vpImage<unsigned char> &I, const vpColVector &tp);
124  virtual void initHessienDesired(const vpImage<unsigned char> &I)=0;
125  virtual void trackNoPyr(const vpImage<unsigned char> &I)=0;
126  void zeroProbabilities();
127 
128 //private:
129 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
130 // vpTemplateTrackerMI(const vpTemplateTrackerMI &)
131 // : vpTemplateTracker(), hessianComputation(USE_HESSIEN_NORMAL), ApproxHessian(HESSIAN_0), lambda(0),
132 // temp(NULL), Prt(NULL), dPrt(NULL), Pt(NULL), Pr(NULL), d2Prt(NULL), PrtTout(NULL),
133 // dprtemp(NULL), PrtD(NULL), dPrtD(NULL), influBspline(0), bspline(0), Nc(0), Ncb(0),
134 // d2Ix(), d2Iy(), d2Ixy(), MI_preEstimation(0), MI_postEstimation(0),
135 // NMI_preEstimation(0), NMI_postEstimation(0), covarianceMatrix(), computeCovariance(false)
136 // {
137 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
138 // }
139 // vpTemplateTrackerMI &operator=(const vpTemplateTrackerMI &){
140 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
141 // return *this;
142 // }
143 //#endif
144 
145 public:
146  //constructeur
149  : vpTemplateTracker(), hessianComputation(USE_HESSIEN_NORMAL), ApproxHessian(HESSIAN_0), lambda(0),
150  temp(NULL), Prt(NULL), dPrt(NULL), Pt(NULL), Pr(NULL), d2Prt(NULL), PrtTout(NULL),
151  dprtemp(NULL), PrtD(NULL), dPrtD(NULL), influBspline(0), bspline(0), Nc(0), Ncb(0),
152  d2Ix(), d2Iy(), d2Ixy(), MI_preEstimation(0), MI_postEstimation(0),
153  NMI_preEstimation(0), NMI_postEstimation(0), covarianceMatrix(), computeCovariance(false)
154  {}
157  vpMatrix getCovarianceMatrix() const { return covarianceMatrix; }
158  double getMI() const {return MI_postEstimation;}
159  double getMI(const vpImage<unsigned char> &I,int &nc, const int &bspline,vpColVector &tp);
160  double getMI256(const vpImage<unsigned char> &I, const vpColVector &tp);
161  double getNMI() const {return NMI_postEstimation;}
162  //initialisation du Hessien en position desiree
163  void setApprocHessian(vpHessienApproximationType approx){ApproxHessian=approx;}
164  void setCovarianceComputation(const bool & flag){ computeCovariance = flag; }
165  void setHessianComputation(vpHessienType type){hessianComputation=type;}
166  void setBspline(const vpBsplineType &newbs);
167  void setLambda(double _l) {lambda = _l ; }
168  void setNc(int newNc);
169 };
170 
171 #endif
172 
vpTemplateTrackerMI()
Default constructor.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
void setLambda(double _l)
void setApprocHessian(vpHessienApproximationType approx)
vpImage< double > d2Ix
vpHessienApproximationType ApproxHessian
double getCost(const vpImage< unsigned char > &I)
void setHessianComputation(vpHessienType type)
virtual void initHessienDesired(const vpImage< unsigned char > &I)=0
virtual double getCost(const vpImage< unsigned char > &I, const vpColVector &tp)=0
vpMatrix getCovarianceMatrix() const
double getNormalizedCost(const vpImage< unsigned char > &I)
vpImage< double > d2Iy
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
void setCovarianceComputation(const bool &flag)
vpImage< double > d2Ixy
virtual void trackNoPyr(const vpImage< unsigned char > &I)=0
vpHessienType hessianComputation