ViSP
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Functions
Variables
Enumerations
Enumerator
Friends
Groups
Pages
vpMeEllipse.h
1
/****************************************************************************
2
*
3
* $Id: vpMeEllipse.h 4231 2013-04-29 16:26:28Z 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
* Moving edges.
36
*
37
* Authors:
38
* Eric Marchand
39
*
40
*****************************************************************************/
41
47
#ifndef vpMeEllipse_HH
48
#define vpMeEllipse_HH
49
50
#include <visp/vpMatrix.h>
51
#include <visp/vpColVector.h>
52
53
#include <visp/vpMeTracker.h>
54
#include <visp/vpMeSite.h>
55
#include <visp/vpImagePoint.h>
56
57
#include <visp/vpImage.h>
58
#include <visp/vpColor.h>
59
60
#include <math.h>
61
#include <list>
62
99
/*
100
The code below shows how to use this class.
101
\code
102
#include <visp/vpConfig.h>
103
#include <visp/vpImage.h>
104
#include <visp/vpMeEllipse.h>
105
#include <visp/vpImagePoint.h>
106
107
int main()
108
{
109
vpImage<unsigned char> I;
110
111
// I is the image containing the ellipse to track
112
113
// Set the moving-edges tracker parameters
114
vpMe me;
115
me.setRange(25);
116
me.setPointsToTrack(20);
117
me.setThreshold(15000);
118
me.setSampleStep(10);
119
120
// Initialize the moving-edges ellipse tracker parameters
121
vpMeEllipse ellipse;
122
ellipse.setMe(&me);
123
124
// Initialize the tracking. You have to click on five different points belonging to the ellipse.
125
ellipse.initTracking(I);
126
127
while ( 1 )
128
{
129
// ... Here the code to read or grab the next image.
130
131
// Track the ellipse.
132
ellipse.track(I);
133
}
134
return 0;
135
}
136
\endcode
137
138
\note It is possible to display the ellipse as an overlay. For that you
139
must use the display function of the class vpMeEllipse.
140
*/
141
142
class
VISP_EXPORT
vpMeEllipse
:
public
vpMeTracker
143
{
144
public
:
145
vpMeEllipse
() ;
146
vpMeEllipse
(
const
vpMeEllipse
&meellipse) ;
147
virtual
~
vpMeEllipse
() ;
148
149
void
track
(
const
vpImage<unsigned char>
& Im);
150
151
void
initTracking
(
const
vpImage<unsigned char>
&I) ;
152
void
initTracking
(
const
vpImage<unsigned char>
&I,
const
unsigned
int
n,
153
vpImagePoint
* iP) ;
154
void
display
(
const
vpImage<unsigned char>
&I,
vpColor
col) ;
155
void
printParameters() ;
156
157
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
158
162
void
initTracking
(
const
vpImage<unsigned char>
&I,
const
unsigned
int
n,
163
unsigned
*i,
unsigned
*j) ;
165
#endif //VISP_BUILD_DEPRECATED_FUNCTIONS
166
180
void
setCircle
(
bool
circle) { this->circle = circle ; }
181
187
inline
double
get_m00
()
const
{
return
m00;}
188
194
inline
double
get_m10
()
const
{
return
m10;}
195
201
inline
double
get_m01
()
const
{
return
m01;}
202
208
inline
double
get_m11
()
const
{
return
m11;}
209
215
inline
double
get_m20
()
const
{
return
m20;}
216
222
inline
double
get_m02
()
const
{
return
m02;}
223
229
inline
double
get_mu11
()
const
{
return
mu11;}
230
236
inline
double
get_mu02
()
const
{
return
mu02;}
237
243
inline
double
get_mu20
()
const
{
return
mu20;}
244
248
inline
vpImagePoint
getCenter
()
const
{
return
iPc; }
249
253
inline
double
getA
()
const
{
return
a; }
254
258
inline
double
getB
()
const
{
return
b; }
259
263
inline
double
getE
()
const
{
return
e; }
264
268
void
getEquationParam
(
double
&A,
double
&B,
double
&E) { A = a; B = b; E = e; }
269
273
inline
double
getSmallestAngle
() {
return
alpha1; }
274
278
inline
double
getHighestAngle
() {
return
alpha2; }
279
289
void
setThresholdRobust
(
const
double
threshold){
290
if
(threshold<0){
291
thresholdWeight = 0;
292
}
else
if
(threshold>1){
293
thresholdWeight = 1;
294
}
else
{
295
thresholdWeight = threshold;
296
}
297
}
298
299
300
301
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
302
public
:
303
#else
304
protected
:
305
#endif
306
309
vpColVector
K
;
311
vpImagePoint
iPc
;
313
double
a
;
315
double
b
;
317
double
e
;
318
319
protected
:
321
vpImagePoint
iP1
;
323
vpImagePoint
iP2
;
325
double
alpha1
;
327
double
alpha2
;
329
double
ce
;
331
double
se
;
333
std::list<double>
angle
;
335
double
m00
;
337
double
mu11,
mu20
, mu02;
339
double
m10
,m01;
341
double
m11,m02,
m20
;
343
double
thresholdWeight
;
344
345
private
:
347
bool
circle ;
348
349
void
computeAngle(
vpImagePoint
pt1,
vpImagePoint
pt2);
350
void
sample
(
const
vpImage<unsigned char>
&image);
351
void
reSample(
const
vpImage<unsigned char>
&I) ;
352
void
leastSquare() ;
353
void
updateTheta();
354
void
suppressPoints() ;
355
void
seekExtremities(
const
vpImage<unsigned char>
&I) ;
356
void
setExtremities();
357
void
getParameters() ;
358
void
computeMoments();
359
360
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
361
365
void
computeAngle(
int
ip1,
int
jp1,
int
ip2,
int
jp2) ;
366
void
computeAngle(
int
ip1,
int
jp1,
double
&alpha1,
367
int
ip2,
int
jp2,
double
&alpha2) ;
369
#endif //VISP_BUILD_DEPRECATED_FUNCTIONS
370
371
//Static Function
372
public
:
373
static
void
display
(
const
vpImage<unsigned char>
& I,
const
vpImagePoint
¢er,
374
const
double
&A,
const
double
&B,
const
double
&E,
375
const
double
& smallalpha,
const
double
&highalpha,
376
vpColor
color =
vpColor::green
);
377
static
void
display
(
const
vpImage<vpRGBa>
& I,
const
vpImagePoint
¢er,
378
const
double
&A,
const
double
&B,
const
double
&E,
379
const
double
& smallalpha,
const
double
&highalpha,
380
vpColor
color =
vpColor::green
);
381
382
};
383
384
#endif
src
tracking
moving-edges
vpMeEllipse.h
Generated on Tue Sep 17 2013 00:21:40 for ViSP by
1.8.4