Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpTemplateTrackerWarpTranslation.cpp
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  * Template tracker.
33  *
34  * Authors:
35  * Amaury Dame
36  * Aurelien Yol
37  * Fabien Spindler
38  *
39  *****************************************************************************/
40 #include <visp3/tt/vpTemplateTrackerWarpTranslation.h>
41 
43 {
44  nbParam = 2;
45  dW.resize(2, nbParam);
46 }
47 
48 // get the parameter corresponding to the lower level of a gaussian pyramid
50 {
51  pdown[0] = p[0] / 2.;
52  pdown[1] = p[1] / 2.;
53 }
54 
56 {
57  pup[0] = p[0] * 2.;
58  pup[1] = p[1] * 2.;
59 }
60 
61 /*calcul de di*dw(x,p0)/dp
62  */
63 void vpTemplateTrackerWarpTranslation::getdW0(const int & /*i*/, const int & /*j*/, const double &dy, const double &dx,
64  double *dIdW)
65 {
66  dIdW[0] = dx;
67  dIdW[1] = dy;
68 }
69 /*calcul de dw(x,p0)/dp
70  */
71 void vpTemplateTrackerWarpTranslation::getdWdp0(const int & /*i*/, const int & /*j*/, double *dIdW)
72 {
73  dIdW[0] = 1.;
74  dIdW[1] = 0;
75 
76  dIdW[2] = 0;
77  dIdW[3] = 1.;
78 }
79 
80 void vpTemplateTrackerWarpTranslation::warpX(const int &i, const int &j, double &i2, double &j2,
81  const vpColVector &ParamM)
82 {
83  j2 = j + ParamM[0];
84  i2 = i + ParamM[1];
85 }
86 
88 {
89  vXres[0] = vX[0] + ParamM[0];
90  vXres[1] = vX[1] + ParamM[1];
91 }
92 
94  const vpColVector & /*ParamM*/, vpMatrix &dW_)
95 {
96  dW_[0][0] = 1;
97  dW_[0][1] = 0;
98  dW_[1][0] = 0;
99  dW_[1][1] = 1;
100 }
101 
102 /*compute dw=dw/dx*dw/dp
103  */
105  const vpColVector & /*ParamM*/, const double *dwdp0, vpMatrix &dW_)
106 {
107  for (unsigned int i = 0; i < nbParam; i++) {
108  dW_[0][i] = dwdp0[i];
109  dW_[1][i] = dwdp0[i + nbParam];
110  }
111 }
112 
114 {
115  vXres[0] = vX[0] + ParamM[0];
116  vXres[1] = vX[1] + ParamM[1];
117 }
119 {
120  ParamMinv[0] = -ParamM[0];
121  ParamMinv[1] = -ParamM[1];
122 }
123 
125 {
126  pres[0] = p1[0] + p2[0];
127  pres[1] = p1[1] + p2[1];
128 }
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Definition: vpArray2D.h:305
void getParamPyramidDown(const vpColVector &p, vpColVector &pdown)
void getParamPyramidUp(const vpColVector &p, vpColVector &pup)
void getdW0(const int &i, const int &j, const double &dy, const double &dx, double *dIdW)
void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &pres) const
void warpXInv(const vpColVector &vX, vpColVector &vXres, const vpColVector &ParamM)
void dWarp(const vpColVector &X1, const vpColVector &X2, const vpColVector &ParamM, vpMatrix &dW)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
void warpX(const vpColVector &vX, vpColVector &vXres, const vpColVector &ParamM)
void dWarpCompo(const vpColVector &X1, const vpColVector &X2, const vpColVector &ParamM, const double *dwdp0, vpMatrix &dW)
void getParamInverse(const vpColVector &ParamM, vpColVector &ParamMinv) const
void getdWdp0(const int &i, const int &j, double *dIdW)