Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpFeatureBuilderEllipse.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
* Conversion between tracker and visual feature ellipse.
32
*/
33
39
40
#include <visp3/core/vpMath.h>
41
#include <visp3/visual_features/vpFeatureBuilder.h>
42
43
BEGIN_VISP_NAMESPACE
58
void
vpFeatureBuilder::create
(
vpFeatureEllipse
&s,
const
vpCircle
&t)
59
{
60
// 3D data
61
double
alpha = t.cP[0];
// A
62
double
beta = t.cP[1];
// B
63
double
gamma = t.cP[2];
// C
64
65
double
X0 = t.cP[3];
66
double
Y0 = t.cP[4];
67
double
Z0 = t.cP[5];
68
69
// equation p 318 prior eq (39)
70
double
d = alpha * X0 + beta * Y0 + gamma * Z0;
71
72
double
A = alpha / d;
73
double
B = beta / d;
74
double
C = gamma / d;
75
76
s.setABC(A, B, C);
77
78
// 2D data
79
s.buildFrom(t.p[0], t.p[1], t.p[2], t.p[3], t.p[4]);
80
}
81
96
void
vpFeatureBuilder::create
(
vpFeatureEllipse
&s,
const
vpSphere
&t)
97
{
98
// 3D data
99
double
X0 = t.cP[0];
100
double
Y0 = t.cP[1];
101
double
Z0 = t.cP[2];
102
double
R = t.cP[3];
103
104
double
d =
vpMath::sqr
(X0) +
vpMath::sqr
(Y0) +
vpMath::sqr
(Z0) -
vpMath::sqr
(R);
105
106
double
A = X0 / d;
107
double
B = Y0 / d;
108
double
C = Z0 / d;
109
110
s.setABC(A, B, C);
111
112
// 2D data
113
s.buildFrom(t.p[0], t.p[1], t.p[2], t.p[3], t.p[4]);
114
}
115
116
#ifdef VISP_HAVE_MODULE_BLOB
134
void
vpFeatureBuilder::create
(
vpFeatureEllipse
&s,
const
vpCameraParameters
&cam,
const
vpDot
&blob)
135
{
136
double
xc = 0, yc = 0;
137
vpPixelMeterConversion::convertPoint
(cam, blob.
getCog
(), xc, yc);
138
vpColVector
nij = blob.
get_nij
();
139
140
s.buildFrom(xc, yc, nij[0], nij[1], nij[2]);
141
}
142
160
void
vpFeatureBuilder::create
(
vpFeatureEllipse
&s,
const
vpCameraParameters
&cam,
const
vpDot2
&blob)
161
{
162
double
xc = 0, yc = 0;
163
vpPixelMeterConversion::convertPoint
(cam, blob.
getCog
(), xc, yc);
164
vpColVector
nij = blob.
get_nij
();
165
166
s.buildFrom(xc, yc, nij[0], nij[1], nij[2]);
167
}
168
#endif
//#ifdef VISP_HAVE_MODULE_BLOB
169
170
#ifdef VISP_HAVE_MODULE_ME
188
void
vpFeatureBuilder::create
(
vpFeatureEllipse
&s,
const
vpCameraParameters
&cam,
const
vpMeEllipse
&ellipse)
189
{
190
double
xg, yg, n20, n11, n02;
191
vpPixelMeterConversion::convertEllipse
(cam, ellipse.
getCenter
(), ellipse.
get_nij
()[0], ellipse.
get_nij
()[1],
192
ellipse.
get_nij
()[2], xg, yg, n20, n11, n02);
193
194
s.buildFrom(xg, yg, n20, n11, n02);
195
}
196
197
#endif
//#ifdef VISP_HAVE_MODULE_ME
198
END_VISP_NAMESPACE
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpCircle
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
Definition
vpCircle.h:87
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpDot2
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
Definition
vpDot2.h:127
vpDot2::getCog
vpImagePoint getCog() const
Definition
vpDot2.h:183
vpDot2::get_nij
vpColVector get_nij() const
Definition
vpDot2.h:147
vpDot
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition
vpDot.h:123
vpDot::get_nij
vpColVector get_nij() const
Definition
vpDot.h:216
vpDot::getCog
vpImagePoint getCog() const
Definition
vpDot.h:255
vpFeatureBuilder::create
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Definition
vpFeatureBuilderPoint.cpp:90
vpFeatureEllipse
Class that defines 2D ellipse visual feature.
Definition
vpFeatureEllipse.h:56
vpMath::sqr
static double sqr(double x)
Definition
vpMath.h:203
vpMeEllipse
Class that tracks an ellipse or a circle using moving edges.
Definition
vpMeEllipse.h:100
vpMeEllipse::getCenter
vpImagePoint getCenter() const
Definition
vpMeEllipse.h:203
vpMeEllipse::get_nij
vpColVector get_nij() const
Definition
vpMeEllipse.h:153
vpPixelMeterConversion::convertEllipse
static void convertEllipse(const vpCameraParameters &cam, const vpImagePoint ¢er_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)
Definition
vpPixelMeterConversion.cpp:74
vpPixelMeterConversion::convertPoint
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Definition
vpPixelMeterConversion.h:108
vpSphere
Class that defines a 3D sphere in the object frame and allows forward projection of a 3D sphere in th...
Definition
vpSphere.h:80
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
visual_features
src
feature-builder
vpFeatureBuilderEllipse.cpp
Generated by
1.17.0