Visual Servoing Platform version 3.5.0
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{
47 nbParam = 3;
48}
49
57{
58 p_down[0] = p[0];
59 p_down[1] = p[1] / 2.;
60 p_down[2] = p[2] / 2.;
61}
62
70{
71 p_up[0] = p[0];
72 p_up[1] = p[1] * 2.;
73 p_up[2] = p[2] * 2.;
74}
75
84void vpTemplateTrackerWarpRT::getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
85{
86 dIdW[0] = -v * du + u * dv;
87 dIdW[1] = du;
88 dIdW[2] = dv;
89}
90
102void vpTemplateTrackerWarpRT::getdWdp0(const int &v, const int &u, double *dIdW)
103{
104 dIdW[0] = -v;
105 dIdW[1] = 1.;
106 dIdW[2] = 0;
107
108 dIdW[3] = u;
109 dIdW[4] = 0;
110 dIdW[5] = 1.;
111}
112
122void vpTemplateTrackerWarpRT::warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)
123{
124 double c = cos(p[0]);
125 double s = sin(p[0]);
126
127 u2 = (c * u1) - (s * v1) + p[1];
128 v2 = (s * u1) + (c * v1) + p[2];
129}
130
139{
140 double c = cos(p[0]);
141 double s = sin(p[0]);
142
143 X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
144 X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
145}
146
158 vpMatrix &dM)
159{
160 double u = X[0];
161 double v = X[1];
162 double c = cos(p[0]);
163 double s = sin(p[0]);
164
165 dM[0][0] = - s * u - c * v;
166 dM[0][1] = 1;
167 dM[0][2] = 0;
168
169 dM[1][0] = c * u - s * v;
170 dM[1][1] = 0;
171 dM[1][2] = 1;
172}
173
182 const vpColVector &p, const double *dwdp0, vpMatrix &dM)
183{
184 double c = cos(p[0]);
185 double s = sin(p[0]);
186
187 for (unsigned int i = 0; i < nbParam; i++) {
188 dM[0][i] = (c * dwdp0[i]) - (s * dwdp0[i + nbParam]);
189 dM[1][i] = (s * dwdp0[i]) + (c * dwdp0[i + nbParam]);
190 }
191}
192
201{
202 double c = cos(p[0]);
203 double s = sin(p[0]);
204
205 X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
206 X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
207}
208
216{
217 double c = cos(p[0]);
218 double s = sin(p[0]);
219 double u = p[1];
220 double v = p[2];
221
222 p_inv[0] = atan2(-s, c);
223 p_inv[1] = -(c * u + s * v);
224 p_inv[2] = s * u - c * v;
225}
226
236{
237 double c1 = cos(p1[0]);
238 double s1 = sin(p1[0]);
239 double c2 = cos(p2[0]);
240 double s2 = sin(p2[0]);
241 double u1 = p1[1];
242 double v1 = p1[2];
243 double u2 = p2[1];
244 double v2 = p2[2];
245
246 p12[0] = atan2(s1 * c2 + c1 * s2, c1 * c2 - s1 * s2);
247 p12[1] = c1 * u2 - s1 * v2 + u1;
248 p12[2] = s1 * u2 + c1 * v2 + v1;
249}
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
void getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
void getParamInverse(const vpColVector &p, vpColVector &p_inv) const
void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &p12) const
void getdWdp0(const int &v, const int &u, double *dIdW)
void getParamPyramidUp(const vpColVector &p, vpColVector &p_up)
void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p)
void dWarp(const vpColVector &X, const vpColVector &, const vpColVector &p, vpMatrix &dM)
void dWarpCompo(const vpColVector &, const vpColVector &, const vpColVector &p, const double *dwdp0, vpMatrix &dM)
void getParamPyramidDown(const vpColVector &p, vpColVector &p_down)
void warpX(const vpColVector &X1, vpColVector &X2, const vpColVector &p)
unsigned int nbParam
Number of parameters used to model warp transformation.