Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpTemplateTrackerMI.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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#ifndef vpTemplateTrackerMI_hh
34#define vpTemplateTrackerMI_hh
35
36#include <visp3/core/vpConfig.h>
37
38#include <visp3/core/vpImageFilter.h>
39#include <visp3/tt/vpTemplateTracker.h>
40#include <visp3/tt/vpTemplateTrackerHeader.h>
41
54class VISP_EXPORT vpTemplateTrackerMI : public vpTemplateTracker
55{
56public:
58 typedef enum
59 {
66 } vpHessienApproximationType;
67
70
72 typedef enum { BSPLINE_THIRD_ORDER = 3, BSPLINE_FOURTH_ORDER = 4 } vpBsplineType;
73
74protected:
77 double lambda;
78
79 double *temp;
80 double *Prt;
81 double *dPrt;
82 double *Pt;
83 double *Pr;
84 double *d2Prt;
85 double *PrtTout;
86 double *dprtemp;
87
88 double *PrtD;
89 double *dPrtD;
91
93 // Nombre de couleur concidere dans l'histogramme
94 int Nc;
95 int Ncb;
96
100
103
106
109
110 // Internal vars for computeHessienNormalized()
111 std::vector<double> m_du;
112 std::vector<double> m_dv;
113 std::vector<double> m_A;
114 std::vector<double> m_dB;
115 std::vector<std::vector<double> > m_d2u;
116 std::vector<std::vector<double> > m_d2v;
117 std::vector<std::vector<double> > m_dA;
118
119protected:
120 void computeGradient();
123 void computeMI(double &MI);
124 void computeProba(int &nbpoint);
125
126 double getCost(const vpImage<unsigned char> &I, const vpColVector &tp) VP_OVERRIDE;
127 double getCost(const vpImage<unsigned char> &I) { return getCost(I, p); }
128 double getNormalizedCost(const vpImage<unsigned char> &I, const vpColVector &tp);
130 void zeroProbabilities();
131
132 // private:
133 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
134 // vpTemplateTrackerMI(const vpTemplateTrackerMI &)
135 // : vpTemplateTracker(), hessianComputation(USE_HESSIEN_NORMAL),
136 // ApproxHessian(HESSIAN_0), lambda(0),
137 // temp(nullptr), Prt(nullptr), dPrt(nullptr), Pt(nullptr), Pr(nullptr), d2Prt(nullptr),
138 // PrtTout(nullptr), dprtemp(nullptr), PrtD(nullptr), dPrtD(nullptr),
139 // influBspline(0), bspline(0), Nc(0), Ncb(0), d2Ix(), d2Iy(), d2Ixy(),
140 // MI_preEstimation(0), MI_postEstimation(0), NMI_preEstimation(0),
141 // NMI_postEstimation(0), covarianceMatrix(), computeCovariance(false)
142 // {
143 // throw vpException(vpException::functionNotImplementedError, "Not
144 // implemented!");
145 // }
146 // vpTemplateTrackerMI &operator=(const vpTemplateTrackerMI &){
147 // throw vpException(vpException::functionNotImplementedError, "Not
148 // implemented!"); return *this;
149 // }
150 //#endif
151
152#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
153 vpTemplateTrackerMI(const vpTemplateTrackerMI &) = delete; // non construction-copyable
154 vpTemplateTrackerMI &operator=(const vpTemplateTrackerMI &) = delete; // non copyable
155#endif
156
157public:
161 Prt(nullptr), dPrt(nullptr), Pt(nullptr), Pr(nullptr), d2Prt(nullptr), PrtTout(nullptr), dprtemp(nullptr), PrtD(nullptr), dPrtD(nullptr),
164 m_dB(), m_d2u(), m_d2v(), m_dA()
165 { }
166 VP_EXPLICIT vpTemplateTrackerMI(vpTemplateTrackerWarp *_warp);
167 virtual ~vpTemplateTrackerMI() VP_OVERRIDE;
169 double getMI() const { return MI_postEstimation; }
170 double getMI(const vpImage<unsigned char> &I, int &nc, const int &bspline, vpColVector &tp);
171 double getMI256(const vpImage<unsigned char> &I, const vpColVector &tp);
172 double getNMI() const { return NMI_postEstimation; }
173 // initialisation du Hessien en position desiree
175 void setCovarianceComputation(const bool &flag) { computeCovariance = flag; }
177 void setBspline(const vpBsplineType &newbs);
178 void setLambda(double _l) { lambda = _l; }
179 void setNc(int newNc);
180};
181END_VISP_NAMESPACE
182#endif
Implementation of column vector and the associated operations.
Definition of the vpImage class member functions.
Definition vpImage.h:131
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
vpHessienApproximationType ApproxHessian
vpImage< double > d2Ix
void computeHessienNormalized(vpMatrix &H)
std::vector< std::vector< double > > m_d2v
vpHessienType hessianComputation
void setHessianComputation(vpHessienType type)
std::vector< double > m_dB
std::vector< double > m_du
void computeProba(int &nbpoint)
vpTemplateTrackerMI()
Default constructor.
void computeHessien(vpMatrix &H)
void setApprocHessian(vpHessienApproximationType approx)
double getCost(const vpImage< unsigned char > &I)
std::vector< double > m_dv
std::vector< std::vector< double > > m_d2u
vpTemplateTrackerMI & operator=(const vpTemplateTrackerMI &)=delete
double getNormalizedCost(const vpImage< unsigned char > &I)
vpImage< double > d2Ixy
vpMatrix getCovarianceMatrix() const
std::vector< std::vector< double > > m_dA
vpTemplateTrackerMI(const vpTemplateTrackerMI &)=delete
vpImage< double > d2Iy
void setCovarianceComputation(const bool &flag)
std::vector< double > m_A
vpTemplateTracker()
Default constructor.
virtual double getCost(const vpImage< unsigned char > &I, const vpColVector &tp)=0