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