Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpTemplateTrackerWarpSRT.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/vpTemplateTrackerWarpSRT.h>
38
44
52{
53 p_down[0] = p[0];
54 p_down[1] = p[1];
55 p_down[2] = p[2] / 2.;
56 p_down[3] = p[3] / 2.;
57}
58
66{
67 p_up[0] = p[0];
68 p_up[1] = p[1];
69 p_up[2] = p[2] * 2.;
70 p_up[3] = p[3] * 2.;
71}
72
81void vpTemplateTrackerWarpSRT::getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)
82{
83 dIdW[0] = u * du + v * dv;
84 dIdW[1] = -v * du + u * dv;
85 dIdW[2] = du;
86 dIdW[3] = dv;
87}
88
100void vpTemplateTrackerWarpSRT::getdWdp0(const int &v, const int &u, double *dIdW)
101{
102 dIdW[0] = u;
103 dIdW[1] = -v;
104 dIdW[2] = 1.;
105 dIdW[3] = 0;
106
107 dIdW[4] = v;
108 dIdW[5] = u;
109 dIdW[6] = 0;
110 dIdW[7] = 1.;
111}
112
122void vpTemplateTrackerWarpSRT::warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)
123{
124 double c = cos(p[1]);
125 double s = sin(p[1]);
126 double scale = 1.0 + p[0];
127
128 u2 = scale * (c * u1 - s * v1) + p[2];
129 v2 = scale * (s * u1 + c * v1) + p[3];
130}
131
140{
141 double c = cos(p[1]);
142 double s = sin(p[1]);
143 double scale = 1.0 + p[0];
144
145 X2[0] = scale * (c * X1[0] - s * X1[1]) + p[2];
146 X2[1] = scale * (s * X1[0] + c * X1[1]) + p[3];
147}
148
160{
161 double u = X[0];
162 double v = X[1];
163 double c = cos(p[1]);
164 double s = sin(p[1]);
165 double scale = 1.0 + p[0];
166 double c_u_s_v = c * u - s * v;
167 double s_u_c_v = s * u + c * v;
168
169 dM[0][0] = c_u_s_v;
170 dM[0][1] = -scale * s_u_c_v;
171 dM[0][2] = 1;
172 dM[0][3] = 0;
173
174 dM[1][0] = s_u_c_v;
175 dM[1][1] = scale * c_u_s_v;
176 dM[1][2] = 0;
177 dM[1][3] = 1;
178}
179
188 const double *dwdp0, vpMatrix &dM)
189{
190 double c = cos(p[1]);
191 double s = sin(p[1]);
192 double scale = 1.0 + p[0];
193
194 for (unsigned int i = 0; i < nbParam; i++) {
195 dM[0][i] = scale * (c * dwdp0[i] - s * dwdp0[i + nbParam]);
196 dM[1][i] = scale * (s * dwdp0[i] + c * dwdp0[i + nbParam]);
197 }
198}
199
208{
209 double c = cos(p[1]);
210 double s = sin(p[1]);
211 double scale = 1.0 + p[0];
212
213 X2[0] = scale * (c * X1[0] - s * X1[1]) + p[2];
214 X2[1] = scale * (s * X1[0] + c * X1[1]) + p[3];
215}
216
224{
225 double c = cos(p[1]);
226 double s = sin(p[1]);
227 double scale = 1.0 + p[0];
228 double u = p[2];
229 double v = p[3];
230
231 p_inv[0] = 1.0 / scale - 1.0;
232 p_inv[1] = atan2(-s, c);
233 p_inv[2] = -(c * u + s * v) / scale;
234 p_inv[3] = (s * u - c * v) / scale;
235}
236
246{
247 double c1 = cos(p1[1]);
248 double s1 = sin(p1[1]);
249 double c2 = cos(p2[1]);
250 double s2 = sin(p2[1]);
251 double scale1 = 1.0 + p1[0];
252 double scale2 = 1.0 + p2[0];
253 double u1 = p1[2];
254 double v1 = p1[3];
255 double u2 = p2[2];
256 double v2 = p2[3];
257
258 p12[0] = scale1 * scale2 - 1.0;
259 p12[1] = atan2(s1 * c2 + c1 * s2, c1 * c2 - s1 * s2);
260 p12[2] = scale1 * (c1 * u2 - s1 * v2) + u1;
261 p12[3] = scale1 * (s1 * u2 + c1 * v2) + v1;
262}
263END_VISP_NAMESPACE
Implementation of column vector and the associated operations.
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p)
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 getParamPyramidUp(const vpColVector &p, vpColVector &p_up)
void getParamPyramidDown(const vpColVector &p, vpColVector &p_down)
void dWarpCompo(const vpColVector &, const vpColVector &, const vpColVector &p, const double *dwdp0, vpMatrix &dM)
void getParamInverse(const vpColVector &p, vpColVector &p_inv) const
void getdWdp0(const int &v, const int &u, double *dIdW)
void warpX(const vpColVector &X1, vpColVector &X2, const vpColVector &p)
void pRondp(const vpColVector &p1, const vpColVector &p2, vpColVector &p12) const
unsigned int nbParam
Number of parameters used to model warp transformation.