Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpMeLine.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  * Eric Marchand
36  *
37  *****************************************************************************/
38 
44 #ifndef vpMeLine_HH
45 #define vpMeLine_HH
46 
47 #include <visp3/core/vpMath.h>
48 #include <visp3/core/vpMatrix.h>
49 #include <visp3/me/vpMeTracker.h>
50 
51 #include <iostream>
52 #include <math.h>
53 
151 class VISP_EXPORT vpMeLine : public vpMeTracker
152 {
153 private:
154  static void update_indices(double theta, int incr, int i, int j, int &i1, int &i2, int &j1, int &j2);
155 
156 protected:
157  vpMeSite PExt[2];
158 
159  double rho, theta;
160  double delta, delta_1;
161  double angle, angle_1;
162  int sign;
163 
167 
168 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
169 public:
170 #else
171 protected:
172 #endif
173 
174  double a;
175  double b;
176  double c;
177 
178 public:
179  vpMeLine();
180  vpMeLine(const vpMeLine &meline);
181  virtual ~vpMeLine();
182 
183  void display(const vpImage<unsigned char> &I, vpColor col);
184 
185  void track(const vpImage<unsigned char> &Im);
186 
187  virtual void sample(const vpImage<unsigned char> &image, bool doNotTrack=false);
188  void reSample(const vpImage<unsigned char> &I);
189  void leastSquare();
190  void updateDelta();
191  void setExtremities();
192  void seekExtremities(const vpImage<unsigned char> &I);
193  void suppressPoints();
194 
195  void initTracking(const vpImage<unsigned char> &I);
196  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2);
197 
198  void computeRhoTheta(const vpImage<unsigned char> &I);
199  double getRho() const;
200  double getTheta() const;
201  void getExtremities(vpImagePoint &ip1, vpImagePoint &ip2);
202 
206  void getEquationParam(double &A, double &B, double &C)
207  {
208  A = a;
209  B = b;
210  C = c;
211  }
212 
216  inline double getA() const { return a; }
217 
221  inline double getB() const { return b; }
222 
226  inline double getC() const { return c; }
227 
228  static bool intersection(const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &ip);
229 
239  inline void computeRhoSignFromIntensity(bool useIntensityForRho) { _useIntensityForRho = useIntensityForRho; }
240 
241  // Static Functions
242 public:
243  static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
244  const double &B, const double &C, const vpColor &color = vpColor::green,
245  unsigned int thickness = 1);
246  static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
247  const double &B, const double &C, const vpColor &color = vpColor::green,
248  unsigned int thickness = 1);
249 
250  static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
251  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
252  const vpColor &color = vpColor::green, unsigned int thickness = 1);
253  static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
254  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
255  const vpColor &color = vpColor::green, unsigned int thickness = 1);
256 };
257 
258 #endif
double getA() const
Definition: vpMeLine.h:216
double c
Parameter c of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:176
void computeRhoSignFromIntensity(bool useIntensityForRho)
Definition: vpMeLine.h:239
Performs search in a given direction(normal) for a given distance(pixels) for a given &#39;site&#39;...
Definition: vpMeSite.h:71
Class to define colors available for display functionnalities.
Definition: vpColor.h:119
bool _useIntensityForRho
Definition: vpMeLine.h:166
static const vpColor green
Definition: vpColor.h:182
double getB() const
Definition: vpMeLine.h:221
double theta
Definition: vpMeLine.h:159
Class that tracks in an image a line moving edges.
Definition: vpMeLine.h:151
double delta_1
Definition: vpMeLine.h:160
void track(const vpImage< unsigned char > &I)
Track sampled pixels.
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:65
virtual void sample(const vpImage< unsigned char > &image, bool doNotTrack=false)=0
Sample pixels at a given interval.
double a
Parameter a of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:174
double b
Parameter b of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:175
int sign
Definition: vpMeLine.h:162
void initTracking(const vpImage< unsigned char > &I)
double angle_1
Definition: vpMeLine.h:161
void getEquationParam(double &A, double &B, double &C)
Definition: vpMeLine.h:206
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
double getC() const
Definition: vpMeLine.h:226
virtual void display(const vpImage< unsigned char > &I, vpColor col)=0