Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpFeatureBuilderLine.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 line.
32
*/
33
39
40
#include <visp3/core/vpDebug.h>
41
#include <visp3/core/vpMath.h>
42
#include <visp3/visual_features/vpFeatureBuilder.h>
43
44
BEGIN_VISP_NAMESPACE
57
void
vpFeatureBuilder::create
(
vpFeatureLine
&s,
const
vpLine
&t)
58
{
59
try
{
60
double
A, B, C, D;
61
s.setRhoTheta(t.getRho(), t.getTheta());
62
63
if
(fabs(t.cP[3]) > fabs(t.cP[7]))
// |D1| > |D2|
64
{
65
A = t.cP[0];
66
B = t.cP[1];
67
C = t.cP[2];
68
D = t.cP[3];
69
}
70
else
{
71
A = t.cP[4];
72
B = t.cP[5];
73
C = t.cP[6];
74
D = t.cP[7];
75
}
76
77
s.setABCD(A, B, C, D);
78
79
}
80
catch
(...) {
81
vpERROR_TRACE
(
"Error caught"
);
82
throw
;
83
}
84
}
85
101
void
vpFeatureBuilder::create
(
vpFeatureLine
&s,
const
vpCylinder
&t,
int
line)
102
{
103
try
{
104
double
a = t.getA();
105
double
b = t.getB();
106
double
c = t.getC();
107
108
double
x0 = t.getX();
109
double
y0 = t.getY();
110
double
z0 = t.getZ();
111
112
double
R = t.getR();
113
114
double
D =
115
vpMath::sqr
(x0) +
vpMath::sqr
(y0) +
vpMath::sqr
(z0) -
vpMath::sqr
(R) -
vpMath::sqr
(a * x0 + b * y0 + c * z0);
116
117
double
alpha1 = (1 - a * a) * x0 - a * b * y0 - a * c * z0;
118
double
beta1 = -a * b * x0 + (1 - b * b) * y0 - b * c * z0;
119
double
gamma1 = -a * c * x0 - b * c * y0 + (1 - c * c) * z0;
120
121
D *= -1;
122
123
if
(D < 0) {
124
alpha1 *= -1;
125
beta1 *= -1;
126
gamma1 *= -1;
127
D *= -1;
128
}
129
130
s.setABCD(alpha1, beta1, gamma1, D);
131
132
if
(line ==
vpCylinder::line1
) {
133
134
s.setRhoTheta(t.getRho1(), t.getTheta1());
135
136
}
137
else
{
138
139
s.setRhoTheta(t.getRho2(), t.getTheta2());
140
}
141
}
142
catch
(...) {
143
vpERROR_TRACE
(
"Error caught"
);
144
throw
;
145
}
146
}
147
148
#ifdef VISP_HAVE_MODULE_ME
195
void
vpFeatureBuilder::create
(
vpFeatureLine
&s,
const
vpCameraParameters
&cam,
const
vpMeLine
&t)
196
{
197
try
{
198
double
rhop = t.getRho();
199
double
thetap = t.getTheta();
200
double
rho;
201
double
theta;
202
203
// Move from (i,j) frame to (u,v) frame. rho unchanged but theta is changed
204
// since j <-> u, i <-> v so that sin(theta) = cos(thetap) and cos(theta) = sin(thetap)
205
// which means theta = pi/2 - thetap
206
207
// It would be more simple to output theta and rho in (u,v) frame
208
// in vpMeLine.cpp by just inverting sin and cos in the atan2 of
209
// vpMeLine::computeRhoTheta() to avoid the "hack" below.
210
// Not done since I am not sure vpMeLine or this function are not used
211
// for other purposes.
212
213
thetap = M_PI / 2.0 - thetap;
// input in [-pi;pi] so output in [-pi/2;3pi/2]
214
if
(thetap > M_PI) {
// thetap in [-pi;pi]
215
thetap -= 2.0 * M_PI;
216
}
217
vpPixelMeterConversion::convertLine
(cam, rhop, thetap, rho, theta);
218
s.buildFrom(rho, theta);
219
}
220
catch
(...) {
221
vpERROR_TRACE
(
"Error caught"
);
222
throw
;
223
}
224
}
225
#endif
//#ifdef VISP_HAVE_MODULE_ME
226
END_VISP_NAMESPACE
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpCylinder
Class that defines a 3D cylinder in the object frame and allows forward projection of a 3D cylinder i...
Definition
vpCylinder.h:101
vpCylinder::line1
@ line1
Definition
vpCylinder.h:105
vpFeatureBuilder::create
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Definition
vpFeatureBuilderPoint.cpp:90
vpFeatureLine
Class that defines a 2D line visual feature which is composed by two parameters that are and ,...
Definition
vpFeatureLine.h:200
vpLine
Class that defines a 3D line in the object frame and allows forward projection of the line in the cam...
Definition
vpLine.h:103
vpMath::sqr
static double sqr(double x)
Definition
vpMath.h:203
vpMeLine
Class that tracks in an image a line moving edges.
Definition
vpMeLine.h:157
vpPixelMeterConversion::convertLine
static void convertLine(const vpCameraParameters &cam, const double &rho_p, const double &theta_p, double &rho_m, double &theta_m)
Definition
vpPixelMeterConversion.cpp:98
vpERROR_TRACE
#define vpERROR_TRACE
Definition
vpDebug.h:423
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
visual_features
src
feature-builder
vpFeatureBuilderLine.cpp
Generated by
1.17.0