Visual Servoing Platform  version 3.1.0
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 modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Moving edges.
33  *
34  * Authors:
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
44 #ifndef vpMeEllipse_HH
45 #define vpMeEllipse_HH
46 
47 #include <visp3/core/vpColVector.h>
48 #include <visp3/core/vpMatrix.h>
49 
50 #include <visp3/core/vpImagePoint.h>
51 #include <visp3/me/vpMeSite.h>
52 #include <visp3/me/vpMeTracker.h>
53 
54 #include <visp3/core/vpColor.h>
55 #include <visp3/core/vpImage.h>
56 
57 #include <list>
58 #include <math.h>
59 
106 class VISP_EXPORT vpMeEllipse : public vpMeTracker
107 {
108 public:
109  vpMeEllipse();
110  vpMeEllipse(const vpMeEllipse &meellipse);
111  virtual ~vpMeEllipse();
112 
116  int getExpectedDensity() { return (int)expecteddensity; };
117  void track(const vpImage<unsigned char> &Im);
118 
119  void initTracking(const vpImage<unsigned char> &I);
120  void initTracking(const vpImage<unsigned char> &I, const unsigned int n, vpImagePoint *iP);
121  void initTracking(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &iP);
122  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ic, double a_p, double b_p, double e_p,
123  double low_alpha, double high_alpha);
124  void display(const vpImage<unsigned char> &I, vpColor col);
126  {
128  } // Shouldn't be here since it's already in vpMeTracker
129  void printParameters();
130 
131 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
132 
136  void initTracking(const vpImage<unsigned char> &I, const unsigned int n, unsigned *i, unsigned *j);
138 #endif // VISP_BUILD_DEPRECATED_FUNCTIONS
139 
146  inline double get_m00() const { return m00; }
147 
154  inline double get_m10() const { return m10; }
155 
162  inline double get_m01() const { return m01; }
163 
170  inline double get_m11() const { return m11; }
171 
178  inline double get_m20() const { return m20; }
179 
186  inline double get_m02() const { return m02; }
187 
193  inline double get_mu11() const { return mu11; }
194 
200  inline double get_mu02() const { return mu02; }
201 
207  inline double get_mu20() const { return mu20; }
208 
212  inline vpImagePoint getCenter() const { return iPc; }
213 
217  inline double getA() const { return a; }
218 
222  inline double getB() const { return b; }
223 
228  inline double getE() const { return e; }
229 
233  void getEquationParam(double &A, double &B, double &E)
234  {
235  A = a;
236  B = b;
237  E = e;
238  }
239 
243  inline double getSmallestAngle() { return alpha1; }
244 
248  inline double getHighestAngle() { return alpha2; }
249 
259  void setThresholdRobust(const double threshold)
260  {
261  if (threshold < 0) {
262  thresholdWeight = 0;
263  } else if (threshold > 1) {
264  thresholdWeight = 1;
265  } else {
266  thresholdWeight = threshold;
267  }
268  }
269 
270 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
271 public:
272 #else
273 protected:
274 #endif
275 
282  double a;
284  double b;
287  double e;
288 
289 protected:
299  double alpha1;
301  double alpha2;
303  double ce;
305  double se;
307  std::list<double> angle;
309  double m00;
311  double mu11, mu20, mu02;
313  double m10, m01;
315  double m11, m02, m20;
320 
321 private:
322  void computeAngle(const vpImagePoint &pt1, const vpImagePoint &pt);
323  void sample(const vpImage<unsigned char> &image);
324  void reSample(const vpImage<unsigned char> &I);
325  void leastSquare();
326  void updateTheta();
327  void suppressPoints();
328  void seekExtremities(const vpImage<unsigned char> &I);
329  void setExtremities();
330  void getParameters();
331  void computeMoments();
332 
333 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
334 
338  void computeAngle(int ip1, int jp1, int ip2, int jp2);
339  void computeAngle(int ip1, int jp1, double &alpha1, int ip2, int jp2, double &alpha2);
341 #endif // VISP_BUILD_DEPRECATED_FUNCTIONS
342 
343  // Static Function
344 public:
345  static void display(const vpImage<unsigned char> &I, const vpImagePoint &center, const double &A, const double &B,
346  const double &E, const double &smallalpha, const double &highalpha,
347  const vpColor &color = vpColor::green, unsigned int thickness = 1);
348  static void display(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &A, const double &B,
349  const double &E, const double &smallalpha, const double &highalpha,
350  const vpColor &color = vpColor::green, unsigned int thickness = 1);
351 };
352 
353 #endif
double a
is the semiminor axis of the ellipse.
Definition: vpMeEllipse.h:282
double expecteddensity
Expected number of me to track along the ellipse.
Definition: vpMeEllipse.h:319
double get_m00() const
Definition: vpMeEllipse.h:146
double thresholdWeight
Threshold for the robust least square.
Definition: vpMeEllipse.h:317
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
int getExpectedDensity()
Definition: vpMeEllipse.h:116
vpImagePoint iP1
Definition: vpMeEllipse.h:293
double getHighestAngle()
Definition: vpMeEllipse.h:248
double get_m02() const
Definition: vpMeEllipse.h:186
Class that tracks an ellipse moving edges.
Definition: vpMeEllipse.h:106
virtual void sample(const vpImage< unsigned char > &image)=0
Sample pixels at a given interval.
double mu20
Definition: vpMeEllipse.h:311
static const vpColor green
Definition: vpColor.h:183
double getE() const
Definition: vpMeEllipse.h:228
double b
is the semimajor axis of the ellipse.
Definition: vpMeEllipse.h:284
double se
Value of sin(e).
Definition: vpMeEllipse.h:305
double get_m10() const
Definition: vpMeEllipse.h:154
double get_m11() const
Definition: vpMeEllipse.h:170
double m20
Definition: vpMeEllipse.h:315
void display(const vpImage< unsigned char > &I)
Definition: vpMeEllipse.h:125
vpImagePoint iP2
Definition: vpMeEllipse.h:297
vpImagePoint iPc
The coordinates of the ellipse center.
Definition: vpMeEllipse.h:280
double alpha1
The smallest angle.
Definition: vpMeEllipse.h:299
double get_mu02() const
Definition: vpMeEllipse.h:200
void setThresholdRobust(const double threshold)
Definition: vpMeEllipse.h:259
double getB() const
Definition: vpMeEllipse.h:222
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
double get_m20() const
Definition: vpMeEllipse.h:178
double m10
First order raw moments.
Definition: vpMeEllipse.h:313
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:65
vpColVector K
Definition: vpMeEllipse.h:278
double get_mu11() const
Definition: vpMeEllipse.h:193
double m00
Surface.
Definition: vpMeEllipse.h:309
void getEquationParam(double &A, double &B, double &E)
Definition: vpMeEllipse.h:233
std::list< double > angle
Stores the value of the angle for each vpMeSite.
Definition: vpMeEllipse.h:307
double get_mu20() const
Definition: vpMeEllipse.h:207
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
double getSmallestAngle()
Definition: vpMeEllipse.h:243
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:301
double get_m01() const
Definition: vpMeEllipse.h:162
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0
vpImagePoint getCenter() const
Definition: vpMeEllipse.h:212
double getA() const
Definition: vpMeEllipse.h:217
double ce
Value of cos(e).
Definition: vpMeEllipse.h:303