Visual Servoing Platform  version 3.6.1 under development (2024-04-20)
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 
127 class VISP_EXPORT vpMeNurbs : public vpMeTracker
128 {
129 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
130 public:
131 #else
132 private:
133 #endif
136 
137 private:
139  double dist;
141  unsigned int nbControlPoints;
144  int beginPtFound;
147  int endPtFound;
150  bool enableCannyDetection;
152  float cannyTh1;
154  float cannyTh2;
155 
156 public:
160  vpMeNurbs();
161 
165  vpMeNurbs(const vpMeNurbs &menurbs);
166 
172  void setNbControlPoints(unsigned int nb_point) { this->nbControlPoints = nb_point; }
173 
180  void setEnableCannyDetection(const bool enable_canny) { this->enableCannyDetection = enable_canny; }
181 
188  void setCannyThreshold(float th1, float th2)
189  {
190  this->cannyTh1 = th1;
191  this->cannyTh2 = th2;
192  }
193 
200  void initTracking(const vpImage<unsigned char> &I);
201 
209  void initTracking(const vpImage<unsigned char> &I, const std::list<vpImagePoint> &ptList);
210 
216  void track(const vpImage<unsigned char> &I);
217 
225  virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false);
226 
237  void reSample(const vpImage<unsigned char> &I);
238 
243  void updateDelta();
244 
252  void seekExtremities(const vpImage<unsigned char> &I);
253 
265  void seekExtremitiesCanny(const vpImage<unsigned char> &I);
266 
273  void suppressPoints();
274 
280  void supressNearPoints();
281 
289  void localReSample(const vpImage<unsigned char> &I);
290 
294  inline vpNurbs getNurbs() const { return nurbs; }
295 
306  void display(const vpImage<unsigned char> &I, const vpColor &color, unsigned int thickness = 1);
307 
308 private:
309  bool computeFreemanChainElement(const vpImage<unsigned char> &I, vpImagePoint &iP, unsigned int &element);
310 
311  bool hasGoodLevel(const vpImage<unsigned char> &I, const vpImagePoint &iP) const;
312 
313  bool isInImage(const vpImage<unsigned char> &I, const vpImagePoint &iP) const;
314 
315  void computeFreemanParameters(unsigned int element, vpImagePoint &diP);
316 
317  bool farFromImageEdge(const vpImage<unsigned char> &I, const vpImagePoint &iP);
318 
319 public:
328  static void display(const vpImage<unsigned char> &I, vpNurbs &n, const vpColor &color = vpColor::green, unsigned int thickness = 1);
329 
338  static void display(const vpImage<vpRGBa> &I, vpNurbs &n, const vpColor &color = vpColor::green, unsigned int thickness = 1);
339 };
340 
341 #endif
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:152
static const vpColor green
Definition: vpColor.h:214
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:128
void setCannyThreshold(float th1, float th2)
Definition: vpMeNurbs.h:188
vpNurbs nurbs
The Nurbs which represents the tracked edge.
Definition: vpMeNurbs.h:135
void setEnableCannyDetection(const bool enable_canny)
Definition: vpMeNurbs.h:180
void setNbControlPoints(unsigned int nb_point)
Definition: vpMeNurbs.h:172
vpNurbs getNurbs() const
Definition: vpMeNurbs.h:294
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:60
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:92