ViSP  2.9.0
vpMeNurbs.h
1 /****************************************************************************
2  *
3  * $Id: vpMeNurbs.h 4649 2014-02-07 14:57:11Z 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  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 
47 #ifndef vpMeNurbs_HH
48 #define vpMeNurbs_HH
49 
50 #include <visp/vpMatrix.h>
51 #include <visp/vpMath.h>
52 #include <visp/vpMeTracker.h>
53 #include <visp/vpNurbs.h>
54 
55 #include <math.h>
56 #include <iostream>
57 #include <list>
58 
129 class VISP_EXPORT vpMeNurbs : public vpMeTracker
130 {
131  #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
132  public:
133  #else
134  private:
135  #endif
136  vpNurbs nurbs;
138 
139  private:
141  double dist;
143  unsigned int nbControlPoints;
145  int beginPtFound;
147  int endPtFound;
149  bool enableCannyDetection;
151  double cannyTh1;
153  double cannyTh2;
154 
155  public:
156  vpMeNurbs();
157  vpMeNurbs(const vpMeNurbs &menurbs);
158  virtual ~vpMeNurbs();
159 
165  void setNbControlPoints(const unsigned int nb_point) {this->nbControlPoints = nb_point;}
166 
172  void setEnableCannyDetection(const bool enable_canny) {this->enableCannyDetection =enable_canny;}
173 
180  void setCannyThreshold(const double th1, const double th2)
181  {
182  this->cannyTh1 = th1;
183  this->cannyTh2 = th2;
184  }
185 
186  void initTracking(const vpImage<unsigned char> &I) ;
187  void initTracking(const vpImage<unsigned char> &I,
188  const std::list<vpImagePoint> &ptList) ;
189 
190  void track(const vpImage<unsigned char>& Im);
191 
192  void sample(const vpImage<unsigned char>&image);
193  void reSample(const vpImage<unsigned char> &I) ;
194  void updateDelta();
195  void setExtremities() ;
196  void seekExtremities(const vpImage<unsigned char> &I) ;
197  void seekExtremitiesCanny(const vpImage<unsigned char> &I) ;
198  void suppressPoints() ;
199 
200  void supressNearPoints();
201  void localReSample(const vpImage<unsigned char> &I);
202 
206  inline vpNurbs getNurbs() const {return nurbs; }
207 
208  void display(const vpImage<unsigned char>& I, vpColor col) ;
209 
210 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
211 
214  vp_deprecated void initTracking(const vpImage<unsigned char> &I,
215  vpList<vpImagePoint> &ptList) ;
216 #endif
217 
218  private:
219  bool computeFreemanChainElement(const vpImage<unsigned char> &I,
220  vpImagePoint &iP,
221  unsigned int &element);
222 
223  bool hasGoodLevel(const vpImage<unsigned char>& I,
224  const vpImagePoint& iP) const;
225 
226  bool isInImage(const vpImage<unsigned char>& I, const vpImagePoint &iP) const;
227 
228  void computeFreemanParameters( unsigned int element, vpImagePoint &diP);
229 
230  bool farFromImageEdge(const vpImage<unsigned char>& I, const vpImagePoint& iP);
231 
232 public:
233  static void display(const vpImage<unsigned char>& I, vpNurbs &n, vpColor color = vpColor::green);
234  static void display(const vpImage<vpRGBa>& I, vpNurbs &n, vpColor color = vpColor::green);
235 };
236 
237 #endif
void setEnableCannyDetection(const bool enable_canny)
Definition: vpMeNurbs.h:172
Provide simple list management.
Definition: vpList.h:113
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
vpNurbs getNurbs() const
Definition: vpMeNurbs.h:206
virtual void sample(const vpImage< unsigned char > &image)=0
Sample pixels at a given interval.
Class that tracks in an image a edge defined by a Nurbs.
Definition: vpMeNurbs.h:129
static const vpColor green
Definition: vpColor.h:170
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 setNbControlPoints(const unsigned int nb_point)
Definition: vpMeNurbs.h:165
void setCannyThreshold(const double th1, const double th2)
Definition: vpMeNurbs.h:180
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
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve...
Definition: vpNurbs.h:89
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0