Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpFeatureBuilderSegment.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
* Segment creation out of dots.
32
*/
33
38
39
#include <visp3/core/vpMath.h>
40
#include <visp3/visual_features/vpFeatureBuilder.h>
41
42
BEGIN_VISP_NAMESPACE
43
#ifdef VISP_HAVE_MODULE_BLOB
44
53
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
const
vpCameraParameters
&cam,
const
vpDot
&d1,
const
vpDot
&d2)
54
{
55
double
x1 = 0, y1 = 0, x2 = 0, y2 = 0;
56
57
vpPixelMeterConversion::convertPoint
(cam, d1.
getCog
(), x1, y1);
58
vpPixelMeterConversion::convertPoint
(cam, d2.
getCog
(), x2, y2);
59
60
double
xc = (x1 + x2) / 2.;
61
double
yc = (y1 + y2) / 2.;
62
double
l = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
63
64
if
(s.isNormalized()) {
65
s.setXc(xc / l);
66
s.setYc(yc / l);
67
s.setL(1 / l);
68
}
69
else
{
70
s.setXc(xc);
71
s.setYc(yc);
72
s.setL(l);
73
}
74
75
s.setAlpha(atan2(y1 - y2, x1 - x2));
76
}
77
86
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
const
vpCameraParameters
&cam,
const
vpDot2
&d1,
const
vpDot2
&d2)
87
{
88
double
x1 = 0, y1 = 0, x2 = 0, y2 = 0;
89
90
vpPixelMeterConversion::convertPoint
(cam, d1.
getCog
(), x1, y1);
91
vpPixelMeterConversion::convertPoint
(cam, d2.
getCog
(), x2, y2);
92
93
double
xc = (x1 + x2) / 2.;
94
double
yc = (y1 + y2) / 2.;
95
double
l = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
96
97
if
(s.isNormalized()) {
98
s.setXc(xc / l);
99
s.setYc(yc / l);
100
s.setL(1 / l);
101
}
102
else
{
103
s.setXc(xc);
104
s.setYc(yc);
105
s.setL(l);
106
}
107
108
s.setAlpha(atan2(y1 - y2, x1 - x2));
109
}
110
#endif
//#ifdef VISP_HAVE_MODULE_BLOB
111
120
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
const
vpCameraParameters
&cam,
const
vpImagePoint
&ip1,
121
const
vpImagePoint
&ip2)
122
{
123
double
x1 = 0, y1 = 0, x2 = 0, y2 = 0;
124
125
vpPixelMeterConversion::convertPoint
(cam, ip1, x1, y1);
126
vpPixelMeterConversion::convertPoint
(cam, ip2, x2, y2);
127
128
double
xc = (x1 + x2) / 2.;
129
double
yc = (y1 + y2) / 2.;
130
double
l = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
131
132
if
(s.isNormalized()) {
133
s.setXc(xc / l);
134
s.setYc(yc / l);
135
s.setL(1 / l);
136
}
137
else
{
138
s.setXc(xc);
139
s.setYc(yc);
140
s.setL(l);
141
}
142
143
s.setAlpha(atan2(y1 - y2, x1 - x2));
144
}
145
155
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
vpPoint
&P1,
vpPoint
&P2)
156
{
157
double
x1 = P1.
get_x
();
158
double
y1 = P1.
get_y
();
159
double
x2 = P2.
get_x
();
160
double
y2 = P2.
get_y
();
161
162
double
Z1 = P1.
cP
[2] / P1.
cP
[3];
163
double
Z2 = P2.
cP
[2] / P2.
cP
[3];
164
165
s.buildFrom(x1, y1, Z1, x2, y2, Z2);
166
}
167
END_VISP_NAMESPACE
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
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
vpDot
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition
vpDot.h:123
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
vpFeatureSegment
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
Definition
vpFeatureSegment.h:68
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpPixelMeterConversion::convertPoint
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Definition
vpPixelMeterConversion.h:108
vpPoint
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition
vpPoint.h:79
vpPoint::get_y
double get_y() const
Get the point y coordinate in the image plane.
Definition
vpPoint.cpp:429
vpPoint::get_x
double get_x() const
Get the point x coordinate in the image plane.
Definition
vpPoint.cpp:427
vpTracker::cP
vpColVector cP
Definition
vpTracker.h:73
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
visual_features
src
feature-builder
vpFeatureBuilderSegment.cpp
Generated by
1.17.0