Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpMeNurbs.h
1 /*
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://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 
41 #ifndef vpMeNurbs_HH
42 #define vpMeNurbs_HH
43 
44 #include <visp3/core/vpMath.h>
45 #include <visp3/core/vpMatrix.h>
46 #include <visp3/me/vpMeTracker.h>
47 #include <visp3/me/vpNurbs.h>
48 
49 #include <iostream>
50 #include <list>
51 #include <math.h>
52 
53 BEGIN_VISP_NAMESPACE
132 class VISP_EXPORT vpMeNurbs : public vpMeTracker
133 {
134 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
135 public:
136 #else
137 private:
138 #endif
140  vpNurbs nurbs;
141 
142 private:
144  double dist;
146  unsigned int nbControlPoints;
149  int beginPtFound;
152  int endPtFound;
155  bool enableCannyDetection;
157  float cannyTh1;
159  float cannyTh2;
160 
161 public:
165  vpMeNurbs();
166 
170  vpMeNurbs(const vpMeNurbs &menurbs);
171 
177  void setNbControlPoints(unsigned int nb_point) { this->nbControlPoints = nb_point; }
178 
185  void setEnableCannyDetection(const bool enable_canny) { this->enableCannyDetection = enable_canny; }
186 
193  void setCannyThreshold(float th1, float th2)
194  {
195  this->cannyTh1 = th1;
196  this->cannyTh2 = th2;
197  }
198 
205  void initTracking(const vpImage<unsigned char> &I);
206 
214  void initTracking(const vpImage<unsigned char> &I, const std::list<vpImagePoint> &ptList);
215 
221  void track(const vpImage<unsigned char> &I);
222 
230  virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false);
231 
242  void reSample(const vpImage<unsigned char> &I);
243 
248  void updateDelta();
249 
257  void seekExtremities(const vpImage<unsigned char> &I);
258 
270  void seekExtremitiesCanny(const vpImage<unsigned char> &I);
271 
278  void suppressPoints();
279 
285  void supressNearPoints();
286 
294  void localReSample(const vpImage<unsigned char> &I);
295 
299  inline vpNurbs getNurbs() const { return nurbs; }
300 
311  void display(const vpImage<unsigned char> &I, const vpColor &color, unsigned int thickness = 1);
312 
313 private:
314  bool computeFreemanChainElement(const vpImage<unsigned char> &I, vpImagePoint &iP, unsigned int &element);
315 
316  bool hasGoodLevel(const vpImage<unsigned char> &I, const vpImagePoint &iP) const;
317 
318  bool isInImage(const vpImage<unsigned char> &I, const vpImagePoint &iP) const;
319 
320  void computeFreemanParameters(unsigned int element, vpImagePoint &diP);
321 
322  bool farFromImageEdge(const vpImage<unsigned char> &I, const vpImagePoint &iP);
323 
324 public:
333  static void display(const vpImage<unsigned char> &I, vpNurbs &n, const vpColor &color = vpColor::green, unsigned int thickness = 1);
334 
343  static void display(const vpImage<vpRGBa> &I, vpNurbs &n, const vpColor &color = vpColor::green, unsigned int thickness = 1);
344 };
345 END_VISP_NAMESPACE
346 #endif
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:157
static const vpColor green
Definition: vpColor.h:220
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
Class that tracks in an image a edge defined by a Nurbs.
Definition: vpMeNurbs.h:133
void setCannyThreshold(float th1, float th2)
Definition: vpMeNurbs.h:193
void setEnableCannyDetection(const bool enable_canny)
Definition: vpMeNurbs.h:185
void setNbControlPoints(unsigned int nb_point)
Definition: vpMeNurbs.h:177
vpNurbs getNurbs() const
Definition: vpMeNurbs.h:299
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:62
void initTracking(const vpImage< unsigned char > &I)
virtual void sample(const vpImage< unsigned char > &image, bool doNotTrack=false)=0
void track(const vpImage< unsigned char > &I)
void display(const vpImage< unsigned char > &I)
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve.
Definition: vpNurbs.h:93