ViSP  2.6.2
vpMeEllipse.h
1 /****************************************************************************
2  *
3  * $Id: vpMeEllipse.h 3581 2012-03-01 15:19:07Z ayol $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 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 
135 class VISP_EXPORT vpMeEllipse : public vpMeTracker
136 {
137 public:
138  vpMeEllipse() ;
139  vpMeEllipse(const vpMeEllipse &meellipse) ;
140  virtual ~vpMeEllipse() ;
141 
142  void track(const vpImage<unsigned char>& Im);
143 
144  void initTracking(const vpImage<unsigned char> &I) ;
145  void initTracking(const vpImage<unsigned char> &I, const unsigned int n,
146  vpImagePoint* iP) ;
147  void display(const vpImage<unsigned char>&I, vpColor col) ;
148  void printParameters() ;
149 
150 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
151 
155  void initTracking(const vpImage<unsigned char> &I, const unsigned int n,
156  unsigned *i, unsigned *j) ;
158 #endif //VISP_BUILD_DEPRECATED_FUNCTIONS
159 
173  void setCircle(bool circle) { this->circle = circle ; }
174 
180  inline double get_m00() const {return m00;}
181 
187  inline double get_m10() const {return m10;}
188 
194  inline double get_m01() const {return m01;}
195 
201  inline double get_m11() const {return m11;}
202 
208  inline double get_m20() const {return m20;}
209 
215  inline double get_m02() const {return m02;}
216 
222  inline double get_mu11() const {return mu11;}
223 
229  inline double get_mu02() const {return mu02;}
230 
236  inline double get_mu20() const {return mu20;}
237 
241  inline vpImagePoint getCenter() const {return iPc; }
242 
246  inline double getA() const {return a; }
247 
251  inline double getB() const {return b; }
252 
256  inline double getE() const {return e; }
257 
261  void getEquationParam(double &A, double &B, double &E) { A = a; B = b; E = e; }
262 
266  inline double getSmallestAngle() { return alpha1; }
267 
271  inline double getHighestAngle() { return alpha2; }
272 
282  void setThresholdRobust(const double threshold){
283  if(threshold<0){
284  thresholdWeight = 0;
285  }else if(threshold>1){
286  thresholdWeight = 1;
287  }else{
288  thresholdWeight = threshold;
289  }
290  }
291 
292 
293 
294 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
295 public:
296 #else
297 protected:
298 #endif
299 
306  double a;
308  double b;
310  double e;
311 
312 protected:
318  double alpha1 ;
320  double alpha2 ;
322  double ce;
324  double se;
326  std::list<double> angle;
328  double m00;
330  double mu11,mu20, mu02;
332  double m10,m01;
334  double m11,m02,m20;
337 
338 private:
340  bool circle ;
341 
342  void computeAngle(vpImagePoint pt1, vpImagePoint pt2);
343  void sample(const vpImage<unsigned char>&image);
344  void reSample(const vpImage<unsigned char> &I) ;
345  void leastSquare() ;
346  void updateTheta();
347  void suppressPoints() ;
348  void seekExtremities(const vpImage<unsigned char> &I) ;
349  void setExtremities();
350  void getParameters() ;
351  void computeMoments();
352 
353 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
354 
358  void computeAngle(int ip1, int jp1,int ip2, int jp2) ;
359  void computeAngle(int ip1, int jp1, double &alpha1,
360  int ip2, int jp2, double &alpha2) ;
362 #endif //VISP_BUILD_DEPRECATED_FUNCTIONS
363 
364 //Static Function
365 public:
366  static void display(const vpImage<unsigned char>& I, const vpImagePoint &center,
367  const double &A, const double &B, const double &E,
368  const double & smallalpha, const double &highalpha,
369  vpColor color = vpColor::green);
370 
371 };
372 
373 
374 
375 
376 #endif
377 
378 
double a
is the semiminor axis of the ellipse.
Definition: vpMeEllipse.h:306
double e
is the angle made by the major axis and the i axis of the image frame .
Definition: vpMeEllipse.h:310
double thresholdWeight
Threshold for the robust least square.
Definition: vpMeEllipse.h:336
Class to define colors available for display functionnalities.
Definition: vpColor.h:123
vpImagePoint iP1
The coordinates of the point corresponding to the smallest angle. More things about the are given a...
Definition: vpMeEllipse.h:314
double getHighestAngle()
Definition: vpMeEllipse.h:271
Class that tracks an ellipse moving edges.
Definition: vpMeEllipse.h:135
virtual void sample(const vpImage< unsigned char > &image)=0
Sample pixels at a given interval.
double getA() const
Definition: vpMeEllipse.h:246
double mu20
Definition: vpMeEllipse.h:330
static const vpColor green
Definition: vpColor.h:168
double get_mu02() const
Definition: vpMeEllipse.h:229
double b
is the semimajor axis of the ellipse.
Definition: vpMeEllipse.h:308
double se
Value of sin(e).
Definition: vpMeEllipse.h:324
double get_m02() const
Definition: vpMeEllipse.h:215
double m20
Definition: vpMeEllipse.h:334
double get_mu20() const
Definition: vpMeEllipse.h:236
vpImagePoint iP2
The coordinates of the point corresponding to the highest angle. More things about the are given at...
Definition: vpMeEllipse.h:316
vpImagePoint iPc
The coordinates of the ellipse center.
Definition: vpMeEllipse.h:304
double getE() const
Definition: vpMeEllipse.h:256
double alpha1
The smallest angle.
Definition: vpMeEllipse.h:318
double getB() const
Definition: vpMeEllipse.h:251
void setThresholdRobust(const double threshold)
Definition: vpMeEllipse.h:282
double get_m01() const
Definition: vpMeEllipse.h:194
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
double m10
First order raw moments.
Definition: vpMeEllipse.h:332
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:71
vpColVector K
Definition: vpMeEllipse.h:302
void setCircle(bool circle)
Definition: vpMeEllipse.h:173
double m00
Surface.
Definition: vpMeEllipse.h:328
double get_mu11() const
Definition: vpMeEllipse.h:222
double get_m00() const
Definition: vpMeEllipse.h:180
void getEquationParam(double &A, double &B, double &E)
Definition: vpMeEllipse.h:261
std::list< double > angle
Stores the value of the angle for each vpMeSite.
Definition: vpMeEllipse.h:326
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
double get_m20() const
Definition: vpMeEllipse.h:208
double getSmallestAngle()
Definition: vpMeEllipse.h:266
void initTracking(const vpImage< unsigned char > &I)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
double alpha2
The highest angle.
Definition: vpMeEllipse.h:320
double get_m10() const
Definition: vpMeEllipse.h:187
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0
vpImagePoint getCenter() const
Definition: vpMeEllipse.h:241
double ce
Value of cos(e).
Definition: vpMeEllipse.h:322
double get_m11() const
Definition: vpMeEllipse.h:201