Visual Servoing Platform  version 3.5.1 under development (2023-09-22)

#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
 
vpColVector get_nij () const
 
double getArea () 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
 
vpPolygon getPolygon () 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) const
 
bool operator!= (const vpDot &d) const
 
void print (std::ostream &os)
 
void setCog (const vpImagePoint &ip)
 
void setComputeMoments (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 (bool activate)
 
void setGraphicsThickness (unsigned int t)
 
void track (const vpImage< unsigned char > &I)
 
void track (const vpImage< unsigned char > &I, vpImagePoint &ip)
 
Public Member Functions Inherited from vpTracker
vpColVector get_p () const
 
vpColVector get_cP () const
 

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
 
Public Attributes Inherited from vpTracker
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/blob/vpDot.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/sensor/vp1394TwoGrabber.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
}
Class for firewire ieee1394 video devices using libdc1394-2.x api.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:132
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition: vpDot.h:112
void initTracking(const vpImage< unsigned char > &I)
Definition: vpDot.cpp:617
void setGraphics(bool activate)
Definition: vpDot.h:357
void track(const vpImage< unsigned char > &I)
Definition: vpDot.cpp:757
See also
vpDot2
Examples
poseVirtualVS.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoAfma6Segment2DCamVelocity.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityLs_des.cpp, testRobotAfma6Pose.cpp, testRobotViper850Pose.cpp, and trackDot.cpp.

Definition at line 111 of file vpDot.h.

Member Enumeration Documentation

◆ vpConnexityType

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 117 of file vpDot.h.

Constructor & Destructor Documentation

◆ vpDot() [1/3]

vpDot::vpDot ( )

Definition at line 91 of file vpDot.cpp.

◆ vpDot() [2/3]

vpDot::vpDot ( const vpImagePoint ip)
explicit

Constructor with initialization of the dot location.

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

Definition at line 103 of file vpDot.cpp.

◆ vpDot() [3/3]

vpDot::vpDot ( const vpDot d)

Copy constructor.

Definition at line 113 of file vpDot.cpp.

◆ ~vpDot()

vpDot::~vpDot ( )
virtual

Destructor.

Definition at line 125 of file vpDot.cpp.

Member Function Documentation

◆ display() [1/3]

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

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

◆ display() [2/3]

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

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

◆ display() [3/3]

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

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

◆ get_cP()

vpColVector vpTracker::get_cP ( ) const
inlineinherited

Return object parameters expressed in the 3D camera frame.

Definition at line 94 of file vpTracker.h.

◆ get_nij()

vpColVector vpDot::get_nij ( ) const
inline

Gets the second order normalized centered moment $ n_{ij} $ as a 3-dim vector containing $ n_{20}, n_{11}, n_{02} $ such as $ n_{ij} = \mu_{ij}/m_{00} $

Returns
The 3-dim vector containing $ n_{20}, n_{11}, n_{02} $.
See also
getCog(), getArea()

Definition at line 206 of file vpDot.h.

Referenced by vpFeatureBuilder::create().

◆ get_p()

vpColVector vpTracker::get_p ( ) const
inlineinherited

Return object parameters expressed in the 2D image plane computed by perspective projection.

Definition at line 92 of file vpTracker.h.

◆ getArea()

double vpDot::getArea ( ) const
inline

Gets the area of the blob corresponding also to the zero order moment.

Returns
The blob area.

Definition at line 221 of file vpDot.h.

◆ getBBox()

vpRect vpDot::getBBox ( ) const
inline

Return the dot bounding box.

See also
getWidth(), getHeight()

Definition at line 230 of file vpDot.h.

References vpRect::setRect().

◆ getCog()

◆ getConnexities()

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 261 of file vpDot.h.

◆ getEdges()

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

Definition at line 251 of file vpDot.h.

◆ getGamma()

double vpDot::getGamma ( ) const
inline

Definition at line 263 of file vpDot.h.

◆ getGrayLevelPrecision()

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 271 of file vpDot.h.

◆ getHeight()

unsigned int vpDot::getHeight ( ) const
inline

Return the width of the dot.

See also
getHeight()

Definition at line 299 of file vpDot.h.

◆ getMaxDotSize()

double vpDot::getMaxDotSize ( ) const
inline

Definition at line 272 of file vpDot.h.

◆ getMeanGrayLevel()

double vpDot::getMeanGrayLevel ( ) const
inline

Return the mean gray level value of the dot.

Definition at line 276 of file vpDot.h.

◆ getPolygon()

vpPolygon vpDot::getPolygon ( ) const
inline
Returns
a vpPolygon made from the edges of the dot.

Definition at line 281 of file vpDot.h.

◆ getWidth()

unsigned int vpDot::getWidth ( ) const
inline

Return the width of the dot.

See also
getHeight()

Definition at line 290 of file vpDot.h.

◆ initTracking() [1/3]

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
servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityLs_des.cpp, testRobotAfma6Pose.cpp, and testRobotViper850Pose.cpp.

Definition at line 617 of file vpDot.cpp.

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

◆ initTracking() [2/3]

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

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

◆ initTracking() [3/3]

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

References track().

◆ operator!=()

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

Definition at line 168 of file vpDot.cpp.

◆ operator=()

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

Copy operator.

Definition at line 130 of file vpDot.cpp.

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

◆ operator==()

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

Definition at line 170 of file vpDot.cpp.

◆ print()

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

Definition at line 311 of file vpDot.h.

◆ setCog()

void vpDot::setCog ( const vpImagePoint ip)
inline

Initialize the dot coordinates with ip.

Definition at line 316 of file vpDot.h.

◆ setComputeMoments()

void vpDot::setComputeMoments ( 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 and second order centered moments vpDot::mu11, vpDot::mu20, vpDot::mu02 computed with respect to the blob centroid.

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.

Definition at line 333 of file vpDot.h.

◆ setConnexity()

void vpDot::setConnexity ( vpConnexityType  type)
inline

Set the type of connexity: 4 or 8.

Definition at line 338 of file vpDot.h.

◆ setGraphics()

void vpDot::setGraphics ( 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
servoAfma6Points2DCamVelocityEyeToHand.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoViper850FourPoints2DArtVelocityLs_des.cpp, testRobotAfma6Pose.cpp, and testRobotViper850Pose.cpp.

Definition at line 357 of file vpDot.h.

◆ setGraphicsThickness()

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 364 of file vpDot.h.

◆ setGrayLevelMax()

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

Definition at line 341 of file vpDot.h.

◆ setGrayLevelMin()

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

Definition at line 340 of file vpDot.h.

◆ setGrayLevelPrecision()

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

◆ setMaxDotSize()

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

References vpTRACE.

◆ track() [1/2]

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
servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoBiclopsPoint2DArtVelocity.cpp, and servoViper850FourPoints2DArtVelocityLs_des.cpp.

Definition at line 757 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().

◆ track() [2/2]

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

References track().

Friends And Related Function Documentation

◆ operator<<

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

Member Data Documentation

◆ cP

◆ cPAvailable

bool vpTracker::cPAvailable
inherited

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

Definition at line 78 of file vpTracker.h.

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

◆ m00

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

Definition at line 131 of file vpDot.h.

Referenced by operator=().

◆ m01

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

Definition at line 138 of file vpDot.h.

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

◆ m02

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 $.

See also
setComputeMoments()

Definition at line 166 of file vpDot.h.

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

◆ m10

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

Definition at line 145 of file vpDot.h.

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

◆ m11

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 $.

See also
setComputeMoments()

Definition at line 152 of file vpDot.h.

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

◆ m20

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 $.

See also
setComputeMoments()

Definition at line 159 of file vpDot.h.

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

◆ mu02

double vpDot::mu02

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

See also
setComputeMoments()

Definition at line 183 of file vpDot.h.

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

◆ mu11

double vpDot::mu11

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

See also
setComputeMoments()

Definition at line 173 of file vpDot.h.

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

◆ mu20

double vpDot::mu20

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

See also
setComputeMoments()

Definition at line 178 of file vpDot.h.

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

◆ p

◆ SPIRAL_SEARCH_SIZE

const unsigned int vpDot::SPIRAL_SEARCH_SIZE = 350
static

Spiral size for the dot search.

Definition at line 129 of file vpDot.h.