ViSP  2.9.0

#include <vpMeEllipse.h>

+ Inheritance diagram for vpMeEllipse:

Public Member Functions

 vpMeEllipse ()
 
 vpMeEllipse (const vpMeEllipse &meellipse)
 
virtual ~vpMeEllipse ()
 
void track (const vpImage< unsigned char > &Im)
 
void initTracking (const vpImage< unsigned char > &I)
 
void initTracking (const vpImage< unsigned char > &I, const unsigned int n, vpImagePoint *iP)
 
void display (const vpImage< unsigned char > &I, vpColor col)
 
void printParameters ()
 
void setCircle (bool is_circle)
 
double get_m00 () const
 
double get_m10 () const
 
double get_m01 () const
 
double get_m11 () const
 
double get_m20 () const
 
double get_m02 () const
 
double get_mu11 () const
 
double get_mu02 () const
 
double get_mu20 () const
 
vpImagePoint getCenter () const
 
double getA () const
 
double getB () const
 
double getE () const
 
void getEquationParam (double &A, double &B, double &E)
 
double getSmallestAngle ()
 
double getHighestAngle ()
 
void setThresholdRobust (const double threshold)
 
void init ()
 
unsigned int numberOfSignal ()
 
unsigned int totalNumberOfSignal ()
 
virtual void display (const vpImage< unsigned char > &I)
 
void display (const vpImage< unsigned char > &I, vpColVector &w, unsigned int &index_w)
 
void setDisplay (vpMeSite::vpMeSiteDisplayType select)
 
int outOfImage (int i, int j, int half, int rows, int cols)
 
int outOfImage (vpImagePoint iP, int half, int rows, int cols)
 
void setInitRange (const unsigned int &r)
 
unsigned int getInitRange ()
 
void setMe (vpMe *p_me)
 
vpMegetMe ()
 
void setMeList (const std::list< vpMeSite > &l)
 
std::list< vpMeSite > & getMeList ()
 
std::list< vpMeSitegetMeList () const
 
int getNbPoints () 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, vpColor color=vpColor::green)
 
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, vpColor color=vpColor::green)
 

Public Attributes

vpColVector K
 
vpImagePoint iPc
 
double a
 
double b
 
double e
 
std::list< vpMeSitelist
 
vpMeme
 
unsigned int init_range
 
int nGoodElement
 
int query_range
 
bool display_point
 
vpColVector p
 
vpColVector cP
 
bool cPAvailable
 

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
 
vpMeSite::vpMeSiteDisplayType selectDisplay
 

Deprecated functions

void initTracking (const vpImage< unsigned char > &I, const unsigned int n, unsigned *i, unsigned *j)
 

Detailed Description

Class that tracks an ellipse moving edges.

In this class, an ellipse is defined as the set of points $ (i,j) $ of the image frame (For more information about the image frame see the vpImagePoint documentation) that satisfy the implicit equation :

\[ i^2 + K_0j^2 + 2K_1ij + 2K_2i + 2K_3j + K4 = 0 \]

If $ K_0 $ is equal to 1 and $ K_1 $ is equal to 0 the the set of points $ (i,j) $ represents a circle.

The five parameters are stored in the public attribute K.

An ellipse is also defined thanks to three other parameter which are $ a $, $ b $ and $ e $. $ a $ represents the semiminor axis and $ b $ is the semimajor axis. Here $ e $ is the angle made by the major axis and the i axis of the image frame $ (i,j) $. The following figure shows better meaning of those parameters.

vpMeEllipse.gif

It is possible to compute the coordinates $ (i,j) $ of a point which belongs to the ellipse thanks to the following equations :

\[ i = i_c + b cos(e) cos(\alpha) - a sin(e) sin(\alpha) \]

\[ j = j_c + b sin(e) cos(\alpha) + a cos(e) sin(\alpha) \]

Here the coordinates $ (i_c,j_c) $ are the coordinates of the ellipse center in the image frame and $ \alpha $ is an angle beetween $ [0,2\pi] $ and which enables to describe all the points of the ellipse.

vpMeEllipse2.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 <visp/vp1394CMUGrabber.h>
#include <visp/vp1394TwoGrabber.h>
#include <visp/vpV4l2Grabber.h>
#include <visp/vpDisplayGDI.h>
#include <visp/vpDisplayX.h>
#include <visp/vpMeEllipse.h>
int main()
{
#if (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_V4L2))
try {
#if defined(VISP_HAVE_DC1394_2)
vp1394TwoGrabber g(false);
#elif defined(VISP_HAVE_CMU1394)
#elif defined(VISP_HAVE_V4L2)
#endif
g.open(I);
g.acquire(I);
#if defined(VISP_HAVE_X11)
vpDisplayX d(I, 0, 0, "Camera view");
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI 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) {
g.acquire(I);
ellipse.track(I);
ellipse.display(I, vpColor::red);
}
}
catch(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 142 of file vpMeEllipse.h.

Constructor & Destructor Documentation

vpMeEllipse::vpMeEllipse ( )

Basic constructor that calls the constructor of the class vpMeTracker.

Definition at line 83 of file vpMeEllipse.cpp.

References iP1, iP2, vpImagePoint::set_i(), vpImagePoint::set_j(), and vpCDEBUG.

vpMeEllipse::vpMeEllipse ( const vpMeEllipse meellipse)

Copy constructor.

Definition at line 107 of file vpMeEllipse.cpp.

References a, alpha1, alpha2, angle, b, ce, e, iP1, iP2, iPc, K, m00, m01, m02, m10, m11, m20, mu02, mu11, mu20, se, and thresholdWeight.

vpMeEllipse::~vpMeEllipse ( )
virtual

Basic destructor.

Definition at line 144 of file vpMeEllipse.cpp.

References angle, vpMeTracker::list, and vpCDEBUG.

Member Function Documentation

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.

Reimplemented in vpMbtMeLine.

Definition at line 326 of file vpMeTracker.cpp.

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

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 347 of file vpMeTracker.cpp.

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

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

Display the 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 787 of file vpMeEllipse.cpp.

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

Referenced by initTracking(), and track().

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,
vpColor  color = vpColor::green 
)
static

Display of the ellipse thanks to the equation parameters.

Parameters
I: The image used as background.
center: Center of the ellipse
A: Semiminor axis of the ellipse.
B: Semimajor axis of the ellipse.
E: Angle made by the major axis and the i axis of the image frame $ (i,j) $
smallalpha: Smallest $ alpha $ angle.
highalpha: Highest $ alpha $ angle.
color: Color used to display th lines.

Definition at line 1228 of file vpMeEllipse.cpp.

References vpColor::blue, vpDisplay::displayCross(), vpDisplay::displayLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpMath::rad(), vpColor::red, vpImagePoint::set_i(), and vpImagePoint::set_j().

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,
vpColor  color = vpColor::green 
)
static

Display of the ellipse thanks to the equation parameters.

Parameters
I: The image used as background.
center: Center of the ellipse
A: Semiminor axis of the ellipse.
B: Semimajor axis of the ellipse.
E: Angle made by the major axis and the i axis of the image frame $ (i,j) $
smallalpha: Smallest $ alpha $ angle.
highalpha: Highest $ alpha $ angle.
color: Color used to display th lines.

Definition at line 1305 of file vpMeEllipse.cpp.

References vpColor::blue, vpDisplay::displayCross(), vpDisplay::displayLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpMath::rad(), vpColor::red, vpImagePoint::set_i(), and vpImagePoint::set_j().

double vpMeEllipse::get_m00 ( ) const
inline

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

Returns
the value of $ m_{00} $.

Definition at line 187 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

double vpMeEllipse::get_m01 ( ) const
inline

Gets the 1 order raw moment $ m_{01} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.

Returns
the value of $ m_{01} $.

Definition at line 201 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

double vpMeEllipse::get_m02 ( ) const
inline

Gets the 2 order raw moment $ m_{02} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.

Returns
the value of $ m_{11} $.

Definition at line 222 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

double vpMeEllipse::get_m10 ( ) const
inline

Gets the 1 order raw moment $ m_{10} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.

Returns
the value of $ m_{10} $.

Definition at line 194 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

double vpMeEllipse::get_m11 ( ) const
inline

Gets the 2 order raw moment $ m_{11} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.

Returns
the value of $ m_{11} $.

Definition at line 208 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

double vpMeEllipse::get_m20 ( ) const
inline

Gets the 2 order raw moment $ m_{20} $ with $ m_{nm} = \sum_{i,j}i^n j^m $.

Returns
the value of $ m_{11} $.

Definition at line 215 of file vpMeEllipse.h.

Referenced by vpFeatureBuilder::create().

double vpMeEllipse::get_mu02 ( ) const
inline

Gets the 2 order central moment $ \mu_{02} $.

Returns
the value of $ \mu_{02} $.

Definition at line 236 of file vpMeEllipse.h.

double vpMeEllipse::get_mu11 ( ) const
inline

Gets the 2 order central moment $ \mu_{11} $.

Returns
the value of $ \mu_{11} $.

Definition at line 229 of file vpMeEllipse.h.

double vpMeEllipse::get_mu20 ( ) const
inline

Gets the 2 order central moment $ \mu_{20} $.

Returns
the value of $ \mu_{20} $.

Definition at line 243 of file vpMeEllipse.h.

double vpMeEllipse::getA ( ) const
inline

Gets the semiminor axis of the ellipse.

Definition at line 253 of file vpMeEllipse.h.

double vpMeEllipse::getB ( ) const
inline

Gets the semimajor axis of the ellipse.

Definition at line 258 of file vpMeEllipse.h.

vpImagePoint vpMeEllipse::getCenter ( ) const
inline

Gets the center of the ellipse.

Definition at line 248 of file vpMeEllipse.h.

double vpMeEllipse::getE ( ) const
inline

Gets the angle made by the major axis and the i axis of the image frame $ (i,j) $

Definition at line 263 of file vpMeEllipse.h.

void vpMeEllipse::getEquationParam ( double &  A,
double &  B,
double &  E 
)
inline

Gets the equation parameters of the ellipse

Definition at line 268 of file vpMeEllipse.h.

double vpMeEllipse::getHighestAngle ( )
inline

Gets the highest $ alpha $ angle

Definition at line 278 of file vpMeEllipse.h.

unsigned int vpMeTracker::getInitRange ( )
inlineinherited

Return the initial range.

Returns
Value of init_range.

Definition at line 133 of file vpMeTracker.h.

vpMe* vpMeTracker::getMe ( )
inlineinherited

Return the moving edges initialisation parameters

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

Definition at line 147 of file vpMeTracker.h.

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

Definition at line 162 of file vpMeTracker.h.

int vpMeTracker::getNbPoints ( ) const
inlineinherited

Return the number of points that has not been suppressed.

Returns
Number of good points.

Definition at line 169 of file vpMeTracker.h.

double vpMeEllipse::getSmallestAngle ( )
inline

Gets the smallest $ alpha $ angle

Definition at line 273 of file vpMeEllipse.h.

void vpMeTracker::init ( void  )
inherited
void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I)

Initilization of the tracking. Ask the user to click on five points from the ellipse edge to track.

Parameters
I: Image in which the ellipse appears.
Examples:
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 800 of file vpMeEllipse.cpp.

References vpDisplay::displayCross(), vpDisplay::flush(), vpDisplay::getClick(), iP1, iP2, vpColor::red, and vpCDEBUG.

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
const unsigned int  n,
vpImagePoint iP 
)

Initialization of the tracking. The ellipse is defined thanks to the coordinates of n points.

Warning
It is better to use at least five points to well estimate the K parameters.
Parameters
I: Image in which the ellipse appears.
n: The number of points in the list.
iP: A pointer to a list of pointsbelonging to the ellipse edge.

i^2 + K0 j^2 + 2 K1 i j + 2 K2 i + 2 K3 j + K4

Definition at line 835 of file vpMeEllipse.cpp.

References vpMeTracker::display(), display(), e, vpDisplay::flush(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpColor::green, vpMeTracker::initTracking(), iP1, iP2, vpMatrix::pseudoInverse(), vpMath::sqr(), track(), vpCDEBUG, and vpERROR_TRACE.

void vpMeEllipse::initTracking ( const vpImage< unsigned char > &  I,
const unsigned int  n,
unsigned *  i,
unsigned *  j 
)
unsigned int vpMeTracker::numberOfSignal ( )
inherited
int vpMeTracker::outOfImage ( int  i,
int  j,
int  half,
int  rows,
int  cols 
)
inherited
int vpMeTracker::outOfImage ( vpImagePoint  iP,
int  half,
int  rows,
int  cols 
)
inherited

Definition at line 144 of file vpMeTracker.cpp.

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

void vpMeEllipse::printParameters ( )

Print the parameters $ K = {K_0, ..., K_4} $ and the coordinates of the ellipse center.

Definition at line 336 of file vpMeEllipse.cpp.

References iPc.

void vpMeEllipse::setCircle ( bool  is_circle)
inline

Set to true if you are sure to track a circle.

Warning
During all the tracking, the shape must be approximatively a circle and not an ellipse with a strong difference between the majoraxis and the minoraxis.

In that case, the set of points $ (i,j) $ satisfy the implicit equation :

\[ i^2 + j^2 + 2K_2i + 2K_3j + K4 = 0 \]

Compared to the classical equation of an ellipse, $ K_0 $ is equal to 1 and $ K_1 $ is equal to 0.

Parameters
is_circle: Set to true if you want to track a circle.
Examples:
trackMeCircle.cpp.

Definition at line 180 of file vpMeEllipse.h.

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

Set the initial range.

Parameters
r: initial range.

Definition at line 126 of file vpMeTracker.h.

Referenced by vpMbtDistanceLine::initMovingEdge(), and vpMbtDistanceCylinder::initMovingEdge().

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

Set the list of moving edges

Parameters
l: list of Moving Edges.

Definition at line 154 of file vpMeTracker.h.

void vpMeEllipse::setThresholdRobust ( const double  threshold)
inline

Set the new threshold for the robust estimation of the parameters of the ellipse equation. 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 289 of file vpMeEllipse.h.

unsigned int vpMeTracker::totalNumberOfSignal ( )
inherited

Definition at line 128 of file vpMeTracker.cpp.

References vpMeTracker::list.

void vpMeEllipse::track ( const vpImage< unsigned char > &  I)

Track the ellipse in the image I.

Parameters
I: Image in which the ellipse appears.
Examples:
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 923 of file vpMeEllipse.cpp.

References vpMeTracker::display(), display(), vpDisplay::flush(), vpColor::red, vpMeTracker::track(), vpCDEBUG, vpDEBUG_ENABLE, and vpERROR_TRACE.

Referenced by initTracking().

Member Data Documentation

double vpMeEllipse::a

$ a $ is the semiminor axis of the ellipse.

Definition at line 313 of file vpMeEllipse.h.

Referenced by display(), and vpMeEllipse().

double vpMeEllipse::alpha1
protected

The smallest $ alpha $ angle.

Definition at line 325 of file vpMeEllipse.h.

Referenced by display(), and vpMeEllipse().

double vpMeEllipse::alpha2
protected

The highest $ alpha $ angle.

Definition at line 327 of file vpMeEllipse.h.

Referenced by display(), and vpMeEllipse().

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

Stores the value of the $ alpha $ angle for each vpMeSite.

Definition at line 333 of file vpMeEllipse.h.

Referenced by vpMeEllipse(), and ~vpMeEllipse().

double vpMeEllipse::b

$ b $ is the semimajor axis of the ellipse.

Definition at line 315 of file vpMeEllipse.h.

Referenced by display(), and vpMeEllipse().

double vpMeEllipse::ce
protected

Value of cos(e).

Definition at line 329 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

bool vpTracker::cPAvailable
inherited

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

Definition at line 88 of file vpTracker.h.

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

bool vpMeTracker::display_point
inherited

Definition at line 174 of file vpMeTracker.h.

Referenced by vpMeTracker::vpMeTracker().

double vpMeEllipse::e

$ e $ is the angle made by the major axis and the i axis of the image frame $ (i,j) $.

Definition at line 317 of file vpMeEllipse.h.

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

unsigned int vpMeTracker::init_range
inherited

Definition at line 83 of file vpMeTracker.h.

Referenced by vpMeTracker::initTracking(), and vpMeTracker::vpMeTracker().

vpImagePoint vpMeEllipse::iP1
protected

The coordinates of the point corresponding to the smallest $ alpha $ angle. More things about the $ alpha $ are given at the beginning of the class description.

Definition at line 321 of file vpMeEllipse.h.

Referenced by initTracking(), and vpMeEllipse().

vpImagePoint vpMeEllipse::iP2
protected

The coordinates of the point corresponding to the highest $ alpha $ angle. More things about the $ alpha $ are given at the beginning of the class description.

Definition at line 323 of file vpMeEllipse.h.

Referenced by initTracking(), and vpMeEllipse().

vpImagePoint vpMeEllipse::iPc

The coordinates of the ellipse center.

Definition at line 311 of file vpMeEllipse.h.

Referenced by display(), printParameters(), and vpMeEllipse().

vpColVector vpMeEllipse::K

Parameters of the ellipse to define the set of points that satisfy the implicit equation :

\[ i^2 + K_0j^2 + 2K_1ij + 2K_2i + 2K_3j + K4 = 0 \]

Definition at line 309 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::m00
protected

Surface.

Definition at line 335 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::m01
protected

Definition at line 339 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::m02
protected

Definition at line 341 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::m10
protected

First order raw moments.

Definition at line 339 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::m11
protected

Second order raw moments.

Definition at line 341 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::m20
protected

Definition at line 341 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

vpMe* vpMeTracker::me
inherited
double vpMeEllipse::mu02
protected

Definition at line 337 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::mu11
protected

Second order central moments.

Definition at line 337 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::mu20
protected

Definition at line 337 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

int vpMeTracker::nGoodElement
inherited
int vpMeTracker::query_range
inherited

Definition at line 173 of file vpMeTracker.h.

Referenced by vpMeTracker::vpMeTracker().

double vpMeEllipse::se
protected

Value of sin(e).

Definition at line 331 of file vpMeEllipse.h.

Referenced by vpMeEllipse().

double vpMeEllipse::thresholdWeight
protected

Threshold for the robust least square.

Definition at line 343 of file vpMeEllipse.h.

Referenced by vpMeEllipse().