Visual Servoing Platform  version 3.0.0

#include <visp3/blob/vpDot.h>

+ Inheritance diagram for vpDot:

Public Types

enum  vpConnexityType { CONNEXITY_4, CONNEXITY_8 }
 

Public Member Functions

 vpDot ()
 
 vpDot (const vpImagePoint &ip)
 
 vpDot (const vpDot &d)
 
virtual ~vpDot ()
 
void display (const vpImage< unsigned char > &I, vpColor color=vpColor::red, unsigned int thickness=1) const
 
vpRect getBBox () const
 
vpImagePoint getCog () const
 
std::list< vpImagePointgetEdges () const
 
std::list< vpImagePointgetConnexities () const
 
double getGamma () const
 
double getGrayLevelPrecision () const
 
double getMaxDotSize () const
 
double getMeanGrayLevel () const
 
unsigned int getWidth () const
 
unsigned int getHeight () const
 
void initTracking (const vpImage< unsigned char > &I)
 
void initTracking (const vpImage< unsigned char > &I, const vpImagePoint &ip)
 
void initTracking (const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int gray_level_min, unsigned int gray_level_max)
 
vpDotoperator= (const vpDot &d)
 
bool operator== (const vpDot &d)
 
bool operator!= (const vpDot &d)
 
void print (std::ostream &os)
 
void setCog (const vpImagePoint &ip)
 
void setComputeMoments (const bool activate)
 
void setConnexity (vpConnexityType type)
 
void setMaxDotSize (double percentage)
 
void setGrayLevelMin (const unsigned int &level_min)
 
void setGrayLevelMax (const unsigned int &level_max)
 
void setGrayLevelPrecision (const double &grayLevelPrecision)
 
void setGraphics (const bool activate)
 
void setGraphicsThickness (unsigned int t)
 
void track (const vpImage< unsigned char > &I)
 
void track (const vpImage< unsigned char > &I, vpImagePoint &ip)
 

Static Public Member Functions

static void display (const vpImage< unsigned char > &I, const vpImagePoint &cog, const std::list< vpImagePoint > &edges_list, vpColor color=vpColor::red, unsigned int thickness=1)
 
static void display (const vpImage< vpRGBa > &I, const vpImagePoint &cog, const std::list< vpImagePoint > &edges_list, vpColor color=vpColor::red, unsigned int thickness=1)
 

Public Attributes

double m00
 
double m01
 
double m10
 
double m11
 
double m20
 
double m02
 
double mu11
 
double mu20
 
double mu02
 
vpColVector p
 
vpColVector cP
 
bool cPAvailable
 

Static Public Attributes

static const unsigned int SPIRAL_SEARCH_SIZE = 350
 

Friends

VISP_EXPORT std::ostream & operator<< (std::ostream &os, vpDot &d)
 

Detailed Description

This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.

The underground algorithm is based on a binarization of the image and a connex component segmentation to determine the dot characteristics (location, moments, size...).

The following sample code shows how to grab images from a firewire camera, track a blob and display the tracking results.

#include <visp3/core/vpConfig.h>
#include <visp3/sensor/vp1394TwoGrabber.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/blob/vpDot.h>
#include <visp3/core/vpImage.h>
int main()
{
#if defined(VISP_HAVE_DC1394)
vpImage<unsigned char> I; // Create a gray level image container
vp1394TwoGrabber g(false); // Create a grabber based on libdc1394-2.x third party lib
g.acquire(I); // Acquire an image
#if defined(VISP_HAVE_X11)
vpDisplayX d(I, 0, 0, "Camera view");
#endif
vpDot blob;
blob.initTracking(I);
blob.setGraphics(true);
while(1) {
g.acquire(I); // Acquire an image
blob.track(I);
}
#endif
}
See also
vpDot2
Examples:
poseVirtualVS.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoAfma6Segment2DCamVelocity.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, testRobotAfma6Pose.cpp, testRobotViper850Pose.cpp, and trackDot.cpp.

Definition at line 115 of file vpDot.h.

Member Enumeration Documentation

Type of connexity 4, or 8.

Enumerator
CONNEXITY_4 

For a given pixel 4 neighbors are considered (left, right, up, down)

CONNEXITY_8 

For a given pixel 8 neighbors are considered (left, right, up, down, and the 4 pixels located on the diagonal)

Definition at line 121 of file vpDot.h.

Constructor & Destructor Documentation

vpDot::vpDot ( )

Definition at line 92 of file vpDot.cpp.

vpDot::vpDot ( const vpImagePoint ip)

Constructor with initialization of the dot location.

Parameters
ip: An image point with sub-pixel coordinates.

Definition at line 106 of file vpDot.cpp.

vpDot::vpDot ( const vpDot d)

Copy constructor.

Definition at line 119 of file vpDot.cpp.

vpDot::~vpDot ( )
virtual

Destructor.

Definition at line 133 of file vpDot.cpp.

Member Function Documentation

void vpDot::display ( const vpImage< unsigned char > &  I,
vpColor  color = vpColor::red,
unsigned int  thick = 1 
) const

Display in overlay the dot edges and center of gravity.

Parameters
I: Image.
color: The color used for the display.
thick: Thickness of the displayed cross located at the dot cog.

Definition at line 860 of file vpDot.cpp.

References vpDisplay::displayCross(), and vpDisplay::displayPoint().

void vpDot::display ( const vpImage< unsigned char > &  I,
const vpImagePoint cog,
const std::list< vpImagePoint > &  edges_list,
vpColor  color = vpColor::red,
unsigned int  thickness = 1 
)
static

Display the dot center of gravity and its list of edges.

Parameters
I: The image used as background.
cog: The center of gravity.
edges_list: The list of edges;
color: Color used to display the dot.
thickness: Thickness of the dot.

Definition at line 919 of file vpDot.cpp.

References vpDisplay::displayCross(), and vpDisplay::displayPoint().

void vpDot::display ( const vpImage< vpRGBa > &  I,
const vpImagePoint cog,
const std::list< vpImagePoint > &  edges_list,
vpColor  color = vpColor::red,
unsigned int  thickness = 1 
)
static

Display the dot center of gravity and its list of edges.

Parameters
I: The image used as background.
cog: The center of gravity.
edges_list: The list of edges;
color: Color used to display the dot.
thickness: Thickness of the dot.

Definition at line 946 of file vpDot.cpp.

References vpDisplay::displayCross(), and vpDisplay::displayPoint().

vpRect vpDot::getBBox ( ) const
inline

Return the dot bounding box.

See also
getWidth(), getHeight()

Definition at line 209 of file vpDot.h.

References vpRect::setRect().

std::list<vpImagePoint> vpDot::getConnexities ( ) const
inline

Return the list of all the image points inside the dot.

Returns
The list of all the images points in the dot. This list is updated after a call to track().

Definition at line 245 of file vpDot.h.

std::list<vpImagePoint> vpDot::getEdges ( ) const
inline

Return the list of all the image points on the border of the dot.

Warning
Doesn't return the image points inside the dot anymore. To get those points see getConnexities().
Examples:
trackDot.cpp.

Definition at line 233 of file vpDot.h.

double vpDot::getGamma ( ) const
inline

Definition at line 249 of file vpDot.h.

double vpDot::getGrayLevelPrecision ( ) const
inline

Return the precision of the gray level of the dot. It is a double precision float witch value is in ]0,1]. 1 means full precision, whereas values close to 0 show a very bad precision.

Definition at line 257 of file vpDot.h.

unsigned int vpDot::getHeight ( ) const
inline

Return the width of the dot.

See also
getHeight()
Examples:
trackDot.cpp.

Definition at line 286 of file vpDot.h.

double vpDot::getMaxDotSize ( ) const
inline

Definition at line 258 of file vpDot.h.

double vpDot::getMeanGrayLevel ( ) const
inline

Return the mean gray level value of the dot.

Definition at line 264 of file vpDot.h.

unsigned int vpDot::getWidth ( ) const
inline

Return the width of the dot.

See also
getHeight()
Examples:
trackDot.cpp.

Definition at line 275 of file vpDot.h.

void vpDot::initTracking ( const vpImage< unsigned char > &  I)

Initialize the tracking with a mouse click and update the dot characteristics (center of gravity, moments).

Wait a user click in a gray area in the image I. The clicked pixel will be the starting point from which the dot will be tracked.

The threshold used to segment the dot is set with the grayLevelPrecision parameter. See the formula in setGrayLevelPrecision() function.

The sub pixel coordinates of the dot are updated. To get the center of gravity coordinates of the dot, use getCog(). To compute the moments use setComputeMoments(true) before a call to initTracking().

Warning
The content of the image modified since we call track() to compute the dot characteristics.
Parameters
I: Image to process.
See also
track(), getCog()
Examples:
poseVirtualVS.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, testRobotAfma6Pose.cpp, testRobotViper850Pose.cpp, and trackDot.cpp.

Definition at line 654 of file vpDot.cpp.

References vpImagePoint::get_i(), vpImagePoint::get_j(), vpDisplay::getClick(), and track().

void vpDot::initTracking ( const vpImage< unsigned char > &  I,
const vpImagePoint ip 
)

Initialize the tracking for a dot supposed to be located at (u,v) and updates the dot characteristics (center of gravity, moments).

The threshold used to segment the dot is set to 80 percent of the gray level of the pixel (u,v).

The sub pixel coordinates of the dot are updated. To get the center of gravity coordinates of the dot, use getCog(). To compute the moments use setComputeMoments(true) before a call to initTracking().

Warning
The content of the image modified since we call track() to compute the dot characteristics.
Parameters
I: Image to process.
ip: Location of the starting point from which the dot will be tracked in the image.
See also
track()

Definition at line 708 of file vpDot.cpp.

References vpImagePoint::get_i(), vpImagePoint::get_j(), and track().

void vpDot::initTracking ( const vpImage< unsigned char > &  I,
const vpImagePoint ip,
unsigned int  level_min,
unsigned int  level_max 
)

Initialize the tracking for a dot supposed to be located at (u,v) and updates the dot characteristics (center of gravity, moments).

The sub pixel coordinates of the dot are updated. To get the center of gravity coordinates of the dot, use getCog(). To compute the moments use setComputeMoments(true) before a call to initTracking().

Warning
The content of the image modified since we call track() to compute the dot characteristics.
Parameters
I: Image to process.
ip: Location of the starting point from which the dot will be tracked in the image.
level_min: Minimum gray level threshold used to segment the dot; value comprised between 0 and 255.
level_max: Maximum gray level threshold used to segment the dot; value comprised between 0 and 255. gray_level_max should be greater than gray_level_min.
See also
track(), getCog()

Definition at line 766 of file vpDot.cpp.

References track().

bool vpDot::operator!= ( const vpDot d)

Definition at line 181 of file vpDot.cpp.

References getCog().

vpDot & vpDot::operator= ( const vpDot d)

Copy operator.

Definition at line 142 of file vpDot.cpp.

References getCog(), m00, m01, m02, m10, m11, m20, mu02, mu11, and mu20.

bool vpDot::operator== ( const vpDot d)

Definition at line 187 of file vpDot.cpp.

References getCog().

void vpDot::print ( std::ostream &  os)
inline

Definition at line 300 of file vpDot.h.

void vpDot::setCog ( const vpImagePoint ip)
inline

Initialize the dot coordinates with ip.

Definition at line 305 of file vpDot.h.

void vpDot::setComputeMoments ( const bool  activate)
inline

Activates the dot's moments computation.

Parameters
activatetrue, if you want to compute the moments. If false, moments are not computed.

Computed moment are vpDot::m00, vpDot::m10, vpDot::m01, vpDot::m11, vpDot::m20, vpDot::m02.

The coordinates of the region's centroid (u, v) can be computed from the moments by $u=\frac{m10}{m00}$ and $v=\frac{m01}{m00}$.

Examples:
servoAfma6Ellipse2DCamVelocity.cpp, and trackDot.cpp.

Definition at line 323 of file vpDot.h.

void vpDot::setConnexity ( vpConnexityType  type)
inline

Set the type of connexity: 4 or 8.

Examples:
trackDot.cpp.

Definition at line 328 of file vpDot.h.

void vpDot::setGraphics ( const bool  activate)
inline

Activates the display of all the pixels of the dot during the tracking. The default thickness of the overlayed drawings can be modified using setGraphicsThickness().

Warning
To effectively display the dot graphics a call to vpDisplay::flush() is needed.
Parameters
activatetrue to activate the display of dot pixels, false to turn off the display.
See also
setGraphicsThickness()
Examples:
poseVirtualVS.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, testRobotAfma6Pose.cpp, testRobotViper850Pose.cpp, and trackDot.cpp.

Definition at line 351 of file vpDot.h.

void vpDot::setGraphicsThickness ( unsigned int  t)
inline

Modify the default thickness that is set to 1 of the drawings in overlay when setGraphics() is enabled.

See also
setGraphics()

Definition at line 357 of file vpDot.h.

void vpDot::setGrayLevelMax ( const unsigned int &  level_max)
inline

Definition at line 333 of file vpDot.h.

void vpDot::setGrayLevelMin ( const unsigned int &  level_min)
inline

Definition at line 330 of file vpDot.h.

void vpDot::setGrayLevelPrecision ( const double &  precision)

Set the precision of the gray level of the dot.

Parameters
precision: It is a double precision float which value is in ]0,1]:
  • 1 means full precision, whereas values close to 0 show a very bad accuracy.
  • Values lower or equal to 0 are brought back to an epsion>0
  • Values higher than 1 are brought back to 1 If the initial gray level is I, the gray levels of the dot will be between : $Imin=255*\big((\frac{I}{255})^{{\gamma}^{-1}}-(1-grayLevelPrecision)\big)^{\gamma}$ and $Imax=255*\big((\frac{I}{255})^{{\gamma}^{-1}}+(1-grayLevelPrecision)\big)^{\gamma}$ with $\gamma=1.5$ .
See also
setWidth(), setHeight(), setGrayLevelMin(), setGrayLevelMax()

Definition at line 888 of file vpDot.cpp.

void vpDot::setMaxDotSize ( double  percentage)

Maximal size of the region to track in terms of image size percentage.

Parameters
percentage: Image size percentage corresponding to the dot maximal size. Values should be in ]0 : 1]. If 1, that means that the dot to track could take up the whole image.

During the tracking, if the dot size if bigger than the maximal size allowed an exception is throwed : vpTrackingException::featureLostError.

Examples:
servoAfma6Ellipse2DCamVelocity.cpp.

Definition at line 617 of file vpDot.cpp.

References vpTRACE.

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

Track and compute the dot characteristics.

To get the center of gravity coordinates of the dot, use getCog(). To compute the moments use setComputeMoments(true) before a call to initTracking().

Warning
The image is modified (all the pixels that belong to the point are set to white (ie to 255).
Parameters
I: Image to process.
See also
getCog()
Examples:
poseVirtualVS.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, and trackDot.cpp.

Definition at line 800 of file vpDot.cpp.

References vpDisplay::displayCross(), vpImagePoint::get_u(), vpImagePoint::get_v(), m01, m02, m10, m11, m20, mu02, mu11, mu20, vpColor::red, vpImagePoint::set_u(), and vpImagePoint::set_v().

Referenced by initTracking(), and track().

void vpDot::track ( const vpImage< unsigned char > &  I,
vpImagePoint ip 
)

Track and updates the new dot coordinates

To compute the moments use setComputeMoments(true) before a call to initTracking() or track().

Warning
The image is modified (all the pixels that belong to the point are set to white (ie to 255).
Parameters
I: Image to process.
ip[out] : Sub pixel coordinate of the tracked dot center of gravity.

Definition at line 846 of file vpDot.cpp.

References track().

Friends And Related Function Documentation

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
vpDot d 
)
friend

Writes the dot center of gravity coordinates in the frame (i,j) (For more details about the orientation of the frame see the vpImagePoint documentation) to the stream os, and returns a reference to the stream.

Definition at line 964 of file vpDot.cpp.

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 83 of file vpTracker.h.

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

double vpDot::m00

Considering the general distribution moments for $ N $ points defined by the relation $ m_{ij} = \sum_{h=0}^{N} u_h^i v_h^j $, $ m_{00} $ is a zero order moment obtained with $i = j = 0 $.

See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 130 of file vpDot.h.

Referenced by vpFeatureBuilder::create(), and operator=().

double vpDot::m01

Considering the general distribution moments for $ N $ points defined by the relation $ m_{ij} = \sum_{h=0}^{N} u_h^i v_h^j $, $ m_{01} $ is a first order moment obtained with $i = 0 $ and $ j = 1 $.

See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 137 of file vpDot.h.

Referenced by vpFeatureBuilder::create(), operator=(), and track().

double vpDot::m02

Considering the general distribution moments for $ N $ points defined by the relation $ m_{ij} = \sum_{h=0}^{N} u_h^i v_h^j $, $ m_{02} $ is a second order moment obtained with $i = 0 $ and $ j = 2 $.

Warning
This moment is not computed for the moment.
See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 169 of file vpDot.h.

Referenced by vpFeatureBuilder::create(), operator=(), and track().

double vpDot::m10

Considering the general distribution moments for $ N $ points defined by the relation $ m_{ij} = \sum_{h=0}^{N} u_h^i v_h^j $, $ m_{10} $ is a first order moment obtained with $i = 1 $ and $ j = 0 $.

See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 144 of file vpDot.h.

Referenced by vpFeatureBuilder::create(), operator=(), and track().

double vpDot::m11

Considering the general distribution moments for $ N $ points defined by the relation $ m_{ij} = \sum_{h=0}^{N} u_h^i v_h^j $, $ m_{11} $ is a first order moment obtained with $i = 1 $ and $ j = 1 $.

Warning
This moment is not computed for the moment.
See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 151 of file vpDot.h.

Referenced by vpFeatureBuilder::create(), operator=(), and track().

double vpDot::m20

Considering the general distribution moments for $ N $ points defined by the relation $ m_{ij} = \sum_{h=0}^{N} u_h^i v_h^j $, $ m_{20} $ is a second order moment obtained with $i = 2 $ and $ j = 0 $.

Warning
This moment is not computed for the moment.
See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 160 of file vpDot.h.

Referenced by vpFeatureBuilder::create(), operator=(), and track().

double vpDot::mu02

$ \mu_{02} $ is a second order central moments defined by: $ \mu_{02} = m_{02} - \frac{m_{01}}{m_{00}}m_{01} $

See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 188 of file vpDot.h.

Referenced by operator=(), and track().

double vpDot::mu11

$ \mu_{11} $ is a second order central moments defined by: $ \mu_{11} = m_{11} - \frac{m_{10}}{m_{00}}m_{01} $

See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 178 of file vpDot.h.

Referenced by operator=(), and track().

double vpDot::mu20

$ \mu_{20} $ is a second order central moments defined by: $ \mu_{20} = m_{20} - \frac{m_{10}}{m_{00}}m_{10} $

See also
setComputeMoments()
Examples:
trackDot.cpp.

Definition at line 183 of file vpDot.h.

Referenced by operator=(), and track().

const unsigned int vpDot::SPIRAL_SEARCH_SIZE = 350
static

Spiral size for the dot search.

Definition at line 128 of file vpDot.h.