ViSP  2.10.0

#include <vpMeLine.h>

+ Inheritance diagram for vpMeLine:

Public Member Functions

 vpMeLine ()
 
 vpMeLine (const vpMeLine &meline)
 
virtual ~vpMeLine ()
 
void display (const vpImage< unsigned char > &I, vpColor col)
 
void track (const vpImage< unsigned char > &Im)
 
void sample (const vpImage< unsigned char > &image)
 
void reSample (const vpImage< unsigned char > &I)
 
void leastSquare ()
 
void updateDelta ()
 
void setExtremities ()
 
void seekExtremities (const vpImage< unsigned char > &I)
 
void suppressPoints ()
 
void initTracking (const vpImage< unsigned char > &I)
 
void initTracking (const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2)
 
void computeRhoTheta (const vpImage< unsigned char > &I)
 
double getRho () const
 
double getTheta () const
 
void getExtremities (vpImagePoint &ip1, vpImagePoint &ip2)
 
void getEquationParam (double &A, double &B, double &C)
 
double getA () const
 
double getB () const
 
double getC () const
 
void computeRhoSignFromIntensity (const bool useIntensityForRho)
 
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 reset ()
 
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 bool intersection (const vpMeLine &line1, const vpMeLine &line2, vpImagePoint &ip)
 
static void display (const vpImage< unsigned char > &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A, const double &B, const double &C, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
static void display (const vpImage< vpRGBa > &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const double &A, const double &B, const double &C, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
static void display (const vpImage< unsigned char > &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const std::list< vpMeSite > &site_list, const double &A, const double &B, const double &C, const vpColor &color=vpColor::green, unsigned int thickness=1)
 
static void display (const vpImage< vpRGBa > &I, const vpMeSite &PExt1, const vpMeSite &PExt2, const std::list< vpMeSite > &site_list, const double &A, const double &B, const double &C, const vpColor &color=vpColor::green, unsigned int thickness=1)
 

Public Attributes

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

Protected Attributes

vpMeSite PExt [2]
 
double rho
 
double theta
 
double delta
 
double delta_1
 
double angle
 
double angle_1
 
int sign
 
bool _useIntensityForRho
 
vpMeSite::vpMeSiteDisplayType selectDisplay
 

Detailed Description

Class that tracks in an image a line moving edges.

In this class the line is defined by its equation in the $ (i,j) = (line,column) $ image plane. Two kinds of parametrization are available to describe a 2D line. The first one corresponds to the following equation

\[ ai + bj + c = 0 \]

where $ i $ and $ j $ are the coordinates of the points belonging to the line. The line features are $ (a, b, c) $.

The second way to write the line equation is to consider polar coordinates

\[ i \; cos(\theta) + j \; sin(\theta) - \rho = 0 \]

where $ i $ and $ j $ are still the coordinates of the points belonging to the line. But now the line features are $ (\rho, \theta) $. The computation of $ \rho $ and $ \theta $ is easy thanks to $ (a, b, c) $.

\[ \theta = arctan(b/a) \]

\[ \rho = -c/\sqrt{a^2+b^2} \]

The value of $ \theta $ is between $ 0 $ and $ 2\pi $. And the value of $ \rho $ can be positive or negative. The conventions to find the right values of the two features are illustrated in the following pictures.

vpMeLine.gif

The angle $\theta$ is computed thanks to the direction of the arrow. The arrow points to the side of the line which is darker.

The example below available in tutorial-me-line-tracker.cpp and described in Tutorial: Moving-edges 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/vpDisplayOpenCV.h>
#include <visp/vpDisplayX.h>
#include <visp/vpMeLine.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");
#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);
vpMeLine line;
line.setMe(&me);
line.initTracking(I);
while(1) {
g.acquire(I);
line.track(I);
}
}
catch(vpException e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#endif
}
Examples:
servoAfma62DhalfCamVelocity.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6Line2DCamVelocity.cpp, servoAfma6SquareLines2DCamVelocity.cpp, servoAfma6TwoLines2DCamVelocity.cpp, trackMeLine.cpp, and tutorial-me-line-tracker.cpp.

Definition at line 156 of file vpMeLine.h.

Constructor & Destructor Documentation

vpMeLine::vpMeLine ( )

Basic constructor that calls the constructor of the class vpMeTracker.

Definition at line 108 of file vpMeLine.cpp.

vpMeLine::vpMeLine ( const vpMeLine meline)

Copy constructor.

Definition at line 118 of file vpMeLine.cpp.

References _useIntensityForRho, a, angle, angle_1, b, c, delta, delta_1, PExt, rho, sign, and theta.

vpMeLine::~vpMeLine ( )
virtual

Basic destructor.

Definition at line 145 of file vpMeLine.cpp.

References vpMeTracker::list.

Member Function Documentation

void vpMeLine::computeRhoSignFromIntensity ( const bool  useIntensityForRho)
inline

This method allows to turn off the computation of the sign of the rho attribute based on the intensity near the middle point of the line. This is usually done to distinguish between a black/white and a white/black edge but it may be source of problem (ex. for a servoing example) when this point can be occluded.

Parameters
useIntensityForRho: new value of the flag.

Definition at line 241 of file vpMeLine.h.

void vpMeLine::computeRhoTheta ( const vpImage< unsigned char > &  I)
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 vpMeEllipse.

Definition at line 335 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 356 of file vpMeTracker.cpp.

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

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

Display line.

Warning
To effectively display the line a call to vpDisplay::flush() is needed.
Parameters
I: Image in which the line appears.
col: Color of the displayed line. Note that a moving edge that is considered as an outlier is displayed in green.

Implements vpMeTracker.

Examples:
servoAfma62DhalfCamVelocity.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6Line2DCamVelocity.cpp, servoAfma6SquareLines2DCamVelocity.cpp, servoAfma6TwoLines2DCamVelocity.cpp, trackMeLine.cpp, and tutorial-me-line-tracker.cpp.

Definition at line 245 of file vpMeLine.cpp.

References vpMeTracker::list, and PExt.

Referenced by track().

void vpMeLine::display ( const vpImage< unsigned char > &  I,
const vpMeSite PExt1,
const vpMeSite PExt2,
const double &  A,
const double &  B,
const double &  C,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
static

Display of a moving line thanks to its equation parameters and its extremities.

Parameters
I: The image used as background.
PExt1: First extrimity
PExt2: Second extrimity
A: Parameter a of the line equation a*i + b*j + c = 0
B: Parameter b of the line equation a*i + b*j + c = 0
C: Parameter c of the line equation a*i + b*j + c = 0
color: Color used to display the line.
thickness: Thickness of the line.

Definition at line 1178 of file vpMeLine.cpp.

References vpDisplay::displayCross(), vpDisplay::displayLine(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpColor::green, vpMeSite::ifloat, vpMeSite::jfloat, vpImagePoint::set_i(), and vpImagePoint::set_j().

void vpMeLine::display ( const vpImage< vpRGBa > &  I,
const vpMeSite PExt1,
const vpMeSite PExt2,
const double &  A,
const double &  B,
const double &  C,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
static

Display of a moving line thanks to its equation parameters and its extremities.

Parameters
I: The image used as background.
PExt1: First extrimity
PExt2: Second extrimity
A: Parameter a of the line equation a*i + b*j + c = 0
B: Parameter b of the line equation a*i + b*j + c = 0
C: Parameter c of the line equation a*i + b*j + c = 0
color: Color used to display the line.
thickness: Thickness of the line.

Definition at line 1242 of file vpMeLine.cpp.

References vpDisplay::displayCross(), vpDisplay::displayLine(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpColor::green, vpMeSite::ifloat, vpMeSite::jfloat, vpImagePoint::set_i(), and vpImagePoint::set_j().

void vpMeLine::display ( const vpImage< unsigned char > &  I,
const vpMeSite PExt1,
const vpMeSite PExt2,
const std::list< vpMeSite > &  site_list,
const double &  A,
const double &  B,
const double &  C,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
static

Display of a moving line thanks to its equation parameters and its extremities with all the site list.

Parameters
I: The image used as background.
PExt1: First extrimity
PExt2: Second extrimity
site_list: vpMeSite list
A: Parameter a of the line equation a*i + b*j + c = 0
B: Parameter b of the line equation a*i + b*j + c = 0
C: Parameter c of the line equation a*i + b*j + c = 0
color: Color used to display the line.
thickness: Thickness of the line.

Definition at line 1308 of file vpMeLine.cpp.

References vpDisplay::displayCross(), vpDisplay::displayLine(), vpImage< Type >::getHeight(), vpMeSite::getState(), vpImage< Type >::getWidth(), vpColor::green, vpMeSite::ifloat, vpMeSite::jfloat, vpMeSite::M_ESTIMATOR, vpImagePoint::set_i(), and vpImagePoint::set_j().

void vpMeLine::display ( const vpImage< vpRGBa > &  I,
const vpMeSite PExt1,
const vpMeSite PExt2,
const std::list< vpMeSite > &  site_list,
const double &  A,
const double &  B,
const double &  C,
const vpColor color = vpColor::green,
unsigned int  thickness = 1 
)
static

Display of a moving line thanks to its equation parameters and its extremities with all the site list.

Parameters
I: The image used as background.
PExt1: First extrimity
PExt2: Second extrimity
site_list: vpMeSite list
A: Parameter a of the line equation a*i + b*j + c = 0
B: Parameter b of the line equation a*i + b*j + c = 0
C: Parameter c of the line equation a*i + b*j + c = 0
color: Color used to display the line.
thickness: Thickness of the line.

Definition at line 1390 of file vpMeLine.cpp.

References vpDisplay::displayCross(), vpDisplay::displayLine(), vpImage< Type >::getHeight(), vpMeSite::getState(), vpImage< Type >::getWidth(), vpColor::green, vpMeSite::ifloat, vpMeSite::jfloat, vpMeSite::M_ESTIMATOR, vpImagePoint::set_i(), and vpImagePoint::set_j().

double vpMeLine::getA ( ) const
inline

Gets parameter a of the line equation a*i + b*j + c = 0

Definition at line 217 of file vpMeLine.h.

double vpMeLine::getB ( ) const
inline

Gets parameter b of the line equation a*i + b*j + c = 0

Definition at line 222 of file vpMeLine.h.

double vpMeLine::getC ( ) const
inline

Gets parameter c of the line equation a*i + b*j + c = 0

Definition at line 227 of file vpMeLine.h.

void vpMeLine::getEquationParam ( double &  A,
double &  B,
double &  C 
)
inline

Gets the equation parameters of the line

Definition at line 212 of file vpMeLine.h.

void vpMeLine::getExtremities ( vpImagePoint ip1,
vpImagePoint ip2 
)

Get the extremities of the line.

Parameters
ip1: Coordinates of the first extremity.
ip2: Coordinates of the second extremity.

Definition at line 1074 of file vpMeLine.cpp.

References PExt, vpImagePoint::set_i(), and vpImagePoint::set_j().

unsigned int vpMeTracker::getInitRange ( )
inlineinherited

Return the initial range.

Returns
Value of init_range.

Definition at line 135 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 149 of file vpMeTracker.h.

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

Return the list of moving edges

Returns
List of Moving Edges.

Definition at line 163 of file vpMeTracker.h.

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

Definition at line 164 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 171 of file vpMeTracker.h.

double vpMeLine::getRho ( ) const

Get the value of $\rho$, the distance between the origin and the point on the line with belong to the normal to the line crossing the origin.

Depending on the convention described at the beginning of this class, $\rho$ is signed.

Examples:
trackMeLine.cpp.

Definition at line 1052 of file vpMeLine.cpp.

References rho.

Referenced by vpFeatureBuilder::create().

double vpMeLine::getTheta ( ) const

Get the value of the angle $\theta$.

Examples:
trackMeLine.cpp.

Definition at line 1061 of file vpMeLine.cpp.

References theta.

Referenced by vpFeatureBuilder::create().

void vpMeTracker::init ( void  )
inherited
void vpMeLine::initTracking ( const vpImage< unsigned char > &  I)
void vpMeLine::initTracking ( const vpImage< unsigned char > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2 
)

Initialization of the tracking. The line is defined thanks to the coordinates of two points.

Parameters
I: Image in which the line appears.
ip1: Coordinates of the first point.
ip2: Coordinates of the second point.

Definition at line 468 of file vpMeLine.cpp.

References delta, delta_1, vpImagePoint::get_i(), vpImagePoint::get_j(), vpMeSite::ifloat, vpMeTracker::initTracking(), vpMeSite::jfloat, PExt, vpMath::round(), sample(), track(), vpCDEBUG, and vpERROR_TRACE.

bool vpMeLine::intersection ( const vpMeLine line1,
const vpMeLine line2,
vpImagePoint ip 
)
static

Computes the intersection point of two lines. The result is given in the (i,j) frame.

Parameters
line1: The first line.
line2: The second line.
ip: The coordinates of the intersection point.
Returns
Returns a boolean value which depends on the computation success. True means that the computation ends successfully.
Examples:
servoAfma62DhalfCamVelocity.cpp.

Definition at line 1097 of file vpMeLine.cpp.

References a, b, c, vpImagePoint::set_i(), and vpImagePoint::set_j().

void vpMeLine::leastSquare ( )
unsigned int vpMeTracker::numberOfSignal ( )
inherited

Definition at line 127 of file vpMeTracker.cpp.

References vpMeTracker::list.

Referenced by leastSquare(), vpMeNurbs::localReSample(), reSample(), and vpMeNurbs::reSample().

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

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

void vpMeLine::reSample ( const vpImage< unsigned char > &  I)

Resample the line if the number of sample is less than 80% of the expected value.

Note
The expected value is computed thanks to the length of the line and the parameter which indicates the number of pixel between two points (vpMe::sample_step).
Parameters
I: Image in which the line appears.

Definition at line 732 of file vpMeLine.cpp.

References delta, delta_1, vpMe::getSampleStep(), vpMeSite::ifloat, vpTrackingException::initializationError, vpMeTracker::initTracking(), vpMeSite::jfloat, vpMeTracker::me, vpMeTracker::numberOfSignal(), PExt, sample(), vpMath::sqr(), and vpDERROR_TRACE.

Referenced by track().

void vpMeTracker::reset ( )
inherited

Reset the tracker by removing all the moving edges.

Definition at line 101 of file vpMeTracker.cpp.

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

Referenced by vpMeTracker::~vpMeTracker().

void vpMeLine::sample ( const vpImage< unsigned char > &  I)
virtual
void vpMeLine::setExtremities ( )

Seek in the list of available points the two extremities of the line.

Definition at line 544 of file vpMeLine.cpp.

References vpMeSite::ifloat, vpMeSite::jfloat, vpMeTracker::list, and PExt.

Referenced by track().

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

Set the initial range.

Parameters
r: initial range.

Definition at line 128 of file vpMeTracker.h.

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

Set the list of moving edges

Parameters
l: list of Moving Edges.

Definition at line 156 of file vpMeTracker.h.

void vpMeLine::suppressPoints ( )

Suppression of the points which belong no more to the line.

Definition at line 526 of file vpMeLine.cpp.

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

Referenced by track().

unsigned int vpMeTracker::totalNumberOfSignal ( )
inherited

Definition at line 137 of file vpMeTracker.cpp.

References vpMeTracker::list.

void vpMeLine::updateDelta ( )

Set the alpha value of the different vpMeSite to the value of delta.

Definition at line 774 of file vpMeLine.cpp.

References vpMeSite::alpha, angle_1, delta, delta_1, vpMeTracker::list, vpMeSite::mask_sign, vpMath::round(), and sign.

Referenced by track().

Member Data Documentation

bool vpMeLine::_useIntensityForRho
protected

Flag to specify wether the intensity of the image at the middle point is used to compute the sign of rho or not.

Definition at line 170 of file vpMeLine.h.

Referenced by computeRhoTheta(), and vpMeLine().

double vpMeLine::a

Parameter a of the line equation a*i + b*j + c = 0.

Definition at line 178 of file vpMeLine.h.

Referenced by intersection(), and vpMeLine().

double vpMeLine::angle
protected

Definition at line 166 of file vpMeLine.h.

Referenced by vpMeLine().

double vpMeLine::angle_1
protected

Definition at line 166 of file vpMeLine.h.

Referenced by updateDelta(), and vpMeLine().

double vpMeLine::b

Parameter b of the line equation a*i + b*j + c = 0.

Definition at line 179 of file vpMeLine.h.

Referenced by computeRhoTheta(), intersection(), and vpMeLine().

double vpMeLine::c

Parameter c of the line equation a*i + b*j + c = 0.

Definition at line 180 of file vpMeLine.h.

Referenced by intersection(), and vpMeLine().

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=().

double vpMeLine::delta
protected

Definition at line 165 of file vpMeLine.h.

Referenced by initTracking(), reSample(), updateDelta(), and vpMeLine().

double vpMeLine::delta_1
protected

Definition at line 165 of file vpMeLine.h.

Referenced by initTracking(), reSample(), seekExtremities(), updateDelta(), and vpMeLine().

bool vpMeTracker::display_point
inherited

Definition at line 176 of file vpMeTracker.h.

Referenced by vpMeTracker::vpMeTracker().

unsigned int vpMeTracker::init_range
inherited

Definition at line 83 of file vpMeTracker.h.

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

vpMe* vpMeTracker::me
inherited
int vpMeTracker::nGoodElement
inherited
vpMeSite vpMeLine::PExt[2]
protected
int vpMeTracker::query_range
inherited

Definition at line 175 of file vpMeTracker.h.

Referenced by vpMeTracker::vpMeTracker().

double vpMeLine::rho
protected

Definition at line 164 of file vpMeLine.h.

Referenced by computeRhoTheta(), getRho(), and vpMeLine().

int vpMeLine::sign
protected

Definition at line 167 of file vpMeLine.h.

Referenced by sample(), seekExtremities(), updateDelta(), and vpMeLine().

double vpMeLine::theta
protected

Definition at line 164 of file vpMeLine.h.

Referenced by getTheta(), and vpMeLine().