Visual Servoing Platform  version 3.2.0

#include <vpMeNurbs.h>

+ Inheritance diagram for vpMeNurbs:

Public Member Functions

 vpMeNurbs ()
 
 vpMeNurbs (const vpMeNurbs &menurbs)
 
virtual ~vpMeNurbs ()
 
void setNbControlPoints (const unsigned int nb_point)
 
void setEnableCannyDetection (const bool enable_canny)
 
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 > &I)
 
virtual void sample (const vpImage< unsigned char > &image, const bool doNotTrack=false)
 
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 row, int cols)
 
int outOfImage (const vpImagePoint &iP, int half, int rows, int cols)
 
void reset ()
 
void setInitRange (const unsigned int &r)
 
unsigned int getInitRange ()
 
virtual void setMask (const vpImage< bool > &mask)
 
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, vpNurbs &n, vpColor color=vpColor::green)
 
static void display (const vpImage< vpRGBa > &I, vpNurbs &n, vpColor color=vpColor::green)
 
static bool inMask (const vpImage< bool > *mask, const unsigned int i, const unsigned int j)
 

Public Attributes

vpNurbs nurbs
 
std::list< vpMeSitelist
 
vpMeme
 
unsigned int init_range
 
int nGoodElement
 
const vpImage< bool > * m_mask
 
int query_range
 
bool display_point
 
vpColVector p
 
vpColVector cP
 
bool cPAvailable
 

Protected Attributes

vpMeSite::vpMeSiteDisplayType selectDisplay
 

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 <visp3/core/vpImage.h>
#include <visp3/core/vpImagePoint.h>
#include <visp3/me/vpMeNurbs.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);
// 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() [1/2]

vpMeNurbs::vpMeNurbs ( )

Basic constructor that calls the constructor of the class vpMeTracker.

Definition at line 214 of file vpMeNurbs.cpp.

◆ vpMeNurbs() [2/2]

vpMeNurbs::vpMeNurbs ( const vpMeNurbs menurbs)

Copy constructor.

Definition at line 223 of file vpMeNurbs.cpp.

◆ ~vpMeNurbs()

vpMeNurbs::~vpMeNurbs ( )
virtual

Basic destructor.

Definition at line 239 of file vpMeNurbs.cpp.

Member Function Documentation

◆ display() [1/5]

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

◆ display() [2/5]

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 1027 of file vpMeNurbs.cpp.

◆ display() [3/5]

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

◆ display() [4/5]

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 1243 of file vpMeNurbs.cpp.

◆ display() [5/5]

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 1264 of file vpMeNurbs.cpp.

◆ getInitRange()

unsigned int vpMeTracker::getInitRange ( )
inlineinherited

Return the initial range.

Returns
Value of init_range.

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

◆ getMeList() [2/2]

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

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

◆ getNurbs()

vpNurbs vpMeNurbs::getNurbs ( ) const
inline

Gets the nurbs;

Definition at line 209 of file vpMeNurbs.h.

◆ init()

void vpMeTracker::init ( void  )
inherited

◆ initTracking() [1/2]

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 247 of file vpMeNurbs.cpp.

◆ initTracking() [2/2]

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 276 of file vpMeNurbs.cpp.

◆ inMask()

bool vpMeTracker::inMask ( const vpImage< bool > *  mask,
const unsigned int  i,
const 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 139 of file vpMeTracker.cpp.

Referenced by vpMbtFaceDepthDense::computeDesiredFeatures(), and vpMbtFaceDepthNormal::computeDesiredFeatures().

◆ localReSample()

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

Resample a part of the edge if two vpMeSite are too far from eachother. In this case the method try to initialize any vpMeSite between the two points.

Parameters
I: Image in which the edge appears.

Definition at line 830 of file vpMeNurbs.cpp.

◆ numberOfSignal()

unsigned int vpMeTracker::numberOfSignal ( )
inherited

Definition at line 119 of file vpMeTracker.cpp.

References vpMeTracker::list.

◆ outOfImage() [1/2]

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

Definition at line 154 of file vpMeTracker.cpp.

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

◆ outOfImage() [2/2]

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

Definition at line 149 of file vpMeTracker.cpp.

◆ reSample()

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 812 of file vpMeNurbs.cpp.

◆ reset()

void vpMeTracker::reset ( )
inherited

Reset the tracker by removing all the moving edges.

Definition at line 95 of file vpMeTracker.cpp.

Referenced by vpMeTracker::~vpMeTracker().

◆ sample()

void vpMeNurbs::sample ( const vpImage< unsigned char > &  I,
const bool  doNotTrack = false 
)
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.
doNotTrack: Inherited parameter, not used.

Implements vpMeTracker.

Definition at line 293 of file vpMeNurbs.cpp.

◆ seekExtremities()

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

Seek along the edge defined by the nurbs, the two extremities of the edge. This function is useful in case of translation of the edge.

Parameters
I: Image in which the edge appears.

Definition at line 394 of file vpMeNurbs.cpp.

◆ seekExtremitiesCanny()

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 515 of file vpMeNurbs.cpp.

References vpImageFilter::canny(), vpImageConvert::convert(), vpImageTools::crop(), 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.

◆ setCannyThreshold()

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 184 of file vpMeNurbs.h.

◆ setDisplay()

◆ setEnableCannyDetection()

void vpMeNurbs::setEnableCannyDetection ( const bool  enable_canny)
inline

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

Parameters
enable_canny: if true it enables the canny detection.

Definition at line 176 of file vpMeNurbs.h.

◆ setExtremities()

void vpMeNurbs::setExtremities ( )

◆ setInitRange()

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

Set the initial range.

Parameters
r: initial range.

Definition at line 122 of file vpMeTracker.h.

◆ setMask()

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

Set the mask

Parameters
mask: Mask.

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

◆ setNbControlPoints()

void vpMeNurbs::setNbControlPoints ( const unsigned int  nb_point)
inline

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

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

Definition at line 168 of file vpMeNurbs.h.

◆ suppressPoints()

void vpMeNurbs::suppressPoints ( )

Suppression of the points which:

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

Definition at line 334 of file vpMeNurbs.cpp.

◆ supressNearPoints()

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 920 of file vpMeNurbs.cpp.

◆ totalNumberOfSignal()

unsigned int vpMeTracker::totalNumberOfSignal ( )
inherited

Definition at line 128 of file vpMeTracker.cpp.

References vpMeTracker::list.

◆ track()

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

Track the edge in the image I.

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

Definition at line 971 of file vpMeNurbs.cpp.

◆ updateDelta()

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 350 of file vpMeNurbs.cpp.

Member Data Documentation

◆ cP

vpColVector vpTracker::cP
inherited

Feature coordinates expressed in the camera frame cP.

Definition at line 74 of file vpTracker.h.

Referenced by vpCircle::init(), vpSphere::init(), vpCylinder::init(), vpTracker::operator=(), vpPoint::operator=(), and vpPose::printPoint().

◆ cPAvailable

bool vpTracker::cPAvailable
inherited

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

Definition at line 80 of file vpTracker.h.

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

◆ display_point

bool vpMeTracker::display_point
inherited

Definition at line 177 of file vpMeTracker.h.

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

◆ init_range

unsigned int vpMeTracker::init_range
inherited

Definition at line 76 of file vpMeTracker.h.

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

◆ list

std::list<vpMeSite> vpMeTracker::list
inherited

Tracking dependent variables/functions List of tracked moving edges points.

Definition at line 73 of file vpMeTracker.h.

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

◆ m_mask

const vpImage<bool>* vpMeTracker::m_mask
inherited

Mask used to disable tracking on a part of image.

Definition at line 79 of file vpMeTracker.h.

◆ me

vpMe* vpMeTracker::me
inherited

Moving edges initialisation parameters.

Definition at line 75 of file vpMeTracker.h.

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

◆ nGoodElement

int vpMeTracker::nGoodElement
inherited

Definition at line 77 of file vpMeTracker.h.

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

◆ nurbs

vpNurbs vpMeNurbs::nurbs

The Nurbs which represents the tracked edge.

Definition at line 137 of file vpMeNurbs.h.

◆ p

vpColVector vpTracker::p
inherited

Feature coordinates expressed in the image plane p. They correspond to 2D normalized coordinates expressed in meters.

Definition at line 70 of file vpTracker.h.

Referenced by vpCircle::display(), vpSphere::display(), vpProjectionDisplay::display(), vpProjectionDisplay::displayCamera(), vpCircle::init(), vpSphere::init(), vpMeTracker::init(), vpCylinder::init(), vpTracker::operator=(), vpPoint::operator=(), and vpPose::printPoint().

◆ query_range

int vpMeTracker::query_range
inherited

Definition at line 176 of file vpMeTracker.h.

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

◆ selectDisplay

vpMeSite::vpMeSiteDisplayType vpMeTracker::selectDisplay
protectedinherited
vpMe::setThreshold
void setThreshold(const double &t)
Definition: vpMe.h:299
vpMeNurbs
Class that tracks in an image a edge defined by a Nurbs.
Definition: vpMeNurbs.h:129
vpMe
Definition: vpMe.h:59
vpMe::setRange
void setRange(const unsigned int &r)
Definition: vpMe.h:270
vpMeNurbs::setNbControlPoints
void setNbControlPoints(const unsigned int nb_point)
Definition: vpMeNurbs.h:168
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:87
vpMeTracker::setMe
void setMe(vpMe *p_me)
Definition: vpMeTracker.h:143
vpMeNurbs::track
void track(const vpImage< unsigned char > &I)
Definition: vpMeNurbs.cpp:971
vpMe::setPointsToTrack
void setPointsToTrack(const int &n)
Definition: vpMe.h:263
vpMeNurbs::initTracking
void initTracking(const vpImage< unsigned char > &I)
Definition: vpMeNurbs.cpp:247
vpMe::setSampleStep
void setSampleStep(const double &s)
Definition: vpMe.h:277
vpImage< unsigned char >
vpMeTracker::me
vpMe * me
Moving edges initialisation parameters.
Definition: vpMeTracker.h:75