Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
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 
49 BEGIN_VISP_NAMESPACE
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 m_PExt[2];
158 
159  double m_rho;
160  double m_theta;
161  double m_delta;
162  double m_delta_1;
163  double m_angle;
164  double m_angle_1;
165  int m_sign;
166 
170 
171  double m_a;
172  double m_b;
173  double m_c;
174 
175 public:
179  vpMeLine();
180 
184  vpMeLine(const vpMeLine &meline);
185 
189  virtual ~vpMeLine() VP_OVERRIDE;
190 
202  void display(const vpImage<unsigned char> &I, const vpColor &color, unsigned int thickness = 1);
203 
209  void track(const vpImage<unsigned char> &I);
210 
221  virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false) VP_OVERRIDE;
222 
233  void reSample(const vpImage<unsigned char> &I);
234 
240  void leastSquare();
241 
245  void updateDelta();
246 
250  void setExtremities();
251 
262  void seekExtremities(const vpImage<unsigned char> &I);
263 
267  void suppressPoints();
268 
275  void initTracking(const vpImage<unsigned char> &I);
276 
285  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2);
286 
292  void computeRhoTheta(const vpImage<unsigned char> &I);
293 
302  double getRho() const;
303 
307  double getTheta() const;
308 
315  void getExtremities(vpImagePoint &ip1, vpImagePoint &ip2);
316 
320  void getEquationParam(double &A, double &B, double &C)
321  {
322  A = m_a;
323  B = m_b;
324  C = m_c;
325  }
326 
330  inline double getA() const { return m_a; }
331 
335  inline double getB() const { return m_b; }
336 
340  inline double getC() const { return m_c; }
341 
353  static bool intersection(const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &ip);
354 
364  inline void computeRhoSignFromIntensity(bool useIntensityForRho) { m_useIntensityForRho = useIntensityForRho; }
365 
379  static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
380  const double &B, const double &C, const vpColor &color = vpColor::green,
381  unsigned int thickness = 1);
382 
396  static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
397  const double &B, const double &C, const vpColor &color = vpColor::green,
398  unsigned int thickness = 1);
399 
414  static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
415  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
416  const vpColor &color = vpColor::green, unsigned int thickness = 1);
417 
432  static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
433  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
434  const vpColor &color = vpColor::green, unsigned int thickness = 1);
435 
436 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
440  VP_DEPRECATED static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
441  const double &B, const double &C, const vpColor &color = vpColor::green,
442  unsigned int thickness = 1);
443 
447  VP_DEPRECATED static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
448  const double &B, const double &C, const vpColor &color = vpColor::green,
449  unsigned int thickness = 1);
450 
454  VP_DEPRECATED static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
455  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
456  const vpColor &color = vpColor::green, unsigned int thickness = 1);
457 
461  VP_DEPRECATED static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
462  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
463  const vpColor &color = vpColor::green, unsigned int thickness = 1);
464 #endif
465 };
466 END_VISP_NAMESPACE
467 #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
Definition of the vpImage class member functions.
Definition: vpImage.h:131
Class that tracks in an image a line moving edges.
Definition: vpMeLine.h:152
double m_angle
Angle in deg between the extremities.
Definition: vpMeLine.h:163
double m_angle_1
Angle in deg between the extremities.
Definition: vpMeLine.h:164
double m_theta
theta parameter of the line
Definition: vpMeLine.h:160
int m_sign
Sign.
Definition: vpMeLine.h:165
double getA() const
Definition: vpMeLine.h:330
double m_delta_1
Angle in rad between the extremities.
Definition: vpMeLine.h:162
double getB() const
Definition: vpMeLine.h:335
double m_c
Parameter c of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:173
bool m_useIntensityForRho
Definition: vpMeLine.h:169
double m_delta
Angle in rad between the extremities.
Definition: vpMeLine.h:161
double m_rho
rho parameter of the line
Definition: vpMeLine.h:159
void computeRhoSignFromIntensity(bool useIntensityForRho)
Definition: vpMeLine.h:364
double m_a
Parameter a of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:171
double m_b
Parameter b of the line equation a*i + b*j + c = 0.
Definition: vpMeLine.h:172
double getC() const
Definition: vpMeLine.h:340
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
Definition: vpMeSite.h:68
Contains abstract elements for a Distance to Feature type feature.
Definition: vpMeTracker.h:62
void display(const vpImage< unsigned char > &I)