ViSP
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Functions
Variables
Enumerations
Enumerator
Friends
Groups
Pages
vpFeatureBuilderSegment.cpp
1
/****************************************************************************
2
*
3
* $Id: vpFeatureBuilderLine.cpp 3530 2012-01-03 10:52:12Z fspindle $
4
*
5
* This file is part of the ViSP software.
6
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7
*
8
* This software is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* ("GPL") version 2 as published by the Free Software Foundation.
11
* See the file LICENSE.txt at the root directory of this source
12
* distribution for additional information about the GNU GPL.
13
*
14
* For using ViSP with software that can not be combined with the GNU
15
* GPL, please contact INRIA about acquiring a ViSP Professional
16
* Edition License.
17
*
18
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19
*
20
* This software was developed at:
21
* INRIA Rennes - Bretagne Atlantique
22
* Campus Universitaire de Beaulieu
23
* 35042 Rennes Cedex
24
* France
25
* http://www.irisa.fr/lagadic
26
*
27
* If you have questions regarding the use of this file, please contact
28
* INRIA at visp@inria.fr
29
*
30
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32
*
33
*
34
* Description:
35
* Segment creation out of dots.
36
*
37
* Authors:
38
* Filip Novotny
39
* Fabien Spindler
40
*
41
*****************************************************************************/
42
43
49
#include <visp/vpFeatureBuilder.h>
50
#include <visp/vpMath.h>
51
52
62
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
const
vpCameraParameters
&cam,
63
const
vpDot
&d1,
const
vpDot
&d2 )
64
{
65
double
x1=0, y1=0, x2=0, y2=0;
66
67
vpPixelMeterConversion::convertPoint
(cam, d1.
getCog
(), x1, y1) ;
68
vpPixelMeterConversion::convertPoint
(cam, d2.
getCog
(), x2, y2) ;
69
70
double
xc = (x1+x2)/2.;
71
double
yc = (y1+y2)/2.;
72
double
l = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
73
74
if
(s.
isNormalized
())
75
{
76
s.
setXc
( xc/l );
77
s.
setYc
( yc/l );
78
s.
setL
( 1/l );
79
}
80
else
81
{
82
s.
setXc
( xc );
83
s.
setYc
( yc );
84
s.
setL
( l );
85
}
86
87
s.
setAlpha
(atan2(y1-y2,x1-x2));
88
}
89
99
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
const
vpCameraParameters
&cam,
100
const
vpDot2
&d1,
const
vpDot2
&d2)
101
{
102
double
x1=0, y1=0, x2=0, y2=0;
103
104
vpPixelMeterConversion::convertPoint
(cam, d1.
getCog
(), x1, y1) ;
105
vpPixelMeterConversion::convertPoint
(cam, d2.
getCog
(), x2, y2) ;
106
107
double
xc = (x1+x2)/2.;
108
double
yc = (y1+y2)/2.;
109
double
l = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
110
111
if
(s.
isNormalized
())
112
{
113
s.
setXc
( xc/l );
114
s.
setYc
( yc/l );
115
s.
setL
( 1/l );
116
}
117
else
118
{
119
s.
setXc
( xc );
120
s.
setYc
( yc );
121
s.
setL
( l );
122
}
123
124
s.
setAlpha
(atan2(y1-y2,x1-x2));
125
}
126
136
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
const
vpCameraParameters
&cam,
137
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2)
138
{
139
double
x1=0, y1=0, x2=0, y2=0;
140
141
vpPixelMeterConversion::convertPoint
(cam, ip1, x1, y1) ;
142
vpPixelMeterConversion::convertPoint
(cam, ip2, x2, y2) ;
143
144
double
xc = (x1+x2)/2.;
145
double
yc = (y1+y2)/2.;
146
double
l = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
147
148
if
(s.
isNormalized
())
149
{
150
s.
setXc
( xc/l );
151
s.
setYc
( yc/l );
152
s.
setL
( 1/l );
153
}
154
else
155
{
156
s.
setXc
( xc );
157
s.
setYc
( yc );
158
s.
setL
( l );
159
}
160
161
s.
setAlpha
(atan2(y1-y2,x1-x2));
162
}
163
173
void
vpFeatureBuilder::create
(
vpFeatureSegment
&s,
vpPoint
& P1,
vpPoint
& P2)
174
{
175
double
x1 = P1.
get_x
();
176
double
y1 = P1.
get_y
();
177
double
x2 = P2.
get_x
();
178
double
y2 = P2.
get_y
();
179
180
double
Z1 = P1.
cP
[2]/P1.
cP
[3];
181
double
Z2 = P2.
cP
[2]/P2.
cP
[3];
182
183
s.
buildFrom
(x1, y1, Z1, x2, y2, Z2);
184
}
src
tracking
feature-builder
vpFeatureBuilderSegment.cpp
Generated on Wed Jun 12 2013 05:39:47 for ViSP by
1.8.1.2