Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMeNurbs.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  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 
43 #ifndef vpMeNurbs_HH
44 #define vpMeNurbs_HH
45 
46 #include <visp3/core/vpMatrix.h>
47 #include <visp3/core/vpMath.h>
48 #include <visp3/me/vpMeTracker.h>
49 #include <visp3/me/vpNurbs.h>
50 
51 #include <math.h>
52 #include <iostream>
53 #include <list>
54 
125 class VISP_EXPORT vpMeNurbs : public vpMeTracker
126 {
127  #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
128  public:
129  #else
130  private:
131  #endif
132  vpNurbs nurbs;
134 
135  private:
137  double dist;
139  unsigned int nbControlPoints;
141  int beginPtFound;
143  int endPtFound;
145  bool enableCannyDetection;
147  double cannyTh1;
149  double cannyTh2;
150 
151  public:
152  vpMeNurbs();
153  vpMeNurbs(const vpMeNurbs &menurbs);
154  virtual ~vpMeNurbs();
155 
161  void setNbControlPoints(const unsigned int nb_point) {this->nbControlPoints = nb_point;}
162 
168  void setEnableCannyDetection(const bool enable_canny) {this->enableCannyDetection =enable_canny;}
169 
176  void setCannyThreshold(const double th1, const double th2)
177  {
178  this->cannyTh1 = th1;
179  this->cannyTh2 = th2;
180  }
181 
182  void initTracking(const vpImage<unsigned char> &I) ;
183  void initTracking(const vpImage<unsigned char> &I,
184  const std::list<vpImagePoint> &ptList) ;
185 
186  void track(const vpImage<unsigned char>& Im);
187 
188  void sample(const vpImage<unsigned char>&image);
189  void reSample(const vpImage<unsigned char> &I) ;
190  void updateDelta();
191  void setExtremities() ;
192  void seekExtremities(const vpImage<unsigned char> &I) ;
193  void seekExtremitiesCanny(const vpImage<unsigned char> &I) ;
194  void suppressPoints() ;
195 
196  void supressNearPoints();
197  void localReSample(const vpImage<unsigned char> &I);
198 
202  inline vpNurbs getNurbs() const {return nurbs; }
203 
204  void display(const vpImage<unsigned char>& I, vpColor col) ;
205 
206  private:
207  bool computeFreemanChainElement(const vpImage<unsigned char> &I,
208  vpImagePoint &iP,
209  unsigned int &element);
210 
211  bool hasGoodLevel(const vpImage<unsigned char>& I,
212  const vpImagePoint& iP) const;
213 
214  bool isInImage(const vpImage<unsigned char>& I, const vpImagePoint &iP) const;
215 
216  void computeFreemanParameters( unsigned int element, vpImagePoint &diP);
217 
218  bool farFromImageEdge(const vpImage<unsigned char>& I, const vpImagePoint& iP);
219 
220 public:
221  static void display(const vpImage<unsigned char>& I, vpNurbs &n, vpColor color = vpColor::green);
222  static void display(const vpImage<vpRGBa>& I, vpNurbs &n, vpColor color = vpColor::green);
223 };
224 
225 #endif
void setEnableCannyDetection(const bool enable_canny)
Definition: vpMeNurbs.h:168
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
vpNurbs getNurbs() const
Definition: vpMeNurbs.h:202
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:125
static const vpColor green
Definition: vpColor.h:166
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 setNbControlPoints(const unsigned int nb_point)
Definition: vpMeNurbs.h:161
void setCannyThreshold(const double th1, const double th2)
Definition: vpMeNurbs.h:176
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
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve...
Definition: vpNurbs.h:85
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0