ViSP  2.8.0

#include <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)
 
vpRect getBBox ()
 
vpImagePoint getCog () const
 
std::list< vpImagePointgetEdges ()
 
std::list< vpImagePointgetConnexities ()
 
double getGamma ()
 
double getGrayLevelPrecision () const
 
double getMaxDotSize ()
 
double getMeanGrayLevel ()
 
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 &cog)
 
void setComputeMoments (const bool activate)
 
void setConnexity (vpConnexityType connexityType)
 
void setMaxDotSize (double percentage)
 
void setGrayLevelMin (const unsigned int &gray_level_min)
 
void setGrayLevelMax (const unsigned int &gray_level_max)
 
void setGrayLevelPrecision (const double &grayLevelPrecision)
 
void setGraphics (const bool activate)
 
void setGraphicsThickness (unsigned int thickness)
 
void track (const vpImage< unsigned char > &I)
 
void track (const vpImage< unsigned char > &I, vpImagePoint &ip)
 
Deprecated functions
vp_deprecated void getEdges (std::list< vpImagePoint > &edges_list)
 
vp_deprecated void getConnexities (vpList< vpImagePoint > &connexities_list)
 

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 <visp/vpConfig.h>
#include <visp/vp1394TwoGrabber.h>
#include <visp/vpDisplayX.h>
#include <visp/vpDot.h>
#include <visp/vpImage.h>
int main()
{
#if defined(VISP_HAVE_DC1394_2)
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, testTrackDot.cpp, and trackDot.cpp.

Definition at line 118 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 124 of file vpDot.h.

Constructor & Destructor Documentation

vpDot::vpDot ( )

Definition at line 98 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 108 of file vpDot.cpp.

vpDot::vpDot ( const vpDot d)

Copy constructor.

Definition at line 118 of file vpDot.cpp.

vpDot::~vpDot ( )
virtual

Destructor.

Definition at line 126 of file vpDot.cpp.

Member Function Documentation

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

Display in overlay the dot edges and center of gravity.

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

Definition at line 852 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 912 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 939 of file vpDot.cpp.

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

vpRect vpDot::getBBox ( )
inline

Return the dot bounding box.

See also
getWidth(), getHeight()

Definition at line 212 of file vpDot.h.

References vpRect::setRect().

std::list<vpImagePoint> vpDot::getConnexities ( )
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 248 of file vpDot.h.

vp_deprecated void vpDot::getConnexities ( vpList< vpImagePoint > &  connexities_list)
inline
Deprecated:
This method is deprecated. You should use getEdges(std::list<vpImagePoint> &) instead.

Return the list of all the image points on the dot border.
Parameters
connexities_list: The list of all the images points on the dot border. This list is update after a call to track().

Definition at line 456 of file vpDot.h.

References vpList< type >::kill().

std::list<vpImagePoint> vpDot::getEdges ( )
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 236 of file vpDot.h.

vp_deprecated void vpDot::getEdges ( std::list< vpImagePoint > &  edges_list)
inline
Deprecated:
This method is deprecated since the naming is not representative regarding to its functionality.
Previously it returned all the points inside the dot. To get the equivalent, use getConnexities().

If you rather want to get the points on the dot border use getEdges().
Parameters
edges_list: The list of all the images points on the dot border. This list is update after a call to track().

Definition at line 441 of file vpDot.h.

double vpDot::getGamma ( )
inline

Definition at line 252 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 260 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 289 of file vpDot.h.

double vpDot::getMaxDotSize ( )
inline

Definition at line 261 of file vpDot.h.

double vpDot::getMeanGrayLevel ( )
inline

Return the mean gray level value of the dot.

Definition at line 267 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 278 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, testTrackDot.cpp, and trackDot.cpp.

Definition at line 642 of file vpDot.cpp.

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

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 697 of file vpDot.cpp.

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

void vpDot::initTracking ( const vpImage< unsigned char > &  I,
const vpImagePoint ip,
unsigned int  gray_level_min,
unsigned int  gray_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.
gray_level_min: Minimum gray level threshold used to segment the dot; value comprised between 0 and 255.
gray_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 756 of file vpDot.cpp.

References track(), and vpERROR_TRACE.

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

Definition at line 175 of file vpDot.cpp.

References getCog().

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

Copy operator.

Definition at line 136 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 181 of file vpDot.cpp.

References getCog().

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

Definition at line 310 of file vpDot.h.

void vpDot::setCog ( const vpImagePoint cog)
inline

Initialize the dot coordinates with cog.

Definition at line 315 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, testTrackDot.cpp, and trackDot.cpp.

Definition at line 333 of file vpDot.h.

void vpDot::setConnexity ( vpConnexityType  connexityType)
inline

Set the type of connexity: 4 or 8.

Examples:
trackDot.cpp.

Definition at line 338 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, testTrackDot.cpp, and trackDot.cpp.

Definition at line 361 of file vpDot.h.

void vpDot::setGraphicsThickness ( unsigned int  thickness)
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 367 of file vpDot.h.

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

Definition at line 343 of file vpDot.h.

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

Definition at line 340 of file vpDot.h.

void vpDot::setGrayLevelPrecision ( const double &  grayLevelPrecision)

Set the precision of the gray level of the dot.

Parameters
grayLevelPrecision: 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 881 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, and testTrackDot.cpp.

Definition at line 605 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, testTrackDot.cpp, and trackDot.cpp.

Definition at line 791 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(), vpImagePoint::set_v(), and vpERROR_TRACE.

Referenced by initTracking(), and track().

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

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.
cog[out] : Sub pixel coordinate of the tracked dot.

Definition at line 838 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 306 of file vpDot.h.

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

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 133 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 140 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 172 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 147 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 154 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 163 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 191 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 181 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 186 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 131 of file vpDot.h.