Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpTemplateTrackerWarpRT.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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 */
37#include <visp3/tt/vpTemplateTrackerWarpRT.h>
38
44
52{
53 p_down[0] = p[0];
54 p_down[1] = p[1] / 2.;
55 p_down[2] = p[2] / 2.;
56}
57
65{
66 p_up[0] = p[0];
67 p_up[1] = p[1] * 2.;
68 p_up[2] = p[2] * 2.;
69}
70
79void vpTemplateTrackerWarpRT::getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
80{
81 dIdW[0] = -v * du + u * dv;
82 dIdW[1] = du;
83 dIdW[2] = dv;
84}
85
97void vpTemplateTrackerWarpRT::getdWdp0(const int &v, const int &u, double *dIdW)
98{
99 dIdW[0] = -v;
100 dIdW[1] = 1.;
101 dIdW[2] = 0;
102
103 dIdW[3] = u;
104 dIdW[4] = 0;
105 dIdW[5] = 1.;
106}
107
117void vpTemplateTrackerWarpRT::warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)
118{
119 double c = cos(p[0]);
120 double s = sin(p[0]);
121
122 u2 = (c * u1) - (s * v1) + p[1];
123 v2 = (s * u1) + (c * v1) + p[2];
124}
125
134{
135 double c = cos(p[0]);
136 double s = sin(p[0]);
137
138 X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
139 X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
140}
141
153{
154 double u = X[0];
155 double v = X[1];
156 double c = cos(p[0]);
157 double s = sin(p[0]);
158
159 dM[0][0] = -s * u - c * v;
160 dM[0][1] = 1;
161 dM[0][2] = 0;
162
163 dM[1][0] = c * u - s * v;
164 dM[1][1] = 0;
165 dM[1][2] = 1;
166}
167
176 const double *dwdp0, vpMatrix &dM)
177{
178 double c = cos(p[0]);
179 double s = sin(p[0]);
180
181 for (unsigned int i = 0; i < nbParam; i++) {
182 dM[0][i] = (c * dwdp0[i]) - (s * dwdp0[i + nbParam]);
183 dM[1][i] = (s * dwdp0[i]) + (c * dwdp0[i + nbParam]);
184 }
185}
186
195{
196 double c = cos(p[0]);
197 double s = sin(p[0]);
198
199 X2[0] = (c * X1[0]) - (s * X1[1]) + p[1];
200 X2[1] = (s * X1[0]) + (c * X1[1]) + p[2];
201}
202
210{
211 double c = cos(p[0]);
212 double s = sin(p[0]);
213 double u = p[1];
214 double v = p[2];
215
216 p_inv[0] = atan2(-s, c);
217 p_inv[1] = -(c * u + s * v);
218 p_inv[2] = s * u - c * v;
219}
220
230{
231 double c1 = cos(p1[0]);
232 double s1 = sin(p1[0]);
233 double c2 = cos(p2[0]);
234 double s2 = sin(p2[0]);
235 double u1 = p1[1];
236 double v1 = p1[2];
237 double u2 = p2[1];
238 double v2 = p2[2];
239
240 p12[0] = atan2(s1 * c2 + c1 * s2, c1 * c2 - s1 * s2);
241 p12[1] = c1 * u2 - s1 * v2 + u1;
242 p12[2] = s1 * u2 + c1 * v2 + v1;
243}
244END_VISP_NAMESPACE
Implementation of column vector and the associated operations.
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
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.