ViSP  2.10.0
vpMbtMeEllipse.h
1 /****************************************************************************
2  *
3  * $Id: vpMbtMeEllipse.h 4705 2014-03-27 16:24:35Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 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 vpMbtMeEllipse_HH
48 #define vpMbtMeEllipse_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 
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
64 
101 /*
102  The code below shows how to use this class.
103 \code
104 #include <visp/vpConfig.h>
105 #include <visp/vpImage.h>
106 #include <visp/vpMbtMeEllipse.h>
107 #include <visp/vpImagePoint.h>
108 
109 int main()
110 {
111  vpImage<unsigned char> I;
112 
113  // I is the image containing the ellipse to track
114 
115  // Set the moving-edges tracker parameters
116  vpMe me;
117  me.setRange(25);
118  me.setPointsToTrack(20);
119  me.setThreshold(15000);
120  me.setSampleStep(10);
121 
122  // Initialize the moving-edges ellipse tracker parameters
123  vpMbtMeEllipse ellipse;
124  ellipse.setMe(&me);
125 
126  // Initialize the tracking. You have to click on five different points belonging to the ellipse.
127  ellipse.initTracking(I);
128 
129  while ( 1 )
130  {
131  // ... Here the code to read or grab the next image.
132 
133  // Track the ellipse.
134  ellipse.track(I);
135  }
136  return 0;
137 }
138 \endcode
139 
140  \note It is possible to display the ellipse as an overlay. For that you
141  must use the display function of the class vpMbtMeEllipse.
142 */
143 
144 class VISP_EXPORT vpMbtMeEllipse : public vpMeTracker
145 {
146 public:
147  vpMbtMeEllipse() ;
148  vpMbtMeEllipse(const vpMbtMeEllipse &meellipse) ;
149  virtual ~vpMbtMeEllipse() ;
150 
151 
152  void display(const vpImage<unsigned char>&I, vpColor col) ;
153  void display(const vpImage<unsigned char>& I) {vpMeTracker::display(I);} //Shouldn't be here since it's already in vpMeTracker
157  int getExpectedDensity() {return (int)expecteddensity;};
158 
164  inline double get_mu11() const {return mu11;}
165 
171  inline double get_mu02() const {return mu02;}
172 
178  inline double get_mu20() const {return mu20;}
179 
183  inline vpImagePoint getCenter() const {return iPc; }
184 
188  inline double getA() const {return a; }
189 
193  inline double getB() const {return b; }
194 
198  inline double getE() const {return e; }
199 
203  void getEquationParam(double &A, double &B, double &E) { A = a; B = b; E = e; }
204 
205  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ic,
206  double mu20_p, double mu11_p, double mu02_p) ;
207 
208  void track(const vpImage<unsigned char>& Im);
209 
210  void updateParameters(const vpImage<unsigned char> &I, const vpImagePoint &ic,
211  double mu20_p, double mu11_p, double mu02_p);
212 
213 
214 protected:
216  vpImagePoint iPc;
218  double a;
220  double b;
222  double e;
223 
224 protected:
226  double ce;
228  double se;
229 
231  double mu11,mu20, mu02;
233  double thresholdWeight;
235  double expecteddensity;
236 
237 private:
238  void sample(const vpImage<unsigned char>&image);
239  void reSample(const vpImage<unsigned char> &I) ;
240  void updateTheta();
241  void suppressPoints() ;
242 };
243 
244 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
245 #endif
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
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:71
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:93
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0