Visual Servoing Platform  version 3.5.1 under development (2022-08-17)
vpTemplateTrackerWarpRT.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/vpTemplateTrackerWarpRT.h>
41 
46 
54 {
55  p_down[0] = p[0];
56  p_down[1] = p[1] / 2.;
57  p_down[2] = p[2] / 2.;
58 }
59 
67 {
68  p_up[0] = p[0];
69  p_up[1] = p[1] * 2.;
70  p_up[2] = p[2] * 2.;
71 }
72 
81 void vpTemplateTrackerWarpRT::getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
82 {
83  dIdW[0] = -v * du + u * dv;
84  dIdW[1] = du;
85  dIdW[2] = dv;
86 }
87 
99 void vpTemplateTrackerWarpRT::getdWdp0(const int &v, const int &u, double *dIdW)
100 {
101  dIdW[0] = -v;
102  dIdW[1] = 1.;
103  dIdW[2] = 0;
104 
105  dIdW[3] = u;
106  dIdW[4] = 0;
107  dIdW[5] = 1.;
108 }
109 
119 void vpTemplateTrackerWarpRT::warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)
120 {
121  double c = cos(p[0]);
122  double s = sin(p[0]);
123 
124  u2 = (c * u1) - (s * v1) + p[1];
125  v2 = (s * u1) + (c * v1) + p[2];
126 }
127 
136 {
137  double c = cos(p[0]);
138  double s = sin(p[0]);
139 
140  X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
141  X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
142 }
143 
155 {
156  double u = X[0];
157  double v = X[1];
158  double c = cos(p[0]);
159  double s = sin(p[0]);
160 
161  dM[0][0] = -s * u - c * v;
162  dM[0][1] = 1;
163  dM[0][2] = 0;
164 
165  dM[1][0] = c * u - s * v;
166  dM[1][1] = 0;
167  dM[1][2] = 1;
168 }
169 
178  const double *dwdp0, vpMatrix &dM)
179 {
180  double c = cos(p[0]);
181  double s = sin(p[0]);
182 
183  for (unsigned int i = 0; i < nbParam; i++) {
184  dM[0][i] = (c * dwdp0[i]) - (s * dwdp0[i + nbParam]);
185  dM[1][i] = (s * dwdp0[i]) + (c * dwdp0[i + nbParam]);
186  }
187 }
188 
197 {
198  double c = cos(p[0]);
199  double s = sin(p[0]);
200 
201  X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
202  X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
203 }
204 
212 {
213  double c = cos(p[0]);
214  double s = sin(p[0]);
215  double u = p[1];
216  double v = p[2];
217 
218  p_inv[0] = atan2(-s, c);
219  p_inv[1] = -(c * u + s * v);
220  p_inv[2] = s * u - c * v;
221 }
222 
232 {
233  double c1 = cos(p1[0]);
234  double s1 = sin(p1[0]);
235  double c2 = cos(p2[0]);
236  double s2 = sin(p2[0]);
237  double u1 = p1[1];
238  double v1 = p1[2];
239  double u2 = p2[1];
240  double v2 = p2[2];
241 
242  p12[0] = atan2(s1 * c2 + c1 * s2, c1 * c2 - s1 * s2);
243  p12[1] = c1 * u2 - s1 * v2 + u1;
244  p12[2] = s1 * u2 + c1 * v2 + v1;
245 }
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:153
void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p)
void getParamInverse(const vpColVector &p, vpColVector &p_inv) const
void dWarp(const vpColVector &X, const vpColVector &, const vpColVector &p, vpMatrix &dM)
void getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
void warpX(const vpColVector &X1, vpColVector &X2, const vpColVector &p)
void dWarpCompo(const vpColVector &, const vpColVector &, const vpColVector &p, const double *dwdp0, vpMatrix &dM)
void getParamPyramidDown(const vpColVector &p, vpColVector &p_down)
void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &p12) const
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
void getParamPyramidUp(const vpColVector &p, vpColVector &p_up)
void getdWdp0(const int &v, const int &u, double *dIdW)
unsigned int nbParam
Number of parameters used to model warp transformation.