Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpMeEllipse.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
36#ifndef _vpMeEllipse_h_
37#define _vpMeEllipse_h_
38
39#include <visp3/core/vpColVector.h>
40#include <visp3/core/vpMatrix.h>
41
42#include <visp3/core/vpImagePoint.h>
43#include <visp3/me/vpMeSite.h>
44#include <visp3/me/vpMeTracker.h>
45
46#include <visp3/core/vpColor.h>
47#include <visp3/core/vpImage.h>
48
49#include <list>
50#include <math.h>
51
89class VISP_EXPORT vpMeEllipse : public vpMeTracker
90{
91public:
99 vpMeEllipse(const vpMeEllipse &me_ellipse);
103 virtual ~vpMeEllipse();
114 void display(const vpImage<unsigned char> &I, const vpColor &col, unsigned int thickness = 1);
115
125 inline vpColVector get_nij() const
126 {
127 vpColVector nij(3);
128 nij[0] = m_n20;
129 nij[1] = m_n11;
130 nij[2] = m_n02;
131
132 return nij;
133 }
134
144 inline vpColVector get_ABE() const
145 {
146 vpColVector ABE(3);
147 ABE[0] = a;
148 ABE[1] = b;
149 ABE[2] = e;
150
151 return ABE;
152 }
153
162 inline double getArea() const { return m00; }
163
169 inline vpImagePoint getCenter() const { return iPc; }
170
174 unsigned int getExpectedDensity() const { return m_expectedDensity; }
175
179 unsigned int getNumberOfGoodPoints() const { return m_numberOfGoodPoints; }
180
187 inline vpImagePoint getFirstEndpoint() const { return iP1; }
188
195 inline double getHighestAngle() const { return m_alphamax; }
196
203 inline vpImagePoint getSecondEndpoint() const { return iP2; }
204
211 inline double getSmallestAngle() const { return m_alphamin; }
212
226 void initTracking(const vpImage<unsigned char> &I, bool trackCircle = false, bool trackArc = false);
227
245 void initTracking(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &iP, bool trackCircle = false,
246 bool trackArc = false);
247
262 void initTracking(const vpImage<unsigned char> &I, const vpColVector &param, vpImagePoint *pt1 = NULL,
263 const vpImagePoint *pt2 = NULL, bool trackCircle = false);
264
269 void printParameters() const;
270
274 void setEndpoints(const vpImagePoint &pt1, const vpImagePoint &pt2)
275 {
276 iP1 = pt1;
277 iP2 = pt2;
278 }
279
289 void setThresholdRobust(double threshold)
290 {
291 if (threshold < 0) {
292 thresholdWeight = 0;
293 }
294 else if (threshold > 1) {
295 thresholdWeight = 1;
296 }
297 else {
298 thresholdWeight = threshold;
299 }
300 }
301
306 void track(const vpImage<unsigned char> &I);
307
308#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
319 vp_deprecated inline double getA() const { return a; }
320
327 vp_deprecated inline double getB() const { return b; }
328
336 vp_deprecated inline double getE() const { return e; }
337
348 vp_deprecated inline double get_m00() const { return m00; }
349
356 vp_deprecated inline double get_m10() const { return m10; }
357
364 vp_deprecated inline double get_m01() const { return m01; }
365
372 vp_deprecated inline double get_m11() const { return m11; }
373
380 vp_deprecated inline double get_m20() const { return m20; }
381
388 vp_deprecated inline double get_m02() const { return m02; }
389
395 vp_deprecated inline double get_mu11() const { return mu11; }
396
402 vp_deprecated inline double get_mu02() const { return mu02; }
403
409 vp_deprecated inline double get_mu20() const { return mu20; }
414 vp_deprecated void getEquationParam(double &A, double &B, double &E)
415 {
416 A = a;
417 B = b;
418 E = e;
419 }
420 vp_deprecated void initTracking(const vpImage<unsigned char> &I, const vpImagePoint &center_p, double a_p, double b_p,
421 double e_p, double low_alpha, double high_alpha);
422 vp_deprecated void initTracking(const vpImage<unsigned char> &I, unsigned int n, vpImagePoint *iP);
423 vp_deprecated void initTracking(const vpImage<unsigned char> &I, unsigned int n, unsigned *i, unsigned *j);
425#endif // VISP_BUILD_DEPRECATED_FUNCTIONS
426
427#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
428public:
429#else
430protected:
431#endif
439 double a;
441 double b;
445 double e;
446
447protected:
459 double alpha1;
464 double alpha2;
466 double ce;
468 double se;
470 std::list<double> angle;
472 double m00;
473#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
475 double mu11, mu20, mu02;
477 double m10, m01;
479 double m11, m02, m20;
480#endif
481
484
494 double m_uc;
496 double m_vc;
498 double m_n20;
500 double m_n11;
502 double m_n02;
504 unsigned int m_expectedDensity;
513
514protected:
521 void computeAbeFromNij();
522
528 double computeAngleOnEllipse(const vpImagePoint &pt) const;
529
536 void computeKiFromNij();
537
543 void computeNijFromAbe();
544
552 void computePointOnEllipse(const double angle, vpImagePoint &iP);
553
561 double computeTheta(const vpImagePoint &iP) const;
562
570 double computeTheta(double u, double v) const;
571
581 void getParameters();
582
590 void leastSquare(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &iP);
591
600 unsigned int leastSquareRobust(const vpImage<unsigned char> &I);
601
613 unsigned int plugHoles(const vpImage<unsigned char> &I);
614
626#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
627 virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false) override;
628#else
629 virtual void sample(const vpImage<unsigned char> &I, bool doNotTrack = false);
630#endif
631
637 void updateTheta();
638
639private:
640#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
641 void computeMoments();
642#endif
643
644 // Static Function
645public:
662 static void displayEllipse(const vpImage<unsigned char> &I, const vpImagePoint &center, const double &A, const double &B,
663 const double &E, const double &smallalpha, const double &highalpha,
664 const vpColor &color = vpColor::green, unsigned int thickness = 1);
665
682 static void displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &A, const double &B,
683 const double &E, const double &smallalpha, const double &highalpha,
684 const vpColor &color = vpColor::green, unsigned int thickness = 1);
685
686#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
687 // Marked deprecated since they override vpMeTracker::display(). Warning detected by mingw64
688 vp_deprecated static void display(const vpImage<unsigned char> &I, const vpImagePoint &center, const double &A, const double &B,
689 const double &E, const double &smallalpha, const double &highalpha,
690 const vpColor &color = vpColor::green, unsigned int thickness = 1);
691 vp_deprecated static void display(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &A, const double &B,
692 const double &E, const double &smallalpha, const double &highalpha,
693 const vpColor &color = vpColor::green, unsigned int thickness = 1);
694#endif
695};
696
697#endif
Implementation of column vector and the associated operations.
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 of the vpImage class member functions.
Definition vpImage.h:135
Class that tracks an ellipse using moving edges.
Definition vpMeEllipse.h:90
double m_n20
Second order centered and normalized moments .
double m_arcEpsilon
Epsilon value used to check if arc angles are the same.
double a
is the semi major axis of the ellipse.
double getHighestAngle() const
double se
Value of sin(e).
vpImagePoint iP2
vpColVector K
double getSmallestAngle() const
vp_deprecated double get_mu20() const
double m_vc
Value of v coordinate of iPc.
unsigned int m_numberOfGoodPoints
Number of correct points tracked along the ellipse.
vpImagePoint iPc
The coordinates of the ellipse center.
std::list< double > angle
Stores the value in increasing order of the angle on the ellipse for each vpMeSite.
vp_deprecated double getA() const
vp_deprecated double get_m20() const
double b
is the semi minor axis of the ellipse.
vp_deprecated double get_m11() const
double m_uc
Value of u coordinate of iPc.
bool m_trackCircle
Track a circle (true) or an ellipse (false).
double ce
Value of cos(e).
vp_deprecated double get_m00() const
void setEndpoints(const vpImagePoint &pt1, const vpImagePoint &pt2)
double m00
Ellipse area.
vpImagePoint getSecondEndpoint() const
vpImagePoint getFirstEndpoint() const
double m_alphamin
vp_deprecated void getEquationParam(double &A, double &B, double &E)
void setThresholdRobust(double threshold)
vpColVector get_ABE() const
vp_deprecated double get_mu11() const
unsigned int getNumberOfGoodPoints() const
bool m_trackArc
Track an arc of ellipse/circle (true) or a complete one (false).
vp_deprecated double get_mu02() const
vpImagePoint getCenter() const
double m_alphamax
vp_deprecated double getB() const
vpColVector get_nij() const
vp_deprecated double get_m10() const
double m_n02
Second order centered and normalized moments .
unsigned int getExpectedDensity() const
unsigned int m_expectedDensity
Expected number of points to track along the ellipse.
vp_deprecated double get_m02() const
double alpha2
double getArea() const
vpImagePoint iP1
double m_n11
Second order centered and normalized moments .
vp_deprecated double get_m01() const
double alpha1
double thresholdWeight
Threshold on the weights for the robust least square.
vp_deprecated double getE() const
Contains abstract elements for a Distance to Feature type feature.
Definition vpMeTracker.h:60
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)