Visual Servoing Platform  version 3.5.0 under development (2022-02-15)

#include <visp3/me/vpMeEllipse.h>

+ Inheritance diagram for vpMeEllipse:

Public Member Functions

 vpMeEllipse ()
 
 vpMeEllipse (const vpMeEllipse &me_ellipse)
 
virtual ~vpMeEllipse ()
 
void display (const vpImage< unsigned char > &I, vpColor col)
 
vpColVector get_nij () const
 
vpColVector get_ABE () const
 
double getArea () const
 
vpImagePoint getCenter () const
 
unsigned int getExpectedDensity () const
 
vpImagePoint getFirstEndpoint () const
 
double getHighestAngle () const
 
vpImagePoint getSecondEndpoint () const
 
double getSmallestAngle () const
 
void initTracking (const vpImage< unsigned char > &I, bool trackArc=false)
 
void initTracking (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &iP, bool trackArc=false)
 
void initTracking (const vpImage< unsigned char > &I, const vpColVector &param, vpImagePoint *pt1=NULL, const vpImagePoint *pt2=NULL)
 
void printParameters () const
 
void setEndpoints (const vpImagePoint &pt1, const vpImagePoint &pt2)
 
void setThresholdRobust (double threshold)
 
void track (const vpImage< unsigned char > &I)
 
Deprecated functions
vp_deprecated double getA () const
 
vp_deprecated double getB () const
 
vp_deprecated double getE () const
 
vp_deprecated double get_m00 () const
 
vp_deprecated double get_m10 () const
 
vp_deprecated double get_m01 () const
 
vp_deprecated double get_m11 () const
 
vp_deprecated double get_m20 () const
 
vp_deprecated double get_m02 () const
 
vp_deprecated double get_mu11 () const
 
vp_deprecated double get_mu02 () const
 
vp_deprecated double get_mu20 () const
 
vp_deprecated void getEquationParam (double &A, double &B, double &E)
 
vp_deprecated void initTracking (const vpImage< unsigned char > &I, const vpImagePoint &center_p, double a_p, double b_p, double e_p, double low_alpha, double high_alpha)
 
vp_deprecated void initTracking (const vpImage< unsigned char > &I, unsigned int n, vpImagePoint *iP)
 
vp_deprecated void initTracking (const vpImage< unsigned char > &I, unsigned int n, unsigned *i, unsigned *j)
 
Public Member Functions Inherited from vpTracker
vpColVector get_p () const
 
vpColVector get_cP () const
 

Static Public Member Functions

static void display (const vpImage< unsigned char > &I, const vpImagePoint &center, const double &A, const double &B, const double &E, const double &smallalpha, const double &highalpha, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
static void display (const vpImage< vpRGBa > &I, const vpImagePoint &center, const double &A, const double &B, const double &E, const double &smallalpha, const double &highalpha, const vpColor &color=vpColor::green, unsigned int thickness=1)
 

Public Attributes

vpColVector K
 
vpImagePoint iPc
 
double a
 
double b
 
double e
 
Public Attributes Inherited from vpMeTracker
std::list< vpMeSitelist
 
vpMeme
 
unsigned int init_range
 
int nGoodElement
 
const vpImage< bool > * m_mask
 
int query_range
 
bool display_point
 
Public Attributes Inherited from vpTracker
vpColVector p
 
vpColVector cP
 
bool cPAvailable
 

Protected Member Functions

void computeAbeFromNij ()
 
double computeAngleOnEllipse (const vpImagePoint &pt) const
 
void computeKiFromNij ()
 
void computeNijFromAbe ()
 
void computePointOnEllipse (const double ang, vpImagePoint &iP)
 
double computeTheta (const vpImagePoint &iP) const
 
double computeTheta (double u, double v) const
 
void getParameters ()
 
void leastSquare (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &iP)
 
void leastSquareRobust (const vpImage< unsigned char > &I)
 
unsigned int plugHoles (const vpImage< unsigned char > &I)
 
virtual void sample (const vpImage< unsigned char > &I, bool doNotTrack=false)
 
void updateTheta ()
 

Protected Attributes

vpImagePoint iP1
 
vpImagePoint iP2
 
double alpha1
 
double alpha2
 
double ce
 
double se
 
std::list< double > angle
 
double m00
 
double mu11
 
double mu20
 
double mu02
 
double m10
 
double m01
 
double m11
 
double m02
 
double m20
 
double thresholdWeight
 
double expecteddensity
 
double m_alphamin
 
double m_alphamax
 
double m_uc
 
double m_vc
 
double m_n20
 
double m_n11
 
double m_n02
 
unsigned int m_expectedDensity
 
unsigned int m_numberOfGoodPoints
 
bool m_trackArc
 
double m_arcEpsilon
 
Protected Attributes Inherited from vpMeTracker
vpMeSite::vpMeSiteDisplayType selectDisplay
 

Public Member Functions Inherited from vpMeTracker

virtual void display (const vpImage< unsigned char > &I)
 
virtual void display (const vpImage< vpRGBa > &I)
 
void display (const vpImage< unsigned char > &I, vpColVector &w, unsigned int &index_w)
 
unsigned int getInitRange ()
 
vpMegetMe ()
 
std::list< vpMeSite > & getMeList ()
 
std::list< vpMeSitegetMeList () const
 
int getNbPoints () const
 
void init ()
 
void initTracking (const vpImage< unsigned char > &I)
 
unsigned int numberOfSignal ()
 
int outOfImage (int i, int j, int half, int row, int cols)
 
int outOfImage (const vpImagePoint &iP, int half, int rows, int cols)
 
void reset ()
 
void setDisplay (vpMeSite::vpMeSiteDisplayType select)
 
void setInitRange (const unsigned int &r)
 
virtual void setMask (const vpImage< bool > &mask)
 
void setMe (vpMe *p_me)
 
void setMeList (const std::list< vpMeSite > &l)
 
unsigned int totalNumberOfSignal ()
 
static bool inMask (const vpImage< bool > *mask, unsigned int i, unsigned int j)
 

Detailed Description

Class that tracks an ellipse using moving edges.

In this class, an ellipse is defined as the set of image points $ (u,v) $ (for more information about the image frame see the vpImagePoint documentation) that satisfy the homogeneous equation:

\[ K_0 u^2 + K_1 v^2 + 2K_2 u v + 2K_3 u + 2K_4 v + K5 = 0 \]

with $K_0 = n_{02}$, $K_1 = n_{20}$, $K_2 = -n_{11}$, etc. (see Eq. (25) of Chaumette TRO 2004 paper [6])

If $ K_0 = K1 $ and $ K_2 = 0 $, the ellipse is a circle.

The six parameters are stored in the private attribute K.

An ellipse is also represented thanks to five parameters that are the center $ (uc,vc) $ of the ellipse and either:

  • three normalized moments $ n_{ij} $ of order 2,
  • or the semimajor axis $ A $, the semiminor axis $ B $ and the ellipse orientation $ E \in [-\pi/2;\pi/2] $ defined by the angle between the major axis and the u axis of the image frame. For more details, see [6]. The following figure illustrates these parameters.
vpMeEllipse.gif

The example below available in tutorial-me-ellipse-tracker.cpp and described in Tutorial: Moving-edges tracking, section Ellipse tracking shows how to use this class.

#include <visp3/core/vpConfig.h>
#ifdef VISP_HAVE_MODULE_SENSOR
#include <visp3/sensor/vp1394CMUGrabber.h>
#include <visp3/sensor/vp1394TwoGrabber.h>
#include <visp3/sensor/vpV4l2Grabber.h>
#endif
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/me/vpMeEllipse.h>
int main()
{
#if (defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_V4L2) || \
(VISP_HAVE_OPENCV_VERSION >= 0x020100))
try {
#if defined(VISP_HAVE_DC1394)
vp1394TwoGrabber g(false);
#elif defined(VISP_HAVE_CMU1394)
#elif defined(VISP_HAVE_V4L2)
#elif defined(VISP_HAVE_OPENCV)
cv::VideoCapture g(0); // open the default camera
if (!g.isOpened()) { // check if we succeeded
std::cout << "Failed to open the camera" << std::endl;
return -1;
}
cv::Mat frame;
#endif
#if defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_CMU1394)
g.acquire(I);
#elif defined(VISP_HAVE_OPENCV)
g >> frame; // get a new frame from camera
#endif
#if defined(VISP_HAVE_X11)
vpDisplayX d(I, 0, 0, "Camera view");
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d(I, 0, 0, "Camera view");
#elif defined(VISP_HAVE_OPENCV)
vpDisplayOpenCV d(I, 0, 0, "Camera view");
#else
std::cout << "No image viewer is available..." << std::endl;
#endif
me.setRange(25);
me.setThreshold(15000);
me.setSampleStep(10);
vpMeEllipse ellipse;
ellipse.setMe(&me);
ellipse.initTracking(I);
while (1) {
#if defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_CMU1394)
g.acquire(I);
#elif defined(VISP_HAVE_OPENCV)
g >> frame;
#endif
ellipse.track(I);
ellipse.display(I, vpColor::red);
}
} catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#endif
}
Examples:
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 97 of file vpMeEllipse.h.

Constructor & Destructor Documentation

◆ vpMeEllipse() [1/2]

vpMeEllipse::vpMeEllipse ( )

Basic constructor that calls the constructor of the class vpMeTracker.

Definition at line 54 of file vpMeEllipse.cpp.

References iP1, iP2, K, vpColVector::resize(), and vpImagePoint::set_ij().

◆ vpMeEllipse() [2/2]

vpMeEllipse::vpMeEllipse ( const vpMeEllipse me_ellipse)

Copy constructor.

Definition at line 80 of file vpMeEllipse.cpp.

◆ ~vpMeEllipse()

vpMeEllipse::~vpMeEllipse ( )
virtual

Basic destructor.

Definition at line 104 of file vpMeEllipse.cpp.

References angle, and vpMeTracker::list.

Member Function Documentation

◆ computeAbeFromNij()

void vpMeEllipse::computeAbeFromNij ( )
protected

Computes the length of the semimajor axis $ a $, the length of the semiminor axis $ b $, and $ e $ that is the angle made by the major axis and the u axis of the image frame $ (u,v) $. They are computed from the normalized moments $ $ n_{ij} $.

Definition at line 253 of file vpMeEllipse.cpp.

References a, b, ce, e, m_n02, m_n11, m_n20, and se.

Referenced by getParameters(), and initTracking().

◆ computeAngleOnEllipse()

double vpMeEllipse::computeAngleOnEllipse ( const vpImagePoint pt) const
protected

Compute the angle of a point on the ellipse wrt the ellipse major axis.

Parameters
pt: Image point on the ellipse.
Returns
The computed angle.

Definition at line 207 of file vpMeEllipse.cpp.

References a, angle, b, ce, vpImagePoint::get_u(), vpImagePoint::get_v(), m_uc, m_vc, and se.

Referenced by initTracking(), leastSquareRobust(), plugHoles(), and track().

◆ computeKiFromNij()

void vpMeEllipse::computeKiFromNij ( )
protected

Computes the parameters $ K = {K_0, ..., K_5} $ from the center of the ellipse and the normalized moments $ n_{ij} $. The parameters $ K $ are such that $ K0 = n02, K1 = n20 $, etc. as in Eq (25) of Chaumette 2004 TRO paper.

Definition at line 281 of file vpMeEllipse.cpp.

References K, m_n02, m_n11, m_n20, m_uc, and m_vc.

Referenced by initTracking().

◆ computeNijFromAbe()

void vpMeEllipse::computeNijFromAbe ( )
protected

Computes the normalized moments $ n_{ij} $ from the $ A, B, E $ parameters as in Eq (24) of Chaumette 2004 TRO paper after simplifications to deal with the case cos(e) = 0.0

Definition at line 297 of file vpMeEllipse.cpp.

References a, b, ce, m_n02, m_n11, m_n20, and se.

Referenced by initTracking().

◆ computePointOnEllipse()

void vpMeEllipse::computePointOnEllipse ( const double  angle,
vpImagePoint iP 
)
protected

Compute the coordinates of a point on an ellipse from its angle with respect to the main orientation of the ellipse.

Parameters
angle: Angle on the ellipse with respect to its major axis.
iP: Image point on the ellipse.

Definition at line 169 of file vpMeEllipse.cpp.

References a, b, ce, m_uc, m_vc, se, and vpImagePoint::set_uv().

Referenced by initTracking(), leastSquareRobust(), plugHoles(), sample(), and track().

◆ computeTheta() [1/2]

double vpMeEllipse::computeTheta ( const vpImagePoint iP) const
protected

Computes the $ \theta $ angle that represents the angle between the tangent to the curve and the u axis. This angle is used for tracking the vpMeSite.

Parameters
iP: The point belonging to the ellipse where the angle is computed.

Definition at line 117 of file vpMeEllipse.cpp.

References vpImagePoint::get_u(), and vpImagePoint::get_v().

Referenced by plugHoles(), sample(), and updateTheta().

◆ computeTheta() [2/2]

double vpMeEllipse::computeTheta ( double  u,
double  v 
) const
protected

Computes the $ \theta $ angle that represents the angle between the tangent to the curve and the u axis. This angle is used for tracking the vpMeSite.

Parameters
u,v: The point belonging to the ellipse where the angle is computed.

Definition at line 132 of file vpMeEllipse.cpp.

References K.

◆ display() [1/6]

void vpMeTracker::display ( const vpImage< unsigned char > &  I)
virtualinherited

Display the moving edge sites with a color corresponding to their state.

  • If green : The vpMeSite is a good point.
  • If blue : The point is removed because of the vpMeSite tracking phase (constrast problem).
  • If purple : The point is removed because of the vpMeSite tracking phase (threshold problem).
  • If red : The point is removed because of the robust method in the virtual visual servoing (M-Estimator problem).
  • If cyan : The point is removed because it's too close to another.
  • Yellow otherwise
Parameters
I: The image.

Definition at line 326 of file vpMeTracker.cpp.

References vpMeSite::display(), and vpMeTracker::list.

◆ display() [2/6]

void vpMeTracker::display ( const vpImage< vpRGBa > &  I)
virtualinherited

Definition at line 340 of file vpMeTracker.cpp.

References vpMeSite::display(), and vpMeTracker::list.

◆ display() [3/6]

void vpMeEllipse::display ( const vpImage< unsigned char > &  I,
vpColor  col 
)
virtual

Display the ellipse or arc of ellipse

Warning
To effectively display the ellipse a call to vpDisplay::flush() is needed.
Parameters
I: Image in which the ellipse appears.
col: Color of the displayed ellipse.

Implements vpMeTracker.

Examples:
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 844 of file vpMeEllipse.cpp.

References a, alpha1, alpha2, b, e, and iPc.

Referenced by track().

◆ display() [4/6]

void vpMeTracker::display ( const vpImage< unsigned char > &  I,
vpColVector w,
unsigned int &  index_w 
)
inherited

Displays the status of moving edge sites

Parameters
I: The image.
w: vector
index_w: index

Definition at line 354 of file vpMeTracker.cpp.

References vpMeTracker::display(), vpMeSite::getState(), vpMeTracker::list, vpMeSite::NO_SUPPRESSION, and vpMeSite::weight.

◆ display() [5/6]

void vpMeEllipse::display ( const vpImage< unsigned char > &  I,
const vpImagePoint center,
const double &  A,
const double &  B,
const double &  E,
const double &  smallalpha,
const double &  highalpha,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
static

Display the ellipse or the arc of ellipse thanks to the ellipse parameters.

Parameters
I: The image used as background.
center: Center of the ellipse.
A: Semimajor axis of the ellipse.
B: Semiminor axis of the ellipse.
E: Angle made by the major axis and the u axis of the image frame $ (u,v) $ (in rad).
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse).
highalpha: Highest $ alpha $ angle in rad (2 $ \Pi $ for a complete ellipse).
color: Color used to display the ellipse.
thickness: Thickness of the drawings.

Definition at line 1197 of file vpMeEllipse.cpp.

References vpDisplay::displayEllipse().

◆ display() [6/6]

void vpMeEllipse::display ( const vpImage< vpRGBa > &  I,
const vpImagePoint center,
const double &  A,
const double &  B,
const double &  E,
const double &  smallalpha,
const double &  highalpha,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
static

Display the ellipse or the arc of ellipse thanks to the ellipse parameters.

Parameters
I: The image used as background.
center: Center of the ellipse
A: Semimajor axis of the ellipse.
B: Semiminor axis of the ellipse.
E: Angle made by the major axis and the u axis of the image frame $ (u,v) $ (in rad)
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse)
highalpha: Highest $ alpha $ angle in rad ( $ 2 \Pi $ for a complete ellipse)
color: Color used to display th lines.
thickness: Thickness of the drawings.

Definition at line 1228 of file vpMeEllipse.cpp.

References vpDisplay::displayEllipse().

◆ get_ABE()

vpColVector vpMeEllipse::get_ABE ( ) const
inline

Gets the ellipse parameters as a 3-dim vector containing $ A, B, E $.

Returns
The 3-dim vector containing $ A, B, E $ corresponding respectively to the semimajor axis, the semiminor axis and the angle in rad made by the major axis and the u axis of the image frame $ (u,v) $, $ e \in [-\pi/2;pi/2] $.
See also
getCenter(), get_nij(), getArea()

Definition at line 134 of file vpMeEllipse.h.

◆ get_cP()

vpColVector vpTracker::get_cP ( ) const
inlineinherited

Return object parameters expressed in the 3D camera frame.

Definition at line 99 of file vpTracker.h.

◆ get_m00()

vp_deprecated double vpMeEllipse::get_m00 ( ) const
inline
Deprecated:
Call rather getArea().

Gets the zero order moment $ m_{00} $ which represents the area of the ellipse.

Returns
The value of $ m_{00} $.
See also
getArea()

Definition at line 274 of file vpMeEllipse.h.

◆ get_m01()

vp_deprecated double vpMeEllipse::get_m01 ( ) const
inline
Deprecated:
Gets the first order raw moment $ m_{01} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.
Returns
the value of $ m_{01} $.

Definition at line 290 of file vpMeEllipse.h.

◆ get_m02()

vp_deprecated double vpMeEllipse::get_m02 ( ) const
inline
Deprecated:
Gets the second order raw moment $ m_{02} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.
Returns
the value of $ m_{11} $.

Definition at line 314 of file vpMeEllipse.h.

◆ get_m10()

vp_deprecated double vpMeEllipse::get_m10 ( ) const
inline
Deprecated:
Gets the first order raw moment $ m_{10} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.
Returns
the value of $ m_{10} $.

Definition at line 282 of file vpMeEllipse.h.

◆ get_m11()

vp_deprecated double vpMeEllipse::get_m11 ( ) const
inline
Deprecated:
Gets the second order raw moment $ m_{11} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.
Returns
the value of $ m_{11} $.

Definition at line 298 of file vpMeEllipse.h.

◆ get_m20()

vp_deprecated double vpMeEllipse::get_m20 ( ) const
inline
Deprecated:
Gets the second order raw moment $ m_{20} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.
Returns
the value of $ m_{11} $.

Definition at line 306 of file vpMeEllipse.h.

◆ get_mu02()

vp_deprecated double vpMeEllipse::get_mu02 ( ) const
inline
Deprecated:
Gets the second order centered moment $ \mu_{02} $.
Returns
the value of $ \mu_{02} $.

Definition at line 328 of file vpMeEllipse.h.

◆ get_mu11()

vp_deprecated double vpMeEllipse::get_mu11 ( ) const
inline
Deprecated:
Gets the second order centered moment $ \mu_{11} $.
Returns
the value of $ \mu_{11} $.

Definition at line 321 of file vpMeEllipse.h.

◆ get_mu20()

vp_deprecated double vpMeEllipse::get_mu20 ( ) const
inline
Deprecated:
Gets the second order centered moment $ \mu_{20} $.
Returns
the value of $ \mu_{20} $.

Definition at line 335 of file vpMeEllipse.h.

◆ get_nij()

vpColVector vpMeEllipse::get_nij ( ) const
inline

Gets the second order normalized centered moment $ n_{ij} $ as a 3-dim vector containing $ n_{20}, n_{11}, n_{02} $ such as $ n_{ij} = \mu_{ij}/m_{00} $

Returns
The 3-dim vector containing $ n_{20}, n_{11}, n_{02} $.
See also
getCenter(), get_ABE(), getArea()

Definition at line 115 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

◆ get_p()

vpColVector vpTracker::get_p ( ) const
inlineinherited

Return object parameters expressed in the 2D image plane computed by perspective projection.

Definition at line 97 of file vpTracker.h.

◆ getA()

vp_deprecated double vpMeEllipse::getA ( ) const
inline
Deprecated:
You should rather use get_ABE(). Gets the semimajor axis of the ellipse.
See also
get_ABE()

Definition at line 245 of file vpMeEllipse.h.

◆ getArea()

double vpMeEllipse::getArea ( ) const
inline

Gets the area of the ellipse corresponding also to the zero order moment of the ellipse.

Returns
The ellipse area.
See also
getCenter(), get_nij(), get_ABE()

Definition at line 152 of file vpMeEllipse.h.

◆ getB()

vp_deprecated double vpMeEllipse::getB ( ) const
inline
Deprecated:
You should rather use get_ABE(). Gets the semiminor axis of the ellipse.
See also
get_ABE()

Definition at line 253 of file vpMeEllipse.h.

◆ getCenter()

vpImagePoint vpMeEllipse::getCenter ( ) const
inline

Gets the center of the ellipse.

See also
get_nij(), get_ABE(), getArea()

Definition at line 159 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

◆ getE()

vp_deprecated double vpMeEllipse::getE ( ) const
inline
Deprecated:
You should rather use get_ABE(). Gets the angle made by the major axis and the u axis of the image frame $ (u,v) $, $ e \in [-\pi/2;pi/2] $.
See also
get_ABE()

Definition at line 262 of file vpMeEllipse.h.

◆ getEquationParam()

vp_deprecated void vpMeEllipse::getEquationParam ( double &  A,
double &  B,
double &  E 
)
inline
Deprecated:
You should rather use get_ABE(). Gets the equation parameters of the ellipse.

Definition at line 340 of file vpMeEllipse.h.

References vpMeTracker::initTracking().

◆ getExpectedDensity()

unsigned int vpMeEllipse::getExpectedDensity ( ) const
inline
Returns
Expected number of moving edges to track along the ellipse.

Definition at line 164 of file vpMeEllipse.h.

◆ getFirstEndpoint()

vpImagePoint vpMeEllipse::getFirstEndpoint ( ) const
inline

Gets the first endpoint of the ellipse arc (corresponding to alpha1, not alphamin) when an arc is tracked.

See also
getSecondEndpoint()

Definition at line 172 of file vpMeEllipse.h.

◆ getHighestAngle()

double vpMeEllipse::getHighestAngle ( ) const
inline

Gets the highest $ alpha $ angle of the moving edges tracked $ \alpha_{max} \in [\alpha_min;\alpha_2] $.

See also
getSmallestAngle()

Definition at line 180 of file vpMeEllipse.h.

◆ getInitRange()

unsigned int vpMeTracker::getInitRange ( )
inlineinherited

Return the initial range.

Returns
Value of init_range.

Definition at line 113 of file vpMeTracker.h.

◆ getMe()

vpMe* vpMeTracker::getMe ( )
inlineinherited

Return the moving edges initialisation parameters

Returns
Moving Edges.
Examples:
trackMeCircle.cpp, and trackMeEllipse.cpp.

Definition at line 120 of file vpMeTracker.h.

◆ getMeList() [1/2]

std::list<vpMeSite>& vpMeTracker::getMeList ( )
inlineinherited

Return the list of moving edges

Returns
List of Moving Edges.

Definition at line 127 of file vpMeTracker.h.

◆ getMeList() [2/2]

std::list<vpMeSite> vpMeTracker::getMeList ( ) const
inlineinherited

Definition at line 128 of file vpMeTracker.h.

◆ getNbPoints()

int vpMeTracker::getNbPoints ( ) const
inlineinherited

Return the number of points that has not been suppressed.

Returns
Number of good points.

Definition at line 135 of file vpMeTracker.h.

References vpTracker::init(), and vpTracker::operator=().

◆ getParameters()

void vpMeEllipse::getParameters ( )
protected

Computes the coordinates of the ellipse center, the normalized moments $ n_{ij} $, the length of the semimajor axis $ a $, the length of the semiminor axis $ b $, and $ e $ that is the angle made by the major axis and the u axis of the image frame $ (u,v) $.

All those computations are made from the parameters $ K ={K_0, ..., K_5} $ so that $ K_0 u^2 + K1 v^2 + 2 K2 u v + 2 K3 u + 2 K4 v + K5 = 0 $.

Definition at line 313 of file vpMeEllipse.cpp.

References computeAbeFromNij(), vpException::fatalError, iPc, K, m_n02, m_n11, m_n20, m_uc, m_vc, printParameters(), vpImagePoint::set_uv(), and vpDEBUG_ENABLE.

Referenced by leastSquare(), and leastSquareRobust().

◆ getSecondEndpoint()

vpImagePoint vpMeEllipse::getSecondEndpoint ( ) const
inline

Gets the second endpoint of the ellipse arc (corresponding to alpha2, not alphamax) when an arc is tracked.

See also
getFirstEndpoint()

Definition at line 188 of file vpMeEllipse.h.

◆ getSmallestAngle()

double vpMeEllipse::getSmallestAngle ( ) const
inline

Gets the smallest $ alpha $ angle of the moving edges tracked $ \alpha_{min} \in [\alpha_1;\alpha_2] $.

See also
getHighestAngle()

Definition at line 196 of file vpMeEllipse.h.

References vpMeTracker::initTracking().

◆ init()

void vpMeTracker::init ( void  )
inherited

◆ initTracking() [1/7]

◆ initTracking() [2/7]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
bool  trackArc = false 
)

Initialize the tracking of an ellipse or an arc of an ellipse when trackArc is set to true. Ask the user to click on five points located on the ellipse to be tracked.

Warning
The points should be selected as far as possible from each other. When an arc of an ellipse is tracked, it is recommended to select the 5 points clockwise.
Parameters
I: Image in which the ellipse appears.
trackArc: When true, track an arc of the ellipse. First and fifth points specify the extremities of the arc (clockwise). When false track the complete ellipse.
Examples:
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 861 of file vpMeEllipse.cpp.

References vpDisplay::displayCross(), vpDisplay::flush(), vpDisplay::getClick(), m_trackArc, and vpColor::red.

Referenced by initTracking().

◆ initTracking() [3/7]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
const std::vector< vpImagePoint > &  iP,
bool  trackArc = false 
)

Initialize the tracking of an ellipse or an arc of an ellipse when trackArc is set to true. The ellipse is defined thanks to a vector of image points.

Warning
It is mandatory to use at least five image points to estimate the ellipse parameters.
The image points should be selected as far as possible from each other. When an arc of an ellipse is tracked, it is recommended to select the 5 points clockwise.
Parameters
I: Image in which the ellipse appears.
iP: A vector of image points belonging to the ellipse edge used to initialize the tracking.
trackArc: When true, track an arc of the ellipse. First and last points specify the extremities of the arc (clockwise). When false track the complete ellipse.

Definition at line 896 of file vpMeEllipse.cpp.

References alpha1, alpha2, computeAngleOnEllipse(), computePointOnEllipse(), vpMeTracker::display(), vpDisplay::flush(), iP1, iP2, leastSquare(), m_arcEpsilon, m_trackArc, sample(), and track().

◆ initTracking() [4/7]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
const vpColVector param,
vpImagePoint pt1 = NULL,
const vpImagePoint pt2 = NULL 
)

Initialize the tracking of an ellipse or an arc of an ellipse when arc extremities are given. The ellipse is defined by the vector containing the coordinates of its center and the three second order centered normalized moments $ n_ij $. Without setting the arc extremities with parameters pt1 and pt2, the complete ellipse is considered. When extremities are set, we consider an ellipse arc defined clockwise from first extremity to second extremity.

Parameters
I: Image in which the ellipse appears.
param: Vector with the five parameters $(u_c, v_c, n_{20}, n_{11}, n_{02})$ defining the ellipse (expressed in pixels).
pt1: Image point defining the first extremity of the arc or NULL to track a complete ellipse.
pt2: Image point defining the second extremity of the arc or NULL to track a complete ellipse.

Definition at line 941 of file vpMeEllipse.cpp.

References alpha1, alpha2, computeAbeFromNij(), computeAngleOnEllipse(), computeKiFromNij(), computePointOnEllipse(), vpMeTracker::display(), vpDisplay::flush(), iP1, iP2, iPc, m_arcEpsilon, m_n02, m_n11, m_n20, m_trackArc, m_uc, m_vc, sample(), vpImagePoint::set_uv(), and track().

◆ initTracking() [5/7]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
const vpImagePoint center_p,
double  a_p,
double  b_p,
double  e_p,
double  alpha1_p,
double  alpha2_p 
)
Deprecated:
Initialization of the tracking. The arc of the ellipse is defined thanks to its center, semimajor axis, semiminor axis, orientation and the angle of its two extremities
Parameters
I: Image in which the ellipse appears.
center_p: Ellipse center.
a_p: Semimajor axis.
b_p: Semiminor axis.
e_p: Orientationn in rad.
alpha1_p: Angle in rad defining the first extremity of the arc.
alpha2_p: Angle in rad defining the second extremity of the arc.

Definition at line 1103 of file vpMeEllipse.cpp.

References a, alpha1, alpha2, b, ce, computeKiFromNij(), computeNijFromAbe(), computePointOnEllipse(), vpMeTracker::display(), e, vpDisplay::flush(), vpImagePoint::get_u(), vpImagePoint::get_v(), iP1, iP2, iPc, m_trackArc, m_uc, m_vc, sample(), se, and track().

◆ initTracking() [6/7]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
unsigned int  n,
vpImagePoint iP 
)
Deprecated:
Initialization of the tracking. The ellipse is defined thanks to the coordinates of n points.
Warning
It is mandatory to use at least five points to estimate the ellipse parameters.
The n points should be selected as far as possible from each other.
Parameters
I: Image in which the ellipse appears.
n: The number of points in the list.
iP: A pointer to a list of points belonging to the ellipse edge.

Definition at line 1151 of file vpMeEllipse.cpp.

References initTracking().

◆ initTracking() [7/7]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
unsigned int  n,
unsigned *  i,
unsigned *  j 
)
Deprecated:
Use an other initTracking() function.

Definition at line 1164 of file vpMeEllipse.cpp.

References initTracking().

◆ inMask()

bool vpMeTracker::inMask ( const vpImage< bool > *  mask,
unsigned int  i,
unsigned int  j 
)
staticinherited

Test whether the pixel is inside the mask. Mask values that are set to true are considered in the tracking.

Parameters
maskMask image or NULL if not wanted. Mask values that are set to true are considered in the tracking. To disable a pixel, set false.
i: Pixel coordinate along the rows.
j: Pixel coordinate along the columns.

Definition at line 140 of file vpMeTracker.cpp.

References vpImage< Type >::getValue().

Referenced by vpMbtFaceDepthDense::computeDesiredFeatures(), vpMbtFaceDepthNormal::computeDesiredFeatures(), vpMbtDistanceKltPoints::computeNbDetectedCurrent(), vpMbtDistanceKltPoints::init(), and vpMeTracker::track().

◆ leastSquare()

void vpMeEllipse::leastSquare ( const vpImage< unsigned char > &  I,
const std::vector< vpImagePoint > &  iP 
)
protected

Least squares method to compute the ellipse to which the points belong.

Parameters
I: Image in which the ellipse appears (useful just to get its number of rows and columns...
iP: A vector of points belonging to the ellipse.

Definition at line 573 of file vpMeEllipse.cpp.

References vpException::fatalError, vpImage< Type >::getHeight(), getParameters(), vpImage< Type >::getWidth(), K, and vpMatrix::nullSpace().

Referenced by initTracking().

◆ leastSquareRobust()

◆ numberOfSignal()

unsigned int vpMeTracker::numberOfSignal ( )
inherited

◆ outOfImage() [1/2]

int vpMeTracker::outOfImage ( int  i,
int  j,
int  half,
int  row,
int  cols 
)
inherited

◆ outOfImage() [2/2]

int vpMeTracker::outOfImage ( const vpImagePoint iP,
int  half,
int  rows,
int  cols 
)
inherited

Definition at line 155 of file vpMeTracker.cpp.

References vpImagePoint::get_i(), vpImagePoint::get_j(), and vpMath::round().

◆ plugHoles()

unsigned int vpMeEllipse::plugHoles ( const vpImage< unsigned char > &  I)
protected

◆ printParameters()

void vpMeEllipse::printParameters ( ) const

Print the parameters $ K = {K_0, ..., K_5} $, the coordinates of the ellipse center, the normalized moments, and the A, B, E parameters.

Definition at line 347 of file vpMeEllipse.cpp.

References a, b, vpMath::deg(), e, K, m_n02, m_n11, m_n20, m_uc, m_vc, and vpColVector::t().

Referenced by getParameters(), and track().

◆ reset()

void vpMeTracker::reset ( )
inherited

Reset the tracker by removing all the moving edges.

Definition at line 96 of file vpMeTracker.cpp.

References vpMeTracker::list, and vpMeTracker::nGoodElement.

Referenced by vpMeTracker::~vpMeTracker().

◆ sample()

void vpMeEllipse::sample ( const vpImage< unsigned char > &  I,
bool  doNotTrack = false 
)
protectedvirtual

Construct a list of vpMeSite moving edges at a particular sampling step between the two extremities. The two extremities are defined by the points with the smallest and the biggest $ alpha $ angle.

Parameters
I: Image in which the ellipse appears.
doNotTrack: If true, moving-edges are not tracked.
Exceptions
vpTrackingException::initializationError: Moving edges not initialized.

Implements vpMeTracker.

Definition at line 367 of file vpMeEllipse.cpp.

References alpha1, alpha2, angle, computePointOnEllipse(), computeTheta(), vpDisplay::displayCross(), expecteddensity, vpException::fatalError, vpImagePoint::get_i(), vpImagePoint::get_j(), vpImage< Type >::getHeight(), vpMe::getSampleStep(), vpImage< Type >::getWidth(), vpMeSite::init(), vpMeTracker::initTracking(), vpMeTracker::list, m_expectedDensity, vpMeTracker::me, vpMeSite::NO_SUPPRESSION, vpMeTracker::outOfImage(), vpMath::rad(), vpColor::red, vpMath::round(), vpMeTracker::selectDisplay, vpMeSite::setDisplay(), vpMe::setSampleStep(), and vpMeSite::setState().

Referenced by initTracking(), and track().

◆ setDisplay()

◆ setEndpoints()

void vpMeEllipse::setEndpoints ( const vpImagePoint pt1,
const vpImagePoint pt2 
)
inline

Set the two endpoints of the ellipse arc when an arc is tracked.

Definition at line 206 of file vpMeEllipse.h.

◆ setInitRange()

void vpMeTracker::setInitRange ( const unsigned int &  r)
inlineinherited

Set the initial range.

Parameters
r: initial range.

Definition at line 159 of file vpMeTracker.h.

◆ setMask()

virtual void vpMeTracker::setMask ( const vpImage< bool > &  mask)
inlinevirtualinherited

Set the mask

Parameters
mask: Mask.

Definition at line 166 of file vpMeTracker.h.

◆ setMe()

◆ setMeList()

void vpMeTracker::setMeList ( const std::list< vpMeSite > &  l)
inlineinherited

Set the list of moving edges

Parameters
l: list of Moving Edges.

Definition at line 180 of file vpMeTracker.h.

◆ setThresholdRobust()

void vpMeEllipse::setThresholdRobust ( double  threshold)
inline

Set the threshold for the weights in the robust estimation of the ellipse parameters. If the weight of a point is below this threshold, this one is removed from the list of tracked meSite. Value must be between 0 (never rejected) and 1 (always rejected).

Parameters
threshold: The new value of the threshold.

Definition at line 221 of file vpMeEllipse.h.

References vpMeTracker::track().

◆ totalNumberOfSignal()

unsigned int vpMeTracker::totalNumberOfSignal ( )
inherited

Definition at line 129 of file vpMeTracker.cpp.

References vpMeTracker::list.

◆ track()

◆ updateTheta()

void vpMeEllipse::updateTheta ( )
protected

Compute the $ theta $ angle for each vpMeSite.

Note
The $ theta $ angle is useful during the tracking part.

Definition at line 149 of file vpMeEllipse.cpp.

References vpMeSite::alpha, computeTheta(), vpMeSite::ifloat, vpMeSite::jfloat, vpMeTracker::list, and vpImagePoint::set_ij().

Referenced by track().

Member Data Documentation

◆ a

double vpMeEllipse::a

$ a $ is the semimajor axis of the ellipse.

Definition at line 365 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeAngleOnEllipse(), computeNijFromAbe(), computePointOnEllipse(), display(), initTracking(), printParameters(), and track().

◆ alpha1

double vpMeEllipse::alpha1
protected

The angle $ \alpha_1 \in [-\pi;\pi] $ on the ellipse corresponding to the first endpoint. Its value is 0 for tracking a complete ellipse

Definition at line 385 of file vpMeEllipse.h.

Referenced by display(), initTracking(), leastSquareRobust(), plugHoles(), sample(), and track().

◆ alpha2

double vpMeEllipse::alpha2
protected

The angle $ \alpha_2 \in [\alpha_1;\alpha_1+2\pi]$ on the ellipse corresponding to the second endpoint. Its value is $ 2 \pi $ for tracking a complete ellipse

Definition at line 390 of file vpMeEllipse.h.

Referenced by display(), initTracking(), leastSquareRobust(), plugHoles(), sample(), and track().

◆ angle

std::list<double> vpMeEllipse::angle
protected

Stores the value in increasing order of the $ alpha $ angle on the ellipse for each vpMeSite .

Definition at line 396 of file vpMeEllipse.h.

Referenced by computeAngleOnEllipse(), leastSquareRobust(), plugHoles(), sample(), and ~vpMeEllipse().

◆ b

double vpMeEllipse::b

$ b $ is the semiminor axis of the ellipse.

Definition at line 367 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeAngleOnEllipse(), computeNijFromAbe(), computePointOnEllipse(), display(), initTracking(), printParameters(), and track().

◆ ce

double vpMeEllipse::ce
protected

Value of cos(e).

Definition at line 392 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeAngleOnEllipse(), computeNijFromAbe(), computePointOnEllipse(), and initTracking().

◆ cP

◆ cPAvailable

bool vpTracker::cPAvailable
inherited

Flag used to indicate if the feature parameters cP expressed in the camera frame are available.

Definition at line 83 of file vpTracker.h.

Referenced by vpTracker::init(), and vpTracker::operator=().

◆ display_point

bool vpMeTracker::display_point
inherited

Definition at line 193 of file vpMeTracker.h.

Referenced by vpMeTracker::operator=(), and vpMeTracker::vpMeTracker().

◆ e

double vpMeEllipse::e

$ e \in [-\pi/2;\pi/2] $ is the angle made by the major axis and the u axis of the image frame $ (u,v) $.

Definition at line 371 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), display(), initTracking(), and printParameters().

◆ expecteddensity

double vpMeEllipse::expecteddensity
protected

Expected number of points to track along the ellipse.

Definition at line 413 of file vpMeEllipse.h.

Referenced by sample().

◆ init_range

unsigned int vpMeTracker::init_range
inherited

◆ iP1

vpImagePoint vpMeEllipse::iP1
protected

The coordinates of the first endpoint of the ellipse arc corresponding to angle $ \alpha_1 $

Definition at line 377 of file vpMeEllipse.h.

Referenced by initTracking(), track(), and vpMeEllipse().

◆ iP2

vpImagePoint vpMeEllipse::iP2
protected

The coordinates of the second endpoint of the ellipse arc corresponding to angle $ \alpha_2 $

Definition at line 381 of file vpMeEllipse.h.

Referenced by initTracking(), track(), and vpMeEllipse().

◆ iPc

vpImagePoint vpMeEllipse::iPc

The coordinates of the ellipse center.

Definition at line 363 of file vpMeEllipse.h.

Referenced by display(), getParameters(), and initTracking().

◆ K

vpColVector vpMeEllipse::K

Parameters of the ellipse satisfying the homogeneous equation :

\[ K_0 u^2 + K_1 v^2 + 2K_2 uv + 2K_3u + 2K_4v + K5 = 0 \]

Definition at line 361 of file vpMeEllipse.h.

Referenced by computeKiFromNij(), computeTheta(), getParameters(), leastSquare(), leastSquareRobust(), printParameters(), and vpMeEllipse().

◆ list

◆ m00

double vpMeEllipse::m00
protected

Ellipse area.

Definition at line 398 of file vpMeEllipse.h.

Referenced by track().

◆ m01

double vpMeEllipse::m01
protected

Definition at line 403 of file vpMeEllipse.h.

Referenced by track().

◆ m02

double vpMeEllipse::m02
protected

Definition at line 405 of file vpMeEllipse.h.

Referenced by track().

◆ m10

double vpMeEllipse::m10
protected

First order raw moments.

Definition at line 403 of file vpMeEllipse.h.

Referenced by track().

◆ m11

double vpMeEllipse::m11
protected

Second order raw moments.

Definition at line 405 of file vpMeEllipse.h.

Referenced by track().

◆ m20

double vpMeEllipse::m20
protected

Definition at line 405 of file vpMeEllipse.h.

Referenced by track().

◆ m_alphamax

double vpMeEllipse::m_alphamax
protected

The highest angle $ \alpha_{max} \in [\alpha_{min};\alpha_2]$ of the current moving edge list

Definition at line 423 of file vpMeEllipse.h.

Referenced by leastSquareRobust(), plugHoles(), and track().

◆ m_alphamin

double vpMeEllipse::m_alphamin
protected

The smallest angle $ \alpha_{min} \in [\alpha_1;\alpha_2]$ of the current moving edge list

Definition at line 419 of file vpMeEllipse.h.

Referenced by leastSquareRobust(), plugHoles(), and track().

◆ m_arcEpsilon

double vpMeEllipse::m_arcEpsilon
protected

Epsilon value used to check if arc angles are the same.

Definition at line 437 of file vpMeEllipse.h.

Referenced by initTracking(), and track().

◆ m_expectedDensity

unsigned int vpMeEllipse::m_expectedDensity
protected

Expected number of points to track along the ellipse.

Definition at line 431 of file vpMeEllipse.h.

Referenced by sample(), and track().

◆ m_mask

const vpImage<bool>* vpMeTracker::m_mask
inherited

Mask used to disable tracking on a part of image.

Definition at line 84 of file vpMeTracker.h.

Referenced by vpMeTracker::track().

◆ m_n02

double vpMeEllipse::m_n02
protected

◆ m_n11

double vpMeEllipse::m_n11
protected

◆ m_n20

double vpMeEllipse::m_n20
protected

Second order centered and normalized moments.

Definition at line 429 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeKiFromNij(), computeNijFromAbe(), getParameters(), initTracking(), printParameters(), and track().

◆ m_numberOfGoodPoints

unsigned int vpMeEllipse::m_numberOfGoodPoints
protected

Number of correct points tracked along the ellipse.

Definition at line 433 of file vpMeEllipse.h.

Referenced by leastSquareRobust(), and track().

◆ m_trackArc

bool vpMeEllipse::m_trackArc
protected

Track an arc of ellipse (true) or a complete one (false).

Definition at line 435 of file vpMeEllipse.h.

Referenced by initTracking(), and track().

◆ m_uc

double vpMeEllipse::m_uc
protected

Value of u coordinate of iPc.

Definition at line 425 of file vpMeEllipse.h.

Referenced by computeAngleOnEllipse(), computeKiFromNij(), computePointOnEllipse(), getParameters(), initTracking(), printParameters(), and track().

◆ m_vc

double vpMeEllipse::m_vc
protected

Value of v coordinate of iPc.

Definition at line 427 of file vpMeEllipse.h.

Referenced by computeAngleOnEllipse(), computeKiFromNij(), computePointOnEllipse(), getParameters(), initTracking(), printParameters(), and track().

◆ me

◆ mu02

double vpMeEllipse::mu02
protected

Definition at line 401 of file vpMeEllipse.h.

Referenced by track().

◆ mu11

double vpMeEllipse::mu11
protected

Second order centered moments.

Definition at line 401 of file vpMeEllipse.h.

Referenced by track().

◆ mu20

double vpMeEllipse::mu20
protected

Definition at line 401 of file vpMeEllipse.h.

Referenced by track().

◆ nGoodElement

int vpMeTracker::nGoodElement
inherited

◆ p

◆ query_range

int vpMeTracker::query_range
inherited

Definition at line 192 of file vpMeTracker.h.

Referenced by vpMeTracker::operator=(), and vpMeTracker::vpMeTracker().

◆ se

double vpMeEllipse::se
protected

Value of sin(e).

Definition at line 394 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeAngleOnEllipse(), computeNijFromAbe(), computePointOnEllipse(), and initTracking().

◆ selectDisplay

◆ thresholdWeight

double vpMeEllipse::thresholdWeight
protected

Threshold on the weights for the robust least square.

Definition at line 409 of file vpMeEllipse.h.

Referenced by leastSquareRobust().