Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpFeatureBuilderEllipse.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 * Conversion between tracker and visual feature ellipse.
33 *
34*****************************************************************************/
35
42#include <visp3/core/vpMath.h>
43#include <visp3/visual_features/vpFeatureBuilder.h>
44
60{
61 // 3D data
62 double alpha = t.cP[0]; // A
63 double beta = t.cP[1]; // B
64 double gamma = t.cP[2]; // C
65
66 double X0 = t.cP[3];
67 double Y0 = t.cP[4];
68 double Z0 = t.cP[5];
69
70 // equation p 318 prior eq (39)
71 double d = alpha * X0 + beta * Y0 + gamma * Z0;
72
73 double A = alpha / d;
74 double B = beta / d;
75 double C = gamma / d;
76
77 s.setABC(A, B, C);
78
79 // 2D data
80 s.buildFrom(t.p[0], t.p[1], t.p[2], t.p[3], t.p[4]);
81}
82
98{
99 // 3D data
100 double X0 = t.cP[0];
101 double Y0 = t.cP[1];
102 double Z0 = t.cP[2];
103 double R = t.cP[3];
104
105 double d = vpMath::sqr(X0) + vpMath::sqr(Y0) + vpMath::sqr(Z0) - vpMath::sqr(R);
106
107 double A = X0 / d;
108 double B = Y0 / d;
109 double C = Z0 / d;
110
111 s.setABC(A, B, C);
112
113 // 2D data
114 s.buildFrom(t.p[0], t.p[1], t.p[2], t.p[3], t.p[4]);
115}
116
117#ifdef VISP_HAVE_MODULE_BLOB
136{
137 double xc = 0, yc = 0;
138 vpPixelMeterConversion::convertPoint(cam, blob.getCog(), xc, yc);
139 vpColVector nij = blob.get_nij();
140
141 s.buildFrom(xc, yc, nij[0], nij[1], nij[2]);
142}
143
162{
163 double xc = 0, yc = 0;
164 vpPixelMeterConversion::convertPoint(cam, blob.getCog(), xc, yc);
165 vpColVector nij = blob.get_nij();
166
167 s.buildFrom(xc, yc, nij[0], nij[1], nij[2]);
168}
169#endif //#ifdef VISP_HAVE_MODULE_BLOB
170
171#ifdef VISP_HAVE_MODULE_ME
190{
191 double xg, yg, n20, n11, n02;
192 vpPixelMeterConversion::convertEllipse(cam, ellipse.getCenter(), ellipse.get_nij()[0], ellipse.get_nij()[1],
193 ellipse.get_nij()[2], xg, yg, n20, n11, n02);
194
195 s.buildFrom(xg, yg, n20, n11, n02);
196}
197
198#endif //#ifdef VISP_HAVE_MODULE_ME
Generic class defining intrinsic camera parameters.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
Definition vpCircle.h:87
Implementation of column vector and the associated operations.
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
Definition vpDot2.h:124
vpImagePoint getCog() const
Definition vpDot2.h:177
vpColVector get_nij() const
Definition vpDot2.h:145
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition vpDot.h:112
vpColVector get_nij() const
Definition vpDot.h:206
vpImagePoint getCog() const
Definition vpDot.h:243
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Class that defines 2D ellipse visual feature.
void setABC(double A, double B, double C)
void buildFrom(double x, double y, double n20, double n11, double n02)
static double sqr(double x)
Definition vpMath.h:124
Class that tracks an ellipse using moving edges.
Definition vpMeEllipse.h:90
vpImagePoint getCenter() const
vpColVector get_nij() const
static void convertEllipse(const vpCameraParameters &cam, const vpImagePoint &center_p, double n20_p, double n11_p, double n02_p, double &xc_m, double &yc_m, double &n20_m, double &n11_m, double &n02_m)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Class that defines a 3D sphere in the object frame and allows forward projection of a 3D sphere in th...
Definition vpSphere.h:78
vpColVector cP
Definition vpTracker.h:72
vpColVector p
Definition vpTracker.h:68