Visual Servoing Platform  version 3.6.1 under development (2025-03-06)
vpMeLine.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 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 VP_ME_LINE_H
40 #define VP_ME_LINE_H
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
50 
152 class VISP_EXPORT vpMeLine : public vpMeTracker
153 {
154 public:
158  vpMeLine();
159 
163  vpMeLine(const vpMeLine &meline);
164 
168  virtual ~vpMeLine() VP_OVERRIDE;
169 
180  void display(const vpImage<unsigned char> &I, const vpColor &color, unsigned int thickness = 1);
181 
192  void display(const vpImage<vpRGBa> &I, const vpColor &color, unsigned int thickness = 1);
193 
201  {
202  vpColVector abc(3);
203  abc[0] = m_a;
204  abc[1] = m_b;
205  abc[2] = m_c;
206  return abc;
207  }
208 
216  void getExtremities(vpImagePoint &ip1, vpImagePoint &ip2) const;
217 
227  inline double getRho() const
228  {
229  return m_rho;
230  }
231 
244  inline vpColVector getRhoTheta() const
245  {
246  vpColVector rho_theta(2);
247  rho_theta[0] = m_rho;
248  rho_theta[1] = m_theta;
249  return rho_theta;
250  }
251 
257  inline double getTheta() const
258  {
259  return m_theta;
260  }
261 
268  void initTracking(const vpImage<unsigned char> &I);
269 
278  void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2);
279 
288  inline void setRhoSignFromIntensity(bool useIntensityForRho)
289  {
290  m_useIntensityForRho = useIntensityForRho;
291  }
292 
298  void track(const vpImage<unsigned char> &I);
299 
313  static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
314  const double &B, const double &C, const vpColor &color = vpColor::green,
315  unsigned int thickness = 1);
316 
330  static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
331  const double &B, const double &C, const vpColor &color = vpColor::green,
332  unsigned int thickness = 1);
333 
348  static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
349  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
350  const vpColor &color = vpColor::green, unsigned int thickness = 1);
351 
366  static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
367  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
368  const vpColor &color = vpColor::green, unsigned int thickness = 1);
369 
381  static bool intersection(const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &iP);
382 
383  static void project(double a, double b, double c, const vpMeSite &P, vpImagePoint &iP);
384 
385 protected:
386  void computeDelta(double &delta, double i1, double j1, double i2, double j2);
387 
393  void computeRhoTheta(const vpImage<unsigned char> &I);
394 
402  void leastSquare(const vpImage<unsigned char> &I);
403 
404  void normalizeAngle(double &delta);
405 
417  unsigned int plugHoles(const vpImage<unsigned char> &I);
418 
429  void reSample(const vpImage<unsigned char> &I);
430 
441  virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false) VP_OVERRIDE;
442 
453  virtual unsigned int seekExtremities(const vpImage<unsigned char> &I);
454 
460  void setExtremities();
461 
465  void updateDelta();
466 
467 private:
468  static void update_indices(double theta, int incr, int i, int j, int &i1, int &i2, int &j1, int &j2);
469 
470 protected:
471  vpMeSite m_PExt[2];
473 
474  double m_rho;
475  double m_theta;
476  double m_delta;
477  double m_delta_1;
478  double m_angle;
479  double m_angle_1;
480  int m_sign;
481 
484  bool m_useIntensityForRho;
485 
486  double m_a;
487  double m_b;
488  double m_c;
489 
490 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
491 public:
496 
508  VP_DEPRECATED inline void computeRhoSignFromIntensity(bool useIntensityForRho)
509  {
510  m_useIntensityForRho = useIntensityForRho;
511  }
512 
517  VP_DEPRECATED inline double getA() const { return m_a; }
518 
523  VP_DEPRECATED inline double getB() const { return m_b; }
524 
529  VP_DEPRECATED inline double getC() const { return m_c; }
530 
535  VP_DEPRECATED void getEquationParam(double &A, double &B, double &C) const
536  {
537  A = m_a;
538  B = m_b;
539  C = m_c;
540  }
541 
545  VP_DEPRECATED static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
546  const double &B, const double &C, const vpColor &color = vpColor::green,
547  unsigned int thickness = 1);
548 
552  VP_DEPRECATED static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
553  const double &B, const double &C, const vpColor &color = vpColor::green,
554  unsigned int thickness = 1);
555 
559  VP_DEPRECATED static void display(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
560  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
561  const vpColor &color = vpColor::green, unsigned int thickness = 1);
562 
566  VP_DEPRECATED static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
567  const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
568  const vpColor &color = vpColor::green, unsigned int thickness = 1);
570 #endif
571 };
572 END_VISP_NAMESPACE
573 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:157
static const vpColor green
Definition: vpColor.h:201
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 line moving edges.
Definition: vpMeLine.h:153
VP_DEPRECATED double getA() const
Definition: vpMeLine.h:517
double getRho() const
Definition: vpMeLine.h:227
VP_DEPRECATED double getB() const
Definition: vpMeLine.h:523
VP_DEPRECATED void getEquationParam(double &A, double &B, double &C) const
Definition: vpMeLine.h:535
double getTheta() const
Definition: vpMeLine.h:257
VP_DEPRECATED double getC() const
Definition: vpMeLine.h:529
VP_DEPRECATED void computeRhoSignFromIntensity(bool useIntensityForRho)
Definition: vpMeLine.h:508
vpColVector getRhoTheta() const
Definition: vpMeLine.h:244
vpColVector get_ABC() const
Definition: vpMeLine.h:200
void setRhoSignFromIntensity(bool useIntensityForRho)
Definition: vpMeLine.h:288
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 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)