Visual Servoing Platform  version 3.6.1 under development (2024-12-12)

#include <visp3/me/vpMeSite.h>

Public Types

enum  vpMeSiteDisplayType { NONE , RANGE , RESULT , RANGE_RESULT }
 
enum  vpMeSiteState {
  NO_SUPPRESSION = 0 , CONTRAST = 1 , THRESHOLD = 2 , M_ESTIMATOR = 3 ,
  TOO_NEAR = 4 , UNKNOW = 5 , OUTSIDE_ROI_MASK = 6
}
 

Public Member Functions

 vpMeSite ()
 
 vpMeSite (const double &ip, const double &jp)
 
 vpMeSite (const vpMeSite &mesite)
 
virtual ~vpMeSite ()
 
double convolution (const vpImage< unsigned char > &ima, const vpMe *me)
 
void display (const vpImage< unsigned char > &I) const
 
void display (const vpImage< vpRGBa > &I) const
 
double getAlpha () const
 
double getWeight () const
 
vpMeSitegetQueryList (const vpImage< unsigned char > &I, const int &range) const
 
int get_i () const
 
int get_j () const
 
double get_ifloat () const
 
double get_jfloat () const
 
void init ()
 
void init (const double &ip, const double &jp, const double &alphap)
 
void init (const double &ip, const double &jp, const double &alphap, const double &convltp)
 
void init (const double &ip, const double &jp, const double &alphap, const double &convltp, const int &sign)
 
void init (const double &ip, const double &jp, const double &alphap, const double &convltp, const int &sign, const double &contrastThreshold)
 
void track (const vpImage< unsigned char > &I, const vpMe *me, const bool &test_contrast=true)
 
void trackMultipleHypotheses (const vpImage< unsigned char > &I, const vpMe &me, const bool &test_contrast, std::vector< vpMeSite > &outputHypotheses, const unsigned numCandidates)
 
void setAlpha (const double &a)
 
void setDisplay (vpMeSiteDisplayType select)
 
void setState (const vpMeSiteState &flag)
 
vpMeSiteState getState () const
 
void setWeight (const double &weight)
 
void setContrastThreshold (const double &thresh, const vpMe &me)
 
double getContrastThreshold () const
 
double computeFinalThreshold (const vpMe &me) const
 
vpMeSiteoperator= (const vpMeSite &m)
 
int operator!= (const vpMeSite &m)
 

Static Public Member Functions

static double distance (const vpMeSite &S1, const vpMeSite &S2)
 
static double sqrDistance (const vpMeSite &S1, const vpMeSite &S2)
 
static void display (const vpImage< unsigned char > &I, const double &i, const double &j, const vpMeSiteState &state=NO_SUPPRESSION)
 
static void display (const vpImage< vpRGBa > &I, const double &i, const double &j, const vpMeSiteState &state=NO_SUPPRESSION)
 

Public Attributes

int m_i
 
int m_j
 
double m_ifloat
 
double m_jfloat
 
int m_mask_sign
 
double m_alpha
 
double m_convlt
 
double m_normGradient
 
double m_weight
 
double m_contrastThreshold
 

Friends

VISP_EXPORT std::ostream & operator<< (std::ostream &os, vpMeSite &vpMeS)
 

Detailed Description

Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'. Gives the most likely site given the probability from an ME mask.

  • Bug fix: rewrote application of masks to use the temporal information instead of applying both temporal masks to the same image. ie: spatial -> spatio/temporal
  • Added new tracking function to choose the most similar edge amongst all edges found.
  • sample step.

Definition at line 67 of file vpMeSite.h.

Member Enumeration Documentation

◆ vpMeSiteDisplayType

Type moving-edges site of display.

Enumerator
NONE 

Not displayed.

RANGE 
RESULT 
RANGE_RESULT 

Definition at line 73 of file vpMeSite.h.

◆ vpMeSiteState

Moving-edge site state

Enumerator
NO_SUPPRESSION 

Point successfully tracked.

CONTRAST 

Point not tracked due to a contrast problem, but retained in the ME list.

THRESHOLD 

Point not tracked due to the likelihood that is below the threshold, but retained in the ME list.

M_ESTIMATOR 

Point detected as an outlier during virtual visual-servoing.

TOO_NEAR 

Point not tracked anymore, since too near from its neighbor.

UNKNOW 

Reserved.

OUTSIDE_ROI_MASK 

Point is outside the region of interest mask, but retained in the ME list.

Definition at line 84 of file vpMeSite.h.

Constructor & Destructor Documentation

◆ vpMeSite() [1/3]

vpMeSite::vpMeSite ( )

Default constructor.

Definition at line 93 of file vpMeSite.cpp.

◆ vpMeSite() [2/3]

vpMeSite::vpMeSite ( const double &  ip,
const double &  jp 
)

Constructor from pixel coordinates.

Definition at line 98 of file vpMeSite.cpp.

References m_i, m_ifloat, m_j, m_jfloat, and vpMath::round().

◆ vpMeSite() [3/3]

vpMeSite::vpMeSite ( const vpMeSite mesite)

Copy constructor.

Definition at line 108 of file vpMeSite.cpp.

◆ ~vpMeSite()

virtual vpMeSite::~vpMeSite ( )
inlinevirtual

Destructor.

Definition at line 138 of file vpMeSite.h.

Member Function Documentation

◆ computeFinalThreshold()

double vpMeSite::computeFinalThreshold ( const vpMe me) const
inline

Get the final computed likelihood threshold value, depending on the likelihood threshold type and ME settings.

Returns
value of the contrast threshold of the site.

Definition at line 329 of file vpMeSite.h.

References vpMe::getLikelihoodThresholdType(), vpMe::getMaskSize(), and vpMe::NORMALIZED_THRESHOLD.

Referenced by track(), and trackMultipleHypotheses().

◆ convolution()

◆ display() [1/4]

void vpMeSite::display ( const vpImage< unsigned char > &  I) const

Display moving edges in image I.

Parameters
I: Input image.

Definition at line 486 of file vpMeSite.cpp.

References m_ifloat, and m_jfloat.

Referenced by vpMeTracker::display(), and display().

◆ display() [2/4]

void vpMeSite::display ( const vpImage< unsigned char > &  I,
const double &  i,
const double &  j,
const vpMeSiteState state = NO_SUPPRESSION 
)
static

Display the moving edge site 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 (contrast 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 outside the mask, see vpMeTracker::setMask().
  • Yellow otherwise.
Parameters
I: The image.
i: Pixel i of the site.
j: Pixel j of the site.
state: State of the site.

Definition at line 492 of file vpMeSite.cpp.

References vpColor::blue, CONTRAST, vpColor::cyan, vpDisplay::displayCross(), vpColor::green, M_ESTIMATOR, NO_SUPPRESSION, OUTSIDE_ROI_MASK, vpColor::purple, vpColor::red, THRESHOLD, and vpColor::yellow.

◆ display() [3/4]

void vpMeSite::display ( const vpImage< vpRGBa > &  I) const

Display moving edges in image I.

Parameters
I: Input image.

Definition at line 488 of file vpMeSite.cpp.

References display(), m_ifloat, and m_jfloat.

◆ display() [4/4]

void vpMeSite::display ( const vpImage< vpRGBa > &  I,
const double &  i,
const double &  j,
const vpMeSiteState state = NO_SUPPRESSION 
)
static

Display the moving edge site 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 (contrast 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 outside the mask, see vpMeTracker::setMask().
  • Yellow otherwise
Parameters
I: The image.
i: Pixel i of the site.
j: Pixel j of the site.
state: State of the site.

Definition at line 521 of file vpMeSite.cpp.

References vpColor::blue, CONTRAST, vpColor::cyan, vpDisplay::displayCross(), vpColor::green, M_ESTIMATOR, NO_SUPPRESSION, OUTSIDE_ROI_MASK, vpColor::purple, vpColor::red, THRESHOLD, and vpColor::yellow.

◆ distance()

static double vpMeSite::distance ( const vpMeSite S1,
const vpMeSite S2 
)
inlinestatic

Compute the square root distance between two moving-edges sites $ |S1 - S2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2} $

Parameters
S1: First site
S2: Second site
Returns
the distance between the two sites.
See also
sqrDistance()

Definition at line 368 of file vpMeSite.h.

◆ get_i()

int vpMeSite::get_i ( ) const
inline

Return integer coordinate along i (rows).

See also
get_ifloat()

Definition at line 183 of file vpMeSite.h.

Referenced by vpMeNurbs::seekExtremities(), vpMeTracker::track(), and vpMeNurbs::updateDelta().

◆ get_ifloat()

◆ get_j()

int vpMeSite::get_j ( ) const
inline

Return integer coordinate along j (columns).

See also
get_jfloat()

Definition at line 189 of file vpMeSite.h.

Referenced by vpMeNurbs::seekExtremities(), vpMeTracker::track(), and vpMeNurbs::updateDelta().

◆ get_jfloat()

◆ getAlpha()

double vpMeSite::getAlpha ( ) const
inline

Get the angle of tangent at site.

Returns
value of alpha

Definition at line 162 of file vpMeSite.h.

◆ getContrastThreshold()

double vpMeSite::getContrastThreshold ( ) const
inline

Get the contrast threshold of the site.

Returns
value of the contrast threshold of the site.

Definition at line 321 of file vpMeSite.h.

◆ getQueryList()

vpMeSite * vpMeSite::getQueryList ( const vpImage< unsigned char > &  I,
const int &  range 
) const

Construct and return the list of vpMeSite along the normal to the contour, in the given range.

Precondition
: Subpixel coordinates (ifloat, jfloat) and the direction of the normal (alpha) have to be set.
Parameters
I: Image in which the display is performed.
range: +/- the range within which the pixel's correspondent will be sought.
Returns
Pointer to the list of query sites

Definition at line 188 of file vpMeSite.cpp.

References vpDisplay::displayCross(), init(), m_alpha, m_contrastThreshold, m_convlt, m_ifloat, m_jfloat, m_mask_sign, RANGE, RANGE_RESULT, vpImagePoint::set_i(), vpImagePoint::set_j(), setDisplay(), and vpColor::yellow.

Referenced by track(), and trackMultipleHypotheses().

◆ getState()

◆ getWeight()

double vpMeSite::getWeight ( ) const
inline

Return site weight or uncertainty as a probability between 0 and 1.

Definition at line 167 of file vpMeSite.h.

◆ init() [1/5]

◆ init() [2/5]

void vpMeSite::init ( const double &  ip,
const double &  jp,
const double &  alphap 
)

Initialize moving-edge site parameters.

Definition at line 117 of file vpMeSite.cpp.

References m_alpha, m_i, m_ifloat, m_j, m_jfloat, m_mask_sign, NONE, and vpMath::round().

◆ init() [3/5]

void vpMeSite::init ( const double &  ip,
const double &  jp,
const double &  alphap,
const double &  convltp 
)

Initialize moving-edge site parameters.

Definition at line 131 of file vpMeSite.cpp.

References m_alpha, m_convlt, m_i, m_ifloat, m_j, m_jfloat, m_mask_sign, and NONE.

◆ init() [4/5]

void vpMeSite::init ( const double &  ip,
const double &  jp,
const double &  alphap,
const double &  convltp,
const int &  sign 
)

Initialize moving-edge site parameters.

Definition at line 144 of file vpMeSite.cpp.

References m_alpha, m_convlt, m_i, m_ifloat, m_j, m_jfloat, m_mask_sign, and NONE.

◆ init() [5/5]

void vpMeSite::init ( const double &  ip,
const double &  jp,
const double &  alphap,
const double &  convltp,
const int &  sign,
const double &  contrastThreshold 
)

Initialize moving-edge site parameters.

Definition at line 157 of file vpMeSite.cpp.

References m_alpha, m_contrastThreshold, m_convlt, m_i, m_ifloat, m_j, m_jfloat, m_mask_sign, and NONE.

◆ operator!=()

int vpMeSite::operator!= ( const vpMeSite m)

Comparison operator.

Definition at line 483 of file vpMeSite.cpp.

References m_i, and m_j.

◆ operator=()

vpMeSite & vpMeSite::operator= ( const vpMeSite m)

Copy operator.

Definition at line 170 of file vpMeSite.cpp.

References m_alpha, m_contrastThreshold, m_convlt, m_i, m_ifloat, m_j, m_jfloat, m_mask_sign, m_normGradient, and m_weight.

◆ setAlpha()

void vpMeSite::setAlpha ( const double &  a)
inline

Set the angle of tangent at site.

Parameters
a: new value of alpha

Definition at line 259 of file vpMeSite.h.

Referenced by vpMeLine::updateDelta(), and vpMeNurbs::updateDelta().

◆ setContrastThreshold()

void vpMeSite::setContrastThreshold ( const double &  thresh,
const vpMe me 
)
inline

Set the contrast threshold of the site. If the vpMe::m_useAutomaticThreshold is set to false, the contrast threshold is set to the global value retrieved using vpMe::getThreshold(). This value can be set using vpMe::setThreshold(). Otherwise, the contrast threshold will be set to the highest value between thresh and the minimum value set by vpMe::setMinThreshold() that could be retrieved using vpMe::getMinThreshold().

Parameters
thresh: new value of contrast threshold
memoving-edge parameters

Definition at line 303 of file vpMeSite.h.

References vpMe::getMinThreshold(), vpMe::getThreshold(), and vpMe::getUseAutomaticThreshold().

Referenced by vpMeEllipse::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), and vpMeLine::seekExtremities().

◆ setDisplay()

◆ setState()

void vpMeSite::setState ( const vpMeSiteState flag)
inline

Set the state of the site.

Parameters
flag: flag corresponding to vpMeSiteState
See also
vpMeSiteState

Definition at line 273 of file vpMeSite.h.

Referenced by vpMeLine::leastSquare(), vpMeEllipse::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), vpMeNurbs::supressNearPoints(), vpMeTracker::track(), and vpMbEdgeTracker::updateMovingEdgeWeights().

◆ setWeight()

void vpMeSite::setWeight ( const double &  weight)
inline

Set the weight or uncertainty of the site.

Parameters
weight: New value of weight as a probability between 0 and 1.

Definition at line 290 of file vpMeSite.h.

Referenced by vpMeTracker::display().

◆ sqrDistance()

static double vpMeSite::sqrDistance ( const vpMeSite S1,
const vpMeSite S2 
)
inlinestatic

Compute the square distance between two moving-edges sites $ |S1 - S2| = (i_1-i_2)^2+(j_1-j_2)^2 $

Parameters
S1: First site
S2: Second site
Returns
The square distance between the two sites.
See also
distance()

Definition at line 384 of file vpMeSite.h.

References m_ifloat, m_jfloat, and vpMath::sqr().

Referenced by vpMeNurbs::localReSample(), vpMeNurbs::seekExtremitiesCanny(), and vpMeNurbs::supressNearPoints().

◆ track()

void vpMeSite::track ( const vpImage< unsigned char > &  I,
const vpMe me,
const bool &  test_contrast = true 
)

Specific function for moving-edges.

Warning
To display the moving edges graphics a call to vpDisplay::flush() is needed after this function.
Parameters
[in]I: Input image.
[in]me: Pointer to the moving-edges settings.
[in]test_contrast: When true tracking is based on contrast. The retained moving-edge is the one with similar contrast. When false, the tracking is based on the likelihood. The retained moving-edge is the one with the maximum likelihood.

Definition at line 282 of file vpMeSite.cpp.

References computeFinalThreshold(), CONTRAST, convolution(), vpDisplay::displayPoint(), vpMe::getMu1(), vpMe::getMu2(), getQueryList(), vpMe::getRange(), vpColor::green, m_convlt, m_i, m_j, m_normGradient, RANGE_RESULT, vpColor::red, RESULT, vpImagePoint::set_i(), vpImagePoint::set_j(), vpMath::sqr(), and THRESHOLD.

Referenced by vpMeTracker::initTracking(), vpMeNurbs::localReSample(), vpMeEllipse::plugHoles(), vpMeLine::seekExtremities(), vpMeNurbs::seekExtremities(), vpMeNurbs::seekExtremitiesCanny(), and vpMeTracker::track().

◆ trackMultipleHypotheses()

void vpMeSite::trackMultipleHypotheses ( const vpImage< unsigned char > &  I,
const vpMe me,
const bool &  test_contrast,
std::vector< vpMeSite > &  outputHypotheses,
const unsigned  numCandidates 
)

Similar to the track() function, but stores the best numCandidates hypotheses in outputHypotheses. The best matching hypotheses (if it is not suppressed) is assigned to this and is stored as the first element of outputHypotheses. The hypotheses are sorted from best to worst match in the vector. A match may be in the vector but mark as suppressed. If this is undesired, you should filter them afterwards.

Exceptions
IfnumCandidates is superior to me.getRange() * 2 + 1.
Warning
To display the moving edges graphics a call to vpDisplay::flush() is needed after this function.

Definition at line 372 of file vpMeSite.cpp.

References vpException::badValue, computeFinalThreshold(), CONTRAST, convolution(), vpDisplay::displayPoint(), vpMe::getMu1(), vpMe::getMu2(), getQueryList(), vpMe::getRange(), vpColor::green, m_convlt, m_i, m_j, m_normGradient, NO_SUPPRESSION, RANGE_RESULT, vpColor::red, RESULT, vpMath::sqr(), and THRESHOLD.

Friends And Related Function Documentation

◆ operator<<

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
vpMeSite vpMeS 
)
friend

ostream operator.

Definition at line 550 of file vpMeSite.cpp.

Member Data Documentation

◆ m_alpha

double vpMeSite::m_alpha

Angle of tangent at site.

Definition at line 109 of file vpMeSite.h.

Referenced by convolution(), getQueryList(), init(), operator=(), and vpMeEllipse::updateTheta().

◆ m_contrastThreshold

double vpMeSite::m_contrastThreshold

Old likelihood ratio threshold (to be avoided) or easy-to-use normalized threshold: minimal contrast.

Definition at line 117 of file vpMeSite.h.

Referenced by getQueryList(), init(), and operator=().

◆ m_convlt

double vpMeSite::m_convlt

Convolution of Site in previous image.

Definition at line 111 of file vpMeSite.h.

Referenced by getQueryList(), init(), operator=(), track(), and trackMultipleHypotheses().

◆ m_i

int vpMeSite::m_i

Integer coordinate along i of a site.

Definition at line 99 of file vpMeSite.h.

Referenced by convolution(), init(), operator!=(), operator=(), vpMeLine::seekExtremities(), vpMeNurbs::seekExtremities(), track(), trackMultipleHypotheses(), and vpMeSite().

◆ m_ifloat

◆ m_j

◆ m_jfloat

◆ m_mask_sign

int vpMeSite::m_mask_sign

Mask sign.

Definition at line 107 of file vpMeSite.h.

Referenced by convolution(), getQueryList(), init(), operator=(), and vpMeLine::updateDelta().

◆ m_normGradient

double vpMeSite::m_normGradient

Convolution of Site in previous image.

Definition at line 113 of file vpMeSite.h.

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

◆ m_weight

double vpMeSite::m_weight

Uncertainty of point given as a probability between 0 and 1.

Definition at line 115 of file vpMeSite.h.

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