Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpMeNurbs.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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  * Nicolas Melchior
36  *
37  *****************************************************************************/
38 
45 #ifndef vpMeNurbs_HH
46 #define vpMeNurbs_HH
47 
48 #include <visp3/core/vpMath.h>
49 #include <visp3/core/vpMatrix.h>
50 #include <visp3/me/vpMeTracker.h>
51 #include <visp3/me/vpNurbs.h>
52 
53 #include <iostream>
54 #include <list>
55 #include <math.h>
56 
130 class VISP_EXPORT vpMeNurbs : public vpMeTracker
131 {
132 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
133 public:
134 #else
135 private:
136 #endif
137  vpNurbs nurbs;
139 
140 private:
142  double dist;
144  unsigned int nbControlPoints;
147  int beginPtFound;
150  int endPtFound;
153  bool enableCannyDetection;
155  double cannyTh1;
157  double cannyTh2;
158 
159 public:
160  vpMeNurbs();
161  vpMeNurbs(const vpMeNurbs &menurbs);
162  virtual ~vpMeNurbs();
163 
169  void setNbControlPoints(const unsigned int nb_point) { this->nbControlPoints = nb_point; }
170 
177  void setEnableCannyDetection(const bool enable_canny) { this->enableCannyDetection = enable_canny; }
178 
185  void setCannyThreshold(const double th1, const double th2)
186  {
187  this->cannyTh1 = th1;
188  this->cannyTh2 = th2;
189  }
190 
191  void initTracking(const vpImage<unsigned char> &I);
192  void initTracking(const vpImage<unsigned char> &I, const std::list<vpImagePoint> &ptList);
193 
194  void track(const vpImage<unsigned char> &I);
195 
196  virtual void sample(const vpImage<unsigned char> &image, const bool doNotTrack=false);
197  void reSample(const vpImage<unsigned char> &I);
198  void updateDelta();
199  void setExtremities();
200  void seekExtremities(const vpImage<unsigned char> &I);
201  void seekExtremitiesCanny(const vpImage<unsigned char> &I);
202  void suppressPoints();
203 
204  void supressNearPoints();
205  void localReSample(const vpImage<unsigned char> &I);
206 
210  inline vpNurbs getNurbs() const { return nurbs; }
211 
212  void display(const vpImage<unsigned char> &I, vpColor col);
213 
214 private:
215  bool computeFreemanChainElement(const vpImage<unsigned char> &I, vpImagePoint &iP, unsigned int &element);
216 
217  bool hasGoodLevel(const vpImage<unsigned char> &I, const vpImagePoint &iP) const;
218 
219  bool isInImage(const vpImage<unsigned char> &I, const vpImagePoint &iP) const;
220 
221  void computeFreemanParameters(unsigned int element, vpImagePoint &diP);
222 
223  bool farFromImageEdge(const vpImage<unsigned char> &I, const vpImagePoint &iP);
224 
225 public:
226  static void display(const vpImage<unsigned char> &I, vpNurbs &n, vpColor color = vpColor::green);
227  static void display(const vpImage<vpRGBa> &I, vpNurbs &n, vpColor color = vpColor::green);
228 };
229 
230 #endif
void setEnableCannyDetection(const bool enable_canny)
Definition: vpMeNurbs.h:177
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
vpNurbs getNurbs() const
Definition: vpMeNurbs.h:210
Class that tracks in an image a edge defined by a Nurbs.
Definition: vpMeNurbs.h:130
static const vpColor green
Definition: vpColor.h:183
virtual void sample(const vpImage< unsigned char > &image, const bool doNotTrack=false)=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:65
void setNbControlPoints(const unsigned int nb_point)
Definition: vpMeNurbs.h:169
void setCannyThreshold(const double th1, const double th2)
Definition: vpMeNurbs.h:185
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:97
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0