Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMeLine.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 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
38
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
50
156class VISP_EXPORT vpMeLine : public vpMeTracker
157{
158public:
162 vpMeLine();
163
167 vpMeLine(const vpMeLine &meline);
168
172 virtual ~vpMeLine() VP_OVERRIDE;
173
177 vpMeLine &operator=(const vpMeLine &meline);
178
189 void display(const vpImage<unsigned char> &I, const vpColor &color, unsigned int thickness = 1);
190
201 void display(const vpImage<vpRGBa> &I, const vpColor &color, unsigned int thickness = 1);
202
210 {
211 vpColVector abc(3);
212 abc[0] = m_a;
213 abc[1] = m_b;
214 abc[2] = m_c;
215 return abc;
216 }
217
225 void getExtremities(vpImagePoint &ip1, vpImagePoint &ip2) const;
226
236 inline double getRho() const
237 {
238 return m_rho;
239 }
240
254 {
255 vpColVector rho_theta(2);
256 rho_theta[0] = m_rho;
257 rho_theta[1] = m_theta;
258 return rho_theta;
259 }
260
266 inline double getTheta() const
267 {
268 return m_theta;
269 }
270
278
287 void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2);
288
294 void track(const vpImage<unsigned char> &I);
295
309 static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
310 const double &B, const double &C, const vpColor &color = vpColor::green,
311 unsigned int thickness = 1);
312
326 static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
327 const double &B, const double &C, const vpColor &color = vpColor::green,
328 unsigned int thickness = 1);
329
344 static void displayLine(const vpImage<unsigned char> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
345 const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
346 const vpColor &color = vpColor::green, unsigned int thickness = 1);
347
362 static void displayLine(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
363 const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
364 const vpColor &color = vpColor::green, unsigned int thickness = 1);
365
377 static bool intersection(const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &iP);
378
379 static void project(double a, double b, double c, const vpMeSite &P, vpImagePoint &iP);
380
381protected:
382 void computeDelta(double &delta, double i1, double j1, double i2, double j2);
383
388 void computeRhoTheta();
389
397 void leastSquare(const vpImage<unsigned char> &I);
398
399 void normalizeAngle(double &delta);
400
412 unsigned int plugHoles(const vpImage<unsigned char> &I);
413
424 void reSample(const vpImage<unsigned char> &I);
425
436 virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false) VP_OVERRIDE;
437
448 virtual unsigned int seekExtremities(const vpImage<unsigned char> &I);
449
455 void setExtremities();
456
460 void updateDelta();
461
462private:
463 static void update_indices(double theta, int incr, int i, int j, int &i1, int &i2, int &j1, int &j2);
464
465protected:
468
469 double m_rho;
470 double m_theta;
471 double m_delta;
472 int m_sign;
473
474 double m_a;
475 double m_b;
476 double m_c;
477
478#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
479public:
484
497 VP_DEPRECATED inline void setRhoSignFromIntensity(bool unused)
498 {
499 (void)unused;
500 }
501
515 VP_DEPRECATED inline void computeRhoSignFromIntensity(bool unused)
516 {
517 (void)unused;
518 }
519
524 VP_DEPRECATED inline double getA() const { return m_a; }
525
530 VP_DEPRECATED inline double getB() const { return m_b; }
531
536 VP_DEPRECATED inline double getC() const { return m_c; }
537
542 VP_DEPRECATED void getEquationParam(double &A, double &B, double &C) const
543 {
544 A = m_a;
545 B = m_b;
546 C = m_c;
547 }
548
552 VP_DEPRECATED static void display(const vpImage<unsigned char> &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<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A,
560 const double &B, const double &C, const vpColor &color = vpColor::green,
561 unsigned int thickness = 1);
562
566 VP_DEPRECATED static void display(const vpImage<unsigned char> &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);
569
573 VP_DEPRECATED static void display(const vpImage<vpRGBa> &I, const vpMeSite &PExt1, const vpMeSite &PExt2,
574 const std::list<vpMeSite> &site_list, const double &A, const double &B, const double &C,
575 const vpColor &color = vpColor::green, unsigned int thickness = 1);
577#endif
578};
579END_VISP_NAMESPACE
580#endif
Implementation of column vector and the associated operations.
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 of the vpImage class member functions.
Definition vpImage.h:131
Class that tracks in an image a line moving edges.
Definition vpMeLine.h:157
VP_DEPRECATED double getA() const
Definition vpMeLine.h:524
double m_theta
theta parameter of the line
Definition vpMeLine.h:470
int m_sign
Sign.
Definition vpMeLine.h:472
VP_DEPRECATED void setRhoSignFromIntensity(bool unused)
Definition vpMeLine.h:497
VP_DEPRECATED void computeRhoSignFromIntensity(bool unused)
Definition vpMeLine.h:515
unsigned int plugHoles(const vpImage< unsigned char > &I)
Definition vpMeLine.cpp:361
double getRho() const
Definition vpMeLine.h:236
void updateDelta()
Definition vpMeLine.cpp:593
VP_DEPRECATED double getB() const
Definition vpMeLine.h:530
void reSample(const vpImage< unsigned char > &I)
Definition vpMeLine.cpp:561
VP_DEPRECATED void getEquationParam(double &A, double &B, double &C) const
Definition vpMeLine.h:542
double m_c
Parameter c of the line equation a*i + b*j + c = 0.
Definition vpMeLine.h:476
double getTheta() const
Definition vpMeLine.h:266
void computeDelta(double &delta, double i1, double j1, double i2, double j2)
double m_delta
Angle in rad between the extremities.
Definition vpMeLine.h:471
VP_DEPRECATED double getC() const
Definition vpMeLine.h:536
double m_rho
rho parameter of the line
Definition vpMeLine.h:469
double m_a
Parameter a of the line equation a*i + b*j + c = 0.
Definition vpMeLine.h:474
void leastSquare(const vpImage< unsigned char > &I)
Definition vpMeLine.cpp:207
double m_b
Parameter b of the line equation a*i + b*j + c = 0.
Definition vpMeLine.h:475
vpColVector getRhoTheta() const
Definition vpMeLine.h:253
vpMeSite m_PExt[2]
Definition vpMeLine.h:466
void normalizeAngle(double &delta)
vpColVector get_ABC() const
Definition vpMeLine.h:209
void setExtremities()
Definition vpMeLine.cpp:355
virtual unsigned int seekExtremities(const vpImage< unsigned char > &I)
Definition vpMeLine.cpp:445
void computeRhoTheta()
Definition vpMeLine.cpp:653
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
Definition vpMeSite.h:75
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)
vpMeTracker & operator=(vpMeTracker &meTracker)
void display(const vpImage< unsigned char > &I)