ViSP  2.8.0

#include <vpMeNurbs.h>

+ Inheritance diagram for vpMeNurbs:

Public Member Functions

 vpMeNurbs ()
 
 vpMeNurbs (const vpMeNurbs &menurbs)
 
virtual ~vpMeNurbs ()
 
void setNbControlPoints (const unsigned int nbControlPoints)
 
void setEnableCannyDetection (const bool enableCannyDetection)
 
void setCannyThreshold (const double th1, const double th2)
 
void initTracking (const vpImage< unsigned char > &I)
 
void initTracking (const vpImage< unsigned char > &I, const std::list< vpImagePoint > &ptList)
 
void track (const vpImage< unsigned char > &Im)
 
void sample (const vpImage< unsigned char > &image)
 
void reSample (const vpImage< unsigned char > &I)
 
void updateDelta ()
 
void setExtremities ()
 
void seekExtremities (const vpImage< unsigned char > &I)
 
void seekExtremitiesCanny (const vpImage< unsigned char > &I)
 
void suppressPoints ()
 
void supressNearPoints ()
 
void localReSample (const vpImage< unsigned char > &I)
 
vpNurbs getNurbs () const
 
void display (const vpImage< unsigned char > &I, vpColor col)
 
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 *me)
 
vpMegetMe ()
 
void setMeList (const std::list< vpMeSite > &l)
 
std::list< vpMeSite > & getMeList ()
 
std::list< vpMeSitegetMeList () const
 
int getNbPoints () const
 

Public Attributes

vpNurbs nurbs
 
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::vpMeSiteDisplayType selectDisplay
 

Deprecated functions

vp_deprecated void initTracking (const vpImage< unsigned char > &I, vpList< vpImagePoint > &ptList)
 
static void display (const vpImage< unsigned char > &I, vpNurbs &n, vpColor color=vpColor::green)
 
static void display (const vpImage< vpRGBa > &I, vpNurbs &n, vpColor color=vpColor::green)
 

Detailed Description

Class that tracks in an image a edge defined by a Nurbs.

The advantage of this class is that it enables to track an edge whose equation is not known in advance. At each iteration, the Nurbs corresponding to the edge is computed.

It is possible to have a direct access to the nurbs. It is indeed a public parameter.

The code below shows how to use this class.

#include <visp/vpImage.h>
#include <visp/vpMeNurbs.h>
#include <visp/vpImagePoint.h>
int main()
{
// Fill the image with a black rectangle
I = 0;
for (int i = 100; i < 180; i ++) {
for (int j = 0; j < 320; j ++) {
I[i][j] = 255;
}
}
// Set the moving-edges tracker parameters
me.setRange(25);
me.setThreshold(15000);
me.setSampleStep(10);
// Initialize the moving-edges tracker parameters
vpMeNurbs meNurbs;
meNurbs.setNbControlPoints(4);
meNurbs.setMe(&me);
// Initialize the location of the edge to track (here a horizontal line
std::list<vpImagePoint> ipList; //List of points belonginig to the edge
ipList.push_back(vpImagePoint(110,119));
ipList.push_back(vpImagePoint(140,119));
ipList.push_back(vpImagePoint(160,119));
ipList.push_back(vpImagePoint(170,119));
meNurbs.initTracking(I, ipList);
while ( 1 )
{
// ... Here the code to read or grab the next image.
// Track the line.
meNurbs.track(I);
}
return 0;
}
Note
It is possible to display the nurbs as an overlay. For that you must use the display function of the class vpMeNurbs.
In case of an edge which is not smooth, it can be interesting to use the canny detection to find the extremities. In this case, use the method setEnableCannyDetection to enable it. Warning : This function requires OpenCV.
Examples:
trackMeNurbs.cpp.

Definition at line 129 of file vpMeNurbs.h.

Constructor & Destructor Documentation

vpMeNurbs::vpMeNurbs ( )

Basic constructor that calls the constructor of the class vpMeTracker.

Definition at line 223 of file vpMeNurbs.cpp.

vpMeNurbs::vpMeNurbs ( const vpMeNurbs menurbs)

Copy constructor.

Definition at line 236 of file vpMeNurbs.cpp.

References nurbs.

vpMeNurbs::~vpMeNurbs ( )
virtual

Basic destructor.

Definition at line 251 of file vpMeNurbs.cpp.

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

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

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

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

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

Display edge.

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

Implements vpMeTracker.

Examples:
trackMeNurbs.cpp.

Definition at line 1102 of file vpMeNurbs.cpp.

References nurbs.

void vpMeNurbs::display ( const vpImage< unsigned char > &  I,
vpNurbs n,
vpColor  color = vpColor::green 
)
static

Display of a moving nurbs.

Parameters
I: The image used as background.
n: Nurbs to display
color: Color used to display the nurbs.

Definition at line 1347 of file vpMeNurbs.cpp.

References vpNurbs::computeCurvePoint(), and vpDisplay::displayCross().

void vpMeNurbs::display ( const vpImage< vpRGBa > &  I,
vpNurbs n,
vpColor  color = vpColor::green 
)
static

Display of a moving nurbs.

Parameters
I: The image used as background.
n: Nurbs to display
color: Color used to display the nurbs.

Definition at line 1369 of file vpMeNurbs.cpp.

References vpNurbs::computeCurvePoint(), and vpDisplay::displayCross().

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.

vpNurbs vpMeNurbs::getNurbs ( ) const
inline

Gets the nurbs;

Definition at line 206 of file vpMeNurbs.h.

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

Initialization of the tracking. Ask the user to click left on several points along the edge to track and click right at the end.

Parameters
I: Image in which the edge appears.
Examples:
trackMeNurbs.cpp.

Definition at line 263 of file vpMeNurbs.cpp.

References vpMouseButton::button1, vpMouseButton::button3, vpDisplay::displayCross(), vpDisplay::flush(), vpDisplay::getClick(), vpColor::green, and vpException::notInitialized.

void vpMeNurbs::initTracking ( const vpImage< unsigned char > &  I,
const std::list< vpImagePoint > &  ptList 
)

Initialization of the tracking. The Nurbs is initialized thanks to the list of vpImagePoint.

Parameters
I: Image in which the edge appears.
ptList: List of point to initialize the Nurbs.

Definition at line 322 of file vpMeNurbs.cpp.

References vpNurbs::globalCurveInterp(), vpMeTracker::initTracking(), nurbs, sample(), and track().

vp_deprecated void vpMeNurbs::initTracking ( const vpImage< unsigned char > &  I,
vpList< vpImagePoint > &  ptList 
)
Deprecated:
You should use initTracking(const vpImage<unsigned char> &, const std::list<vpImagePoint> &) instead.

Initialization of the tracking. The Nurbs is initialized thanks to the list of vpImagePoint.

Parameters
I: Image in which the edge appears.
ptList: List of point to initialize the Nurbs.

Definition at line 298 of file vpMeNurbs.cpp.

References vpList< type >::front(), vpNurbs::globalCurveInterp(), vpMeTracker::initTracking(), vpList< type >::next(), nurbs, vpList< type >::outside(), sample(), track(), and vpList< type >::value().

unsigned int vpMeTracker::numberOfSignal ( )
inherited

Definition at line 117 of file vpMeTracker.cpp.

References vpMeTracker::list.

Referenced by vpMeLine::leastSquare(), localReSample(), vpMeLine::reSample(), and 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 143 of file vpMeTracker.cpp.

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

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

Resample the edge if the number of sample is less than 70% of the expected value.

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

Definition at line 872 of file vpMeNurbs.cpp.

References vpMe::getSampleStep(), vpMeTracker::initTracking(), vpMeTracker::numberOfSignal(), and sample().

Referenced by track().

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

Construct a list of vpMeSite moving edges at a particular sampling step between the two extremities of the nurbs.

Parameters
I: Image in which the edge appears.

Implements vpMeTracker.

Definition at line 340 of file vpMeNurbs.cpp.

References vpNurbs::computeCurveDersPoint(), vpImage< Type >::getHeight(), vpMe::getPointsToTrack(), vpMe::getSampleStep(), vpImage< Type >::getWidth(), vpMeSite::init(), vpMeTracker::list, nurbs, vpMeTracker::outOfImage(), vpMeTracker::selectDisplay, vpMeSite::setDisplay(), vpMath::sqr(), and vpImagePoint::sqrDistance().

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

void vpMeNurbs::seekExtremities ( const vpImage< unsigned char > &  I)
void vpMeNurbs::seekExtremitiesCanny ( const vpImage< unsigned char > &  I)

Seek the extremities of the edge thanks to a canny edge detection. The edge detection enable to find the points belonging to the edge. The any vpMesite are initialize at this points.

This method is practicle when the edge is not smooth.

Note
To use the canny detection, OpenCV has to be installed.
Parameters
I: Image in which the edge appears.

Definition at line 572 of file vpMeNurbs.cpp.

References vpImageConvert::convert(), vpImageTools::createSubImage(), vpDisplay::displayPoint(), vpDisplay::displayRectangle(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImage< Type >::getHeight(), vpMe::getRange(), vpMe::getSampleStep(), vpImage< Type >::getWidth(), vpColor::green, vpMeSite::ifloat, vpMeSite::init(), vpMeSite::jfloat, vpMath::maximum(), vpColor::orange, vpMeSite::setDisplay(), vpMe::setRange(), vpMath::sqr(), vpMeSite::sqrDistance(), vpMeSite::track(), and vpTRACE.

Referenced by track().

void vpMeNurbs::setCannyThreshold ( const double  th1,
const double  th2 
)
inline

Enables to set the two thresholds use by the canny detection.

Parameters
th1: The first threshold;
th2: The second threshold;

Definition at line 180 of file vpMeNurbs.h.

void vpMeNurbs::setEnableCannyDetection ( const bool  enableCannyDetection)
inline

Enables or disables the canny detection used during the extremities search.

Parameters
enableCannyDetection: if true it enables the canny detection.

Definition at line 172 of file vpMeNurbs.h.

void vpMeNurbs::setExtremities ( )
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 vpMeNurbs::setNbControlPoints ( const unsigned int  nbControlPoints)
inline

Sets the number of control points used to compute the Nurbs.

Parameters
nbControlPoints: The number of control points used to compute the Nurbs.
Examples:
trackMeNurbs.cpp.

Definition at line 165 of file vpMeNurbs.h.

void vpMeNurbs::suppressPoints ( )

Suppression of the points which:

  • belong no more to the edge.
  • which are to closed to another point.

Definition at line 382 of file vpMeNurbs.cpp.

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

Referenced by track().

void vpMeNurbs::supressNearPoints ( )

Suppress vpMeSites if they are too close to each other.

The goal is to keep the order of the vpMeSites in the list.

Definition at line 992 of file vpMeNurbs.cpp.

References vpMe::getSampleStep(), vpMeTracker::list, vpMeSite::setState(), vpMath::sqr(), vpMeSite::sqrDistance(), and vpMeSite::TOO_NEAR.

Referenced by track().

unsigned int vpMeTracker::totalNumberOfSignal ( )
inherited

Definition at line 127 of file vpMeTracker.cpp.

References vpMeTracker::list.

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

Set the alpha value (normal to the edge at this point) of the different vpMeSite to a value computed thanks to the nurbs.

Definition at line 402 of file vpMeNurbs.cpp.

References vpMeSite::alpha, vpNurbs::computeCurveDersPoint(), vpNurbs::computeCurvePoint(), vpImagePoint::distance(), vpMeSite::i, vpMeSite::j, vpMeTracker::list, and nurbs.

Referenced by track().

Member Data Documentation

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

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
vpNurbs vpMeNurbs::nurbs

The Nurbs which represents the tracked edge.

Definition at line 137 of file vpMeNurbs.h.

Referenced by display(), initTracking(), localReSample(), sample(), seekExtremities(), track(), updateDelta(), and vpMeNurbs().

int vpMeTracker::query_range
inherited

Definition at line 173 of file vpMeTracker.h.

Referenced by vpMeTracker::vpMeTracker().