Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMeEllipse.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Moving edges.
32  *
33  * Authors:
34  * Eric Marchand
35  *
36  *****************************************************************************/
37 
43 #ifndef vpMeEllipse_HH
44 #define vpMeEllipse_HH
45 
46 #include <visp3/core/vpMatrix.h>
47 #include <visp3/core/vpColVector.h>
48 
49 #include <visp3/me/vpMeTracker.h>
50 #include <visp3/me/vpMeSite.h>
51 #include <visp3/core/vpImagePoint.h>
52 
53 #include <visp3/core/vpImage.h>
54 #include <visp3/core/vpColor.h>
55 
56 #include <math.h>
57 #include <list>
58 
95 class VISP_EXPORT vpMeEllipse : public vpMeTracker
96 {
97 public:
98  vpMeEllipse() ;
99  vpMeEllipse(const vpMeEllipse &meellipse) ;
100  virtual ~vpMeEllipse() ;
101 
105  int getExpectedDensity() {return (int)expecteddensity;};
106  void track(const vpImage<unsigned char>& Im);
107 
108  void initTracking(const vpImage<unsigned char> &I) ;
109  void initTracking(const vpImage<unsigned char> &I, const unsigned int n, vpImagePoint* iP);
110  void initTracking(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &iP);
111  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ic, double a_p, double b_p, double e_p, double low_alpha, double high_alpha) ;
112  void display(const vpImage<unsigned char>&I, vpColor col) ;
113  void display(const vpImage<unsigned char>& I) {vpMeTracker::display(I);} //Shouldn't be here since it's already in vpMeTracker
114  void printParameters() ;
115 
116 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
117 
121  void initTracking(const vpImage<unsigned char> &I, const unsigned int n,
122  unsigned *i, unsigned *j) ;
124 #endif //VISP_BUILD_DEPRECATED_FUNCTIONS
125 
131  inline double get_m00() const {return m00;}
132 
138  inline double get_m10() const {return m10;}
139 
145  inline double get_m01() const {return m01;}
146 
152  inline double get_m11() const {return m11;}
153 
159  inline double get_m20() const {return m20;}
160 
166  inline double get_m02() const {return m02;}
167 
173  inline double get_mu11() const {return mu11;}
174 
180  inline double get_mu02() const {return mu02;}
181 
187  inline double get_mu20() const {return mu20;}
188 
192  inline vpImagePoint getCenter() const {return iPc; }
193 
197  inline double getA() const {return a; }
198 
202  inline double getB() const {return b; }
203 
207  inline double getE() const {return e; }
208 
212  void getEquationParam(double &A, double &B, double &E) { A = a; B = b; E = e; }
213 
217  inline double getSmallestAngle() { return alpha1; }
218 
222  inline double getHighestAngle() { return alpha2; }
223 
233  void setThresholdRobust(const double threshold){
234  if(threshold<0){
235  thresholdWeight = 0;
236  }else if(threshold>1){
237  thresholdWeight = 1;
238  }else{
239  thresholdWeight = threshold;
240  }
241  }
242 
243 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
244 public:
245 #else
246 protected:
247 #endif
248 
255  double a;
257  double b;
259  double e;
260 
261 protected:
267  double alpha1 ;
269  double alpha2 ;
271  double ce;
273  double se;
275  std::list<double> angle;
277  double m00;
279  double mu11,mu20, mu02;
281  double m10,m01;
283  double m11,m02,m20;
288 
289 private:
290  void computeAngle(vpImagePoint pt1, vpImagePoint pt2);
291  void sample(const vpImage<unsigned char>&image);
292  void reSample(const vpImage<unsigned char> &I) ;
293  void leastSquare() ;
294  void updateTheta();
295  void suppressPoints() ;
296  void seekExtremities(const vpImage<unsigned char> &I) ;
297  void setExtremities();
298  void getParameters() ;
299  void computeMoments();
300 
301 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
302 
306  void computeAngle(int ip1, int jp1,int ip2, int jp2) ;
307  void computeAngle(int ip1, int jp1, double &alpha1,
308  int ip2, int jp2, double &alpha2) ;
314  vp_deprecated void setCircle(bool ) { }
315 
317 #endif //VISP_BUILD_DEPRECATED_FUNCTIONS
318 
319 //Static Function
320 public:
321  static void display(const vpImage<unsigned char>& I, const vpImagePoint &center,
322  const double &A, const double &B, const double &E,
323  const double & smallalpha, const double &highalpha,
324  const vpColor &color = vpColor::green,
325  unsigned int thickness=1);
326  static void display(const vpImage<vpRGBa>& I, const vpImagePoint &center,
327  const double &A, const double &B, const double &E,
328  const double & smallalpha, const double &highalpha,
329  const vpColor &color = vpColor::green,
330  unsigned int thickness=1);
331 
332 };
333 
334 #endif
double a
is the semiminor axis of the ellipse.
Definition: vpMeEllipse.h:255
double expecteddensity
Expected number of me to track along the ellipse.
Definition: vpMeEllipse.h:287
double e
is the angle made by the major axis and the i axis of the image frame .
Definition: vpMeEllipse.h:259
double thresholdWeight
Threshold for the robust least square.
Definition: vpMeEllipse.h:285
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
int getExpectedDensity()
Definition: vpMeEllipse.h:105
vpImagePoint iP1
The coordinates of the point corresponding to the smallest angle. More things about the are given a...
Definition: vpMeEllipse.h:263
double getHighestAngle()
Definition: vpMeEllipse.h:222
Class that tracks an ellipse moving edges.
Definition: vpMeEllipse.h:95
virtual void sample(const vpImage< unsigned char > &image)=0
Sample pixels at a given interval.
double getA() const
Definition: vpMeEllipse.h:197
double mu20
Definition: vpMeEllipse.h:279
static const vpColor green
Definition: vpColor.h:166
double get_mu02() const
Definition: vpMeEllipse.h:180
double b
is the semimajor axis of the ellipse.
Definition: vpMeEllipse.h:257
double se
Value of sin(e).
Definition: vpMeEllipse.h:273
double get_m02() const
Definition: vpMeEllipse.h:166
double m20
Definition: vpMeEllipse.h:283
void display(const vpImage< unsigned char > &I)
Definition: vpMeEllipse.h:113
double get_mu20() const
Definition: vpMeEllipse.h:187
vpImagePoint iP2
The coordinates of the point corresponding to the highest angle. More things about the are given at...
Definition: vpMeEllipse.h:265
vpImagePoint iPc
The coordinates of the ellipse center.
Definition: vpMeEllipse.h:253
double getE() const
Definition: vpMeEllipse.h:207
double alpha1
The smallest angle.
Definition: vpMeEllipse.h:267
double getB() const
Definition: vpMeEllipse.h:202
void setThresholdRobust(const double threshold)
Definition: vpMeEllipse.h:233
double get_m01() const
Definition: vpMeEllipse.h:145
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
double m10
First order raw moments.
Definition: vpMeEllipse.h:281
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:64
vpColVector K
Definition: vpMeEllipse.h:251
double m00
Surface.
Definition: vpMeEllipse.h:277
double get_mu11() const
Definition: vpMeEllipse.h:173
double get_m00() const
Definition: vpMeEllipse.h:131
void getEquationParam(double &A, double &B, double &E)
Definition: vpMeEllipse.h:212
std::list< double > angle
Stores the value of the angle for each vpMeSite.
Definition: vpMeEllipse.h:275
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
double get_m20() const
Definition: vpMeEllipse.h:159
double getSmallestAngle()
Definition: vpMeEllipse.h:217
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:88
double alpha2
The highest angle.
Definition: vpMeEllipse.h:269
double get_m10() const
Definition: vpMeEllipse.h:138
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0
vpImagePoint getCenter() const
Definition: vpMeEllipse.h:192
double ce
Value of cos(e).
Definition: vpMeEllipse.h:271
double get_m11() const
Definition: vpMeEllipse.h:152