Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpTemplateTrackerWarpRT.cpp
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 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 https://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 *
38*****************************************************************************/
39#include <visp3/tt/vpTemplateTrackerWarpRT.h>
40
45
53{
54 p_down[0] = p[0];
55 p_down[1] = p[1] / 2.;
56 p_down[2] = p[2] / 2.;
57}
58
66{
67 p_up[0] = p[0];
68 p_up[1] = p[1] * 2.;
69 p_up[2] = p[2] * 2.;
70}
71
80void vpTemplateTrackerWarpRT::getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
81{
82 dIdW[0] = -v * du + u * dv;
83 dIdW[1] = du;
84 dIdW[2] = dv;
85}
86
98void vpTemplateTrackerWarpRT::getdWdp0(const int &v, const int &u, double *dIdW)
99{
100 dIdW[0] = -v;
101 dIdW[1] = 1.;
102 dIdW[2] = 0;
103
104 dIdW[3] = u;
105 dIdW[4] = 0;
106 dIdW[5] = 1.;
107}
108
118void vpTemplateTrackerWarpRT::warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)
119{
120 double c = cos(p[0]);
121 double s = sin(p[0]);
122
123 u2 = (c * u1) - (s * v1) + p[1];
124 v2 = (s * u1) + (c * v1) + p[2];
125}
126
135{
136 double c = cos(p[0]);
137 double s = sin(p[0]);
138
139 X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
140 X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
141}
142
154{
155 double u = X[0];
156 double v = X[1];
157 double c = cos(p[0]);
158 double s = sin(p[0]);
159
160 dM[0][0] = -s * u - c * v;
161 dM[0][1] = 1;
162 dM[0][2] = 0;
163
164 dM[1][0] = c * u - s * v;
165 dM[1][1] = 0;
166 dM[1][2] = 1;
167}
168
177 const double *dwdp0, vpMatrix &dM)
178{
179 double c = cos(p[0]);
180 double s = sin(p[0]);
181
182 for (unsigned int i = 0; i < nbParam; i++) {
183 dM[0][i] = (c * dwdp0[i]) - (s * dwdp0[i + nbParam]);
184 dM[1][i] = (s * dwdp0[i]) + (c * dwdp0[i + nbParam]);
185 }
186}
187
196{
197 double c = cos(p[0]);
198 double s = sin(p[0]);
199
200 X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
201 X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
202}
203
211{
212 double c = cos(p[0]);
213 double s = sin(p[0]);
214 double u = p[1];
215 double v = p[2];
216
217 p_inv[0] = atan2(-s, c);
218 p_inv[1] = -(c * u + s * v);
219 p_inv[2] = s * u - c * v;
220}
221
231{
232 double c1 = cos(p1[0]);
233 double s1 = sin(p1[0]);
234 double c2 = cos(p2[0]);
235 double s2 = sin(p2[0]);
236 double u1 = p1[1];
237 double v1 = p1[2];
238 double u2 = p2[1];
239 double v2 = p2[2];
240
241 p12[0] = atan2(s1 * c2 + c1 * s2, c1 * c2 - s1 * s2);
242 p12[1] = c1 * u2 - s1 * v2 + u1;
243 p12[2] = s1 * u2 + c1 * v2 + v1;
244}
Implementation of column vector and the associated operations.
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:152
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.