Visual Servoing Platform  version 3.0.0
vpTemplateTrackerWarpTranslation.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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  * Template tracker.
32  *
33  * Authors:
34  * Amaury Dame
35  * Aurelien Yol
36  * Fabien Spindler
37  *
38  *****************************************************************************/
39 #include <visp3/tt/vpTemplateTrackerWarpTranslation.h>
40 
42 {
43  nbParam = 2 ;
44  dW.resize(2,nbParam);
45 }
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,double *dIdW)
64 {
65  dIdW[0]=dx;
66  dIdW[1]=dy;
67 }
68 /*calcul de dw(x,p0)/dp
69 */
70 void vpTemplateTrackerWarpTranslation::getdWdp0(const int &/*i*/,const int &/*j*/,double *dIdW)
71 {
72  dIdW[0]=1.;
73  dIdW[1]=0;
74 
75  dIdW[2]=0;
76  dIdW[3]=1.;
77 }
78 
79 void vpTemplateTrackerWarpTranslation::warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM)
80 {
81  j2=j+ParamM[0];
82  i2=i+ParamM[1];
83 }
84 
85 
87 {
88  vXres[0]=vX[0]+ParamM[0];
89  vXres[1]=vX[1]+ParamM[1];
90 }
91 
92 void vpTemplateTrackerWarpTranslation::dWarp(const vpColVector &/*X1*/,const vpColVector &/*X2*/,const vpColVector &/*ParamM*/,
93  vpMatrix &dW_)
94 {
95  dW_[0][0]=1;dW_[0][1]=0;
96  dW_[1][0]=0;dW_[1][1]=1;
97 }
98 
99 /*compute dw=dw/dx*dw/dp
100 */
101 void vpTemplateTrackerWarpTranslation::dWarpCompo(const vpColVector &/*X1*/,const vpColVector &/*X2*/,const vpColVector &/*ParamM*/,
102  const double *dwdp0,vpMatrix &dW_)
103 {
104  for(unsigned int i=0;i<nbParam;i++)
105  {
106  dW_[0][i]=dwdp0[i];
107  dW_[1][i]=dwdp0[i+nbParam];
108  }
109 }
110 
112 {
113  vXres[0]=vX[0]+ParamM[0];
114  vXres[1]=vX[1]+ParamM[1];
115 }
117 {
118  ParamMinv[0]=-ParamM[0];
119  ParamMinv[1]=-ParamM[1];
120 }
121 
123 {
124  pres[0]=p1[0]+p2[0];
125  pres[1]=p1[1]+p2[1];
126 }
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
Definition: vpArray2D.h:167
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 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:72
void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &pres) const
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)