Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMbtMeEllipse.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 vpMbtMeEllipse_HH
44 #define vpMbtMeEllipse_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 
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 
97 /*
98  The code below shows how to use this class.
99 \code
100 #include <visp3/core/vpConfig.h>
101 #include <visp3/core/vpImage.h>
102 #include <visp3/mbt/vpMbtMeEllipse.h>
103 #include <visp3/core/vpImagePoint.h>
104 
105 int main()
106 {
107  vpImage<unsigned char> I;
108 
109  // I is the image containing the ellipse to track
110 
111  // Set the moving-edges tracker parameters
112  vpMe me;
113  me.setRange(25);
114  me.setPointsToTrack(20);
115  me.setThreshold(15000);
116  me.setSampleStep(10);
117 
118  // Initialize the moving-edges ellipse tracker parameters
119  vpMbtMeEllipse ellipse;
120  ellipse.setMe(&me);
121 
122  // Initialize the tracking. You have to click on five different points belonging to the ellipse.
123  ellipse.initTracking(I);
124 
125  while ( 1 )
126  {
127  // ... Here the code to read or grab the next image.
128 
129  // Track the ellipse.
130  ellipse.track(I);
131  }
132  return 0;
133 }
134 \endcode
135 
136  \note It is possible to display the ellipse as an overlay. For that you
137  must use the display function of the class vpMbtMeEllipse.
138 */
139 
140 class VISP_EXPORT vpMbtMeEllipse : public vpMeTracker
141 {
142 public:
143  vpMbtMeEllipse() ;
144  vpMbtMeEllipse(const vpMbtMeEllipse &meellipse) ;
145  virtual ~vpMbtMeEllipse() ;
146 
147  void computeProjectionError(const vpImage<unsigned char>& _I, double &_sumErrorRad, unsigned int &_nbFeatures);
148 
149  void display(const vpImage<unsigned char>&I, vpColor col) ;
150  void display(const vpImage<unsigned char>& I) {vpMeTracker::display(I);} //Shouldn't be here since it's already in vpMeTracker
154  int getExpectedDensity() {return (int)expecteddensity;};
155 
161  inline double get_mu11() const {return mu11;}
162 
168  inline double get_mu02() const {return mu02;}
169 
175  inline double get_mu20() const {return mu20;}
176 
180  inline vpImagePoint getCenter() const {return iPc; }
181 
185  inline double getA() const {return a; }
186 
190  inline double getB() const {return b; }
191 
195  inline double getE() const {return e; }
196 
200  void getEquationParam(double &A, double &B, double &E) { A = a; B = b; E = e; }
201 
202  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ic,
203  double mu20_p, double mu11_p, double mu02_p) ;
204 
205  void track(const vpImage<unsigned char>& Im);
206 
207  void updateParameters(const vpImage<unsigned char> &I, const vpImagePoint &ic,
208  double mu20_p, double mu11_p, double mu02_p);
209 
210 
211 protected:
213  vpImagePoint iPc;
215  double a;
217  double b;
219  double e;
220 
221 protected:
223  double ce;
225  double se;
226 
228  double mu11,mu20, mu02;
230  double thresholdWeight;
232  double expecteddensity;
233 
234 private:
235  void sample(const vpImage<unsigned char>&image);
236  void reSample(const vpImage<unsigned char> &I) ;
237  void updateTheta();
238  void suppressPoints() ;
239 };
240 
241 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
242 #endif
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
virtual void sample(const vpImage< unsigned char > &image)=0
Sample pixels at a given interval.
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:64
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
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0