Visual Servoing Platform  version 3.6.1 under development (2024-04-25)
vpMeLine.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 https://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 
39 #ifndef vpMeLine_HH
40 #define vpMeLine_HH
41 
42 #include <visp3/core/vpMath.h>
43 #include <visp3/core/vpMatrix.h>
44 #include <visp3/me/vpMeTracker.h>
45 
46 #include <iostream>
47 #include <math.h>
48 
146 class VISP_EXPORT vpMeLine : public vpMeTracker
147 {
148 private:
149  static void update_indices(double theta, int incr, int i, int j, int &i1, int &i2, int &j1, int &j2);
150 
151 protected:
152  vpMeSite m_PExt[2];
153 
154  double m_rho;
155  double m_theta;
156  double m_delta;
157  double m_delta_1;
158  double m_angle;
159  double m_angle_1;
160  int m_sign;
161 
165 
166  double m_a;
167  double m_b;
168  double m_c;
169 
170 public:
174  vpMeLine();
175 
179  vpMeLine(const vpMeLine &meline);
180 
184  virtual ~vpMeLine() vp_override;
185 
197  void display(const vpImage<unsigned char> &I, const vpColor &color, unsigned int thickness = 1);
198 
204  void track(const vpImage<unsigned char> &I);
205 
216  virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false) vp_override;
217 
228  void reSample(const vpImage<unsigned char> &I);
229 
235  void leastSquare();
236 
240  void updateDelta();
241 
245  void setExtremities();
246 
257  void seekExtremities(const vpImage<unsigned char> &I);
258 
262  void suppressPoints();
263 
270  void initTracking(const vpImage<unsigned char> &I);
271 
280  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2);
281 
287  void computeRhoTheta(const vpImage<unsigned char> &I);
288 
297  double getRho() const;
298 
302  double getTheta() const;
303 
310  void getExtremities(vpImagePoint &ip1, vpImagePoint &ip2);
311 
315  void getEquationParam(double &A, double &B, double &C)
316  {
317  A = m_a;
318  B = m_b;
319  C = m_c;
320  }
321 
325  inline double getA() const { return m_a; }
326 
330  inline double getB() const { return m_b; }
331 
335  inline double getC() const { return m_c; }
336 
348  static bool intersection(const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &ip);
349 
359  inline void computeRhoSignFromIntensity(bool useIntensityForRho) { m_useIntensityForRho = useIntensityForRho; }
360 
374  static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
375  const double &B, const double &C, const vpColor &color = vpColor::green,
376  unsigned int thickness = 1);
377 
391  static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
392  const double &B, const double &C, const vpColor &color = vpColor::green,
393  unsigned int thickness = 1);
394 
409  static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
410  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
411  const vpColor &color = vpColor::green, unsigned int thickness = 1);
412 
427  static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
428  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
429  const vpColor &color = vpColor::green, unsigned int thickness = 1);
430 
431 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
435  vp_deprecated static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
436  const double &B, const double &C, const vpColor &color = vpColor::green,
437  unsigned int thickness = 1);
438 
442  vp_deprecated static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
443  const double &B, const double &C, const vpColor &color = vpColor::green,
444  unsigned int thickness = 1);
445 
449  vp_deprecated static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
450  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
451  const vpColor &color = vpColor::green, unsigned int thickness = 1);
452 
456  vp_deprecated static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
457  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
458  const vpColor &color = vpColor::green, unsigned int thickness = 1);
459 #endif
460 };
461 
462 #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
Definition of the vpImage class member functions.
Definition: vpImage.h:69
Class that tracks in an image a line moving edges.
Definition: vpMeLine.h:147
double m_angle
Angle in deg between the extremities.
Definition: vpMeLine.h:158
double m_angle_1
Angle in deg between the extremities.
Definition: vpMeLine.h:159
double m_theta
theta parameter of the line
Definition: vpMeLine.h:155
int m_sign
Sign.
Definition: vpMeLine.h:160
double getA() const
Definition: vpMeLine.h:325
double m_delta_1
Angle in rad between the extremities.
Definition: vpMeLine.h:157
double getB() const
Definition: vpMeLine.h:330
double m_c
Parameter c of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:168
bool m_useIntensityForRho
Definition: vpMeLine.h:164
double m_delta
Angle in rad between the extremities.
Definition: vpMeLine.h:156
double m_rho
rho parameter of the line
Definition: vpMeLine.h:154
void computeRhoSignFromIntensity(bool useIntensityForRho)
Definition: vpMeLine.h:359
double m_a
Parameter a of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:166
double m_b
Parameter b of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:167
double getC() const
Definition: vpMeLine.h:335
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
Definition: vpMeSite.h:65
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:60
void display(const vpImage< unsigned char > &I)