ViSP  2.8.0

#include <vpMbtKltPolygon.h>

+ Inheritance diagram for vpMbtKltPolygon:

Public Types

enum  vpMbtPolygonClippingType {
  NO_CLIPPING = 0, NEAR_CLIPPING = 1, FAR_CLIPPING = 2, LEFT_CLIPPING = 4,
  RIGHT_CLIPPING = 8, UP_CLIPPING = 16, DOWN_CLIPPING = 32, FOV_CLIPPING = 60,
  ALL_CLIPPING = 63
}
 

Public Member Functions

 vpMbtKltPolygon ()
 
virtual ~vpMbtKltPolygon ()
 
unsigned int computeNbDetectedCurrent (const vpKltOpencv &_tracker)
 
void computeHomography (const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0)
 
void computeInteractionMatrixAndResidu (vpColVector &_R, vpMatrix &_J)
 
void displayPrimitive (const vpImage< unsigned char > &_I)
 
void displayPrimitive (const vpImage< vpRGBa > &_I)
 
vpCameraParametersgetCameraParameters ()
 
vpColVector getCurrentNormal () const
 
std::map< int, vpImagePoint > & getCurrentPoints ()
 
std::map< int, int > & getCurrentPointsInd ()
 
unsigned int getInitialNumberPoint () const
 
unsigned int getNbPointsCur () const
 
bool hasEnoughPoints () const
 
void init (const vpKltOpencv &_tracker)
 
void removeOutliers (const vpColVector &weight, const double &threshold_outlier)
 
virtual void setCameraParameters (const vpCameraParameters &_cam)
 
void updateMask (IplImage *_mask, unsigned int _nb=255, unsigned int _shiftBorder=0)
 
void addPoint (const unsigned int n, const vpPoint &P)
 
void changeFrame (const vpHomogeneousMatrix &cMo)
 
void computeRoiClipped (const vpCameraParameters &cam=vpCameraParameters())
 
unsigned int getClipping () const
 
double getFarClippingDistance () const
 
int getIndex () const
 
unsigned int getNbPoint () const
 
unsigned int getNbCornerInsidePrevImage () const
 
unsigned int getNbCornerInsideImage (const vpImage< unsigned char > &I, const vpCameraParameters &cam)
 
double getNearClippingDistance () const
 
vpPointgetPoint (const unsigned int _index)
 
std::vector< vpImagePointgetRoi (const vpCameraParameters &cam)
 
std::vector< vpImagePointgetRoi (const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< vpImagePoint > &roi)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< vpImagePoint > &roi, const vpHomogeneousMatrix &cMo)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< std::pair< vpImagePoint, unsigned int > > &roi)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< std::pair< vpImagePoint, unsigned int > > &roi, const vpHomogeneousMatrix &cMo)
 
bool isAppearing () const
 
virtual bool isVisible (const vpHomogeneousMatrix &cMo, const double alpha, const bool &modulo=false)
 
bool isVisible () const
 
void setClipping (const unsigned int &flags)
 
void setFarClippingDistance (const double &dist)
 
virtual void setIndex (const int i)
 
virtual void setNbPoint (const unsigned int nb)
 
void setNearClippingDistance (const double &dist)
 
Deprecated functions
bool isVisible (const vpHomogeneousMatrix &cMo, const bool &depthTest=false)
 

Static Public Member Functions

static void getMinMaxRoi (const std::vector< vpImagePoint > &roi, int &i_min, int &i_max, int &j_min, int &j_max)
 
static bool roiInsideImage (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &corners)
 

Public Attributes

int index
 
unsigned int nbpt
 
unsigned int nbCornersInsidePrev
 
bool isvisible
 
bool isappearing
 
vpPointp
 
std::vector< std::pair< vpPoint, unsigned int > > roiPointsClip
 
unsigned int clippingFlag
 
double distNearClip
 
double distFarClip
 

Detailed Description

Implementation of a polygon of the model containing points of interest. It is used by the model-based tracker KLT, and hybrid.

Warning
This class is only available if OpenCV is installed, and used.

Definition at line 66 of file vpMbtKltPolygon.h.

Member Enumeration Documentation

Enumerator
NO_CLIPPING 
NEAR_CLIPPING 
FAR_CLIPPING 
LEFT_CLIPPING 
RIGHT_CLIPPING 
UP_CLIPPING 
DOWN_CLIPPING 
FOV_CLIPPING 
ALL_CLIPPING 

Definition at line 70 of file vpMbtPolygon.h.

Constructor & Destructor Documentation

vpMbtKltPolygon::vpMbtKltPolygon ( )

Basic constructor.

Definition at line 51 of file vpMbtKltPolygon.cpp.

References vpMbtPolygon::isvisible.

vpMbtKltPolygon::~vpMbtKltPolygon ( )
virtual

Basic destructor.

Definition at line 69 of file vpMbtKltPolygon.cpp.

Member Function Documentation

void vpMbtPolygon::addPoint ( const unsigned int  n,
const vpPoint P 
)
inherited

Add a corner point to the list of polygon's corners.

Parameters
n: The index of the corner.
P: The point to add.

Definition at line 121 of file vpMbtPolygon.cpp.

References vpMbtPolygon::p.

Referenced by vpMbtDistanceLine::buildFrom(), vpMbKltTracker::initFaceFromCorners(), and vpMbEdgeTracker::initFaceFromCorners().

void vpMbtPolygon::changeFrame ( const vpHomogeneousMatrix cMo)
inherited

Project the 3D corner points into the image thanks to the pose of the camera.

Parameters
cMo: The pose of the camera.

Definition at line 133 of file vpMbtPolygon.cpp.

References vpPoint::changeFrame(), vpMbtPolygon::nbpt, vpMbtPolygon::p, and vpPoint::projection().

Referenced by vpMbtPolygon::getRoi(), vpMbtPolygon::getRoiClipped(), and vpMbtPolygon::isVisible().

void vpMbtKltPolygon::computeHomography ( const vpHomogeneousMatrix _cTc0,
vpHomography _cHc0 
)

compute the homography using a displacement matrix.

the homography is given by:

$ {}^cH_{c_0} = {}^cR_{c_0} + \frac{{}^cT_{c_0} . {}^tN}{d_0} $

Several internal variables are computed (dt, cRc0_0n)

Parameters
_cTc0: the displacement matrix of the camera between the initial position of the camera and the current camera position
_cHc0: the homography of the plane

Definition at line 247 of file vpMbtKltPolygon.cpp.

References vpHomogeneousMatrix::extract().

void vpMbtKltPolygon::computeInteractionMatrixAndResidu ( vpColVector _R,
vpMatrix _J 
)

Compute the interaction matrix and the residu vector for the face. The method assumes that these two objects are properly sized in order to be able to improve the speed with the use of SubCoVector and subMatrix.

Warning
The function preCompute must be called before the this method.
Parameters
_R: the residu vector
_J: the interaction matrix

Definition at line 158 of file vpMbtKltPolygon.cpp.

References vpPixelMeterConversion::convertPoint(), and vpMbtPolygon::index.

unsigned int vpMbtKltPolygon::computeNbDetectedCurrent ( const vpKltOpencv _tracker)

compute the number of point in this instanciation of the tracker that corresponds to the points of the face

Parameters
_tracker: the KLT tracker
Returns
the number of points that are tracked in this face and in this instanciation of the tracker

Definition at line 124 of file vpMbtKltPolygon.cpp.

References vpKltOpencv::getFeature(), and vpKltOpencv::getNbFeatures().

void vpMbtPolygon::computeRoiClipped ( const vpCameraParameters cam = vpCameraParameters())
inherited
void vpMbtKltPolygon::displayPrimitive ( const vpImage< unsigned char > &  _I)

Display the primitives tracked for the face.

Parameters
_I: The image where to display.

Definition at line 423 of file vpMbtKltPolygon.cpp.

References vpDisplay::displayCharString(), vpDisplay::displayCross(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpColor::red, vpMath::round(), vpImagePoint::set_i(), and vpImagePoint::set_j().

void vpMbtKltPolygon::displayPrimitive ( const vpImage< vpRGBa > &  _I)

Display the primitives tracked for the face.

Parameters
_I: The image where to display.

Definition at line 448 of file vpMbtKltPolygon.cpp.

References vpDisplay::displayCharString(), vpDisplay::displayCross(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpColor::red, vpMath::round(), vpImagePoint::set_i(), and vpImagePoint::set_j().

vpCameraParameters& vpMbtKltPolygon::getCameraParameters ( )
inline

Get the camera parameters of the face.

Returns
cam : the camera parameters of the face.

Definition at line 122 of file vpMbtKltPolygon.h.

unsigned int vpMbtPolygon::getClipping ( ) const
inlineinherited

Get the clipping used.

See also
vpMbtPolygonClipping
Returns
Clipping flags.

Definition at line 134 of file vpMbtPolygon.h.

Referenced by vpMbtDistanceLine::display(), vpMbtDistanceLine::initMovingEdge(), and vpMbtDistanceLine::updateMovingEdge().

vpColVector vpMbtKltPolygon::getCurrentNormal ( ) const
inline

Definition at line 124 of file vpMbtKltPolygon.h.

std::map<int, vpImagePoint>& vpMbtKltPolygon::getCurrentPoints ( )
inline

Definition at line 126 of file vpMbtKltPolygon.h.

std::map<int, int>& vpMbtKltPolygon::getCurrentPointsInd ( )
inline

Definition at line 128 of file vpMbtKltPolygon.h.

double vpMbtPolygon::getFarClippingDistance ( ) const
inlineinherited

Get the far distance for clipping.

Returns
Far clipping value.

Definition at line 141 of file vpMbtPolygon.h.

int vpMbtPolygon::getIndex ( ) const
inlineinherited

Get the index of the face.

Returns
index : the index of the face.

Definition at line 148 of file vpMbtPolygon.h.

unsigned int vpMbtKltPolygon::getInitialNumberPoint ( ) const
inline

Get the number of point that was belonging to the face at the initialisation

Returns
the number of initial point

Definition at line 135 of file vpMbtKltPolygon.h.

void vpMbtPolygon::getMinMaxRoi ( const std::vector< vpImagePoint > &  roi,
int &  i_min,
int &  i_max,
int &  j_min,
int &  j_max 
)
staticinherited

Definition at line 574 of file vpMbtPolygon.cpp.

Referenced by updateMask().

unsigned int vpMbtPolygon::getNbCornerInsideImage ( const vpImage< unsigned char > &  I,
const vpCameraParameters cam 
)
inherited

Static method to check the number of points of a region defined by the vector of image point that are inside the image.

Parameters
I: The image used for its size.
cam: The camera parameters.

Definition at line 552 of file vpMbtPolygon.cpp.

References vpMeterPixelConversion::convertPoint(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpMbtPolygon::nbCornersInsidePrev, vpMbtPolygon::nbpt, and vpMbtPolygon::p.

unsigned int vpMbtPolygon::getNbCornerInsidePrevImage ( ) const
inlineinherited

Return the number of corners at the previous computation.

Returns
number of corner of the face at the previous computation

Definition at line 162 of file vpMbtPolygon.h.

unsigned int vpMbtPolygon::getNbPoint ( ) const
inlineinherited

Return the number of corners.

Returns
number of corner of the face

Definition at line 155 of file vpMbtPolygon.h.

Referenced by vpMbEdgeTracker::addPolygon().

unsigned int vpMbtKltPolygon::getNbPointsCur ( ) const
inline

get the number of points detected in the last image.

Warning
to have the real number of points, the function computeNbDetectedCurrent must be called first.
Returns
the number of points detected in the current image

Definition at line 145 of file vpMbtKltPolygon.h.

double vpMbtPolygon::getNearClippingDistance ( ) const
inlineinherited

Get the near distance for clipping.

Returns
Near clipping value.

Definition at line 171 of file vpMbtPolygon.h.

vpPoint & vpMbtPolygon::getPoint ( const unsigned int  _index)
inherited

Get a reference to a corner.

Exceptions
vpException::dimensionErrorif the _index is out of range.
Parameters
_index: the index of the corner

Definition at line 92 of file vpMbtPolygon.cpp.

References vpException::dimensionError, vpMbtPolygon::nbpt, and vpMbtPolygon::p.

std::vector< vpImagePoint > vpMbtPolygon::getRoi ( const vpCameraParameters cam)
inherited

Get the region of interest in the image.

Warning
Suppose that changeFrame() has already been called.
Parameters
cam: camera parameters.
Returns
Image point corresponding to the region of interest.

Definition at line 450 of file vpMbtPolygon.cpp.

References vpMeterPixelConversion::convertPoint(), vpMbtPolygon::nbpt, and vpMbtPolygon::p.

Referenced by vpMbtPolygon::getRoi().

std::vector< vpImagePoint > vpMbtPolygon::getRoi ( const vpCameraParameters cam,
const vpHomogeneousMatrix cMo 
)
inherited

Get the region of interest in the image.

Parameters
cam: camera parameters.
cMo: pose.
Returns
Image point corresponding to the region of interest.

Definition at line 471 of file vpMbtPolygon.cpp.

References vpMbtPolygon::changeFrame(), and vpMbtPolygon::getRoi().

void vpMbtPolygon::getRoiClipped ( const vpCameraParameters cam,
std::vector< vpImagePoint > &  roi 
)
inherited

Get the region of interest clipped in the image.

Warning
Suppose that changeFrame() and computeRoiClipped() have already been called.
Parameters
cam: camera parameters.
roi: image point corresponding to the region of interest.

Definition at line 486 of file vpMbtPolygon.cpp.

References vpMeterPixelConversion::convertPoint(), and vpMbtPolygon::roiPointsClip.

Referenced by vpMbtPolygon::getRoiClipped(), init(), and updateMask().

void vpMbtPolygon::getRoiClipped ( const vpCameraParameters cam,
std::vector< vpImagePoint > &  roi,
const vpHomogeneousMatrix cMo 
)
inherited

Get the region of interest clipped in the image.

Parameters
cam: camera parameters.
cMo: pose.
roi: image point corresponding to the region of interest.

Definition at line 503 of file vpMbtPolygon.cpp.

References vpMbtPolygon::changeFrame(), vpMbtPolygon::computeRoiClipped(), and vpMbtPolygon::getRoiClipped().

void vpMbtPolygon::getRoiClipped ( const vpCameraParameters cam,
std::vector< std::pair< vpImagePoint, unsigned int > > &  roi 
)
inherited

Get the region of interest clipped in the image and the information to know if it's a clipped point.

Warning
Suppose that changeFrame() and computeRoiClipped() have already been called.
Parameters
cam: camera parameters.
roi: image point corresponding to the region of interest with clipping information.

Definition at line 519 of file vpMbtPolygon.cpp.

References vpMeterPixelConversion::convertPoint(), and vpMbtPolygon::roiPointsClip.

void vpMbtPolygon::getRoiClipped ( const vpCameraParameters cam,
std::vector< std::pair< vpImagePoint, unsigned int > > &  roi,
const vpHomogeneousMatrix cMo 
)
inherited

Get the region of interest clipped in the image and the information to know if it's a clipped point.

Parameters
cam: camera parameters.
roi: image point corresponding to the region of interest with clipping information.
cMo: pose.

Definition at line 536 of file vpMbtPolygon.cpp.

References vpMbtPolygon::changeFrame(), vpMbtPolygon::computeRoiClipped(), and vpMbtPolygon::getRoiClipped().

bool vpMbtKltPolygon::hasEnoughPoints ( ) const
inline

Definition at line 147 of file vpMbtKltPolygon.h.

void vpMbtKltPolygon::init ( const vpKltOpencv _tracker)

Initialise the face to track. All the points in the map, representing all the map detected in the image, are parsed in order to extract the id of the points that are indeed in the face.

Parameters
_tracker: ViSP OpenCV KLT Tracker.

Definition at line 80 of file vpMbtKltPolygon.cpp.

References vpPlane::getD(), vpKltOpencv::getFeature(), vpKltOpencv::getNbFeatures(), vpPlane::getNormal(), vpMbtPolygon::getRoiClipped(), vpColVector::normalize(), and vpMbtPolygon::p.

bool vpMbtPolygon::isAppearing ( ) const
inlineinherited

Definition at line 187 of file vpMbtPolygon.h.

bool vpMbtPolygon::isVisible ( const vpHomogeneousMatrix cMo,
const double  alpha,
const bool &  modulo = false 
)
virtualinherited

Check if the polygon is visible in the image and if the angle between the normal to the face and the line vector going from the optical center to the cog of the face is below the given threshold. To do that, the polygon is projected into the image thanks to the camera pose.

Parameters
cMo: The pose of the camera.
alpha: Maximum angle to detect if the face is visible (in rad).
modulo: Indicates if the test should also consider faces that are not oriented counter clockwise. If true, the orientation of the face is without importance.
Returns
Return true if the polygon is visible.

Definition at line 156 of file vpMbtPolygon.cpp.

References vpMbtPolygon::changeFrame(), vpColVector::crossProd(), vpColVector::dotProd(), vpPoint::get_X(), vpPoint::get_Y(), vpPoint::get_Z(), vpMbtPolygon::isappearing, vpMbtPolygon::isvisible, vpMbtPolygon::nbpt, vpColVector::normalize(), vpMbtPolygon::p, vpMath::rad(), vpPoint::set_X(), vpPoint::set_Y(), and vpPoint::set_Z().

bool vpMbtPolygon::isVisible ( ) const
inlineinherited

Definition at line 189 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::isVisible().

bool vpMbtPolygon::isVisible ( const vpHomogeneousMatrix cMo,
const bool &  depthTest = false 
)
inherited
Deprecated:
This method is deprecated since it is no more used since ViSP 2.7.2.

Check if the polygon is visible in the image. To do that, the polygon is projected into the image thanks to the camera pose.

Parameters
cMo: The pose of the camera.
depthTest: True if a face has to be entirely visible (in front of the camera). False if it can be partially visible.
Returns
Return true if the polygon is visible.

Definition at line 643 of file vpMbtPolygon.cpp.

References vpMbtPolygon::changeFrame(), vpMbtPolygon::isappearing, vpMbtPolygon::isvisible, vpMbtPolygon::isVisible(), vpMbtPolygon::nbpt, vpMbtPolygon::p, and vpMath::rad().

void vpMbtKltPolygon::removeOutliers ( const vpColVector _w,
const double &  threshold_outlier 
)

This method removes the outliers. A point is considered as outlier when its associated weight is below a given threshold (threshold_outlier).

Parameters
_w: Vector containing the weight of all the tracked points.
threshold_outlier: Threshold to specify wether or not a point has to be deleted.

Definition at line 382 of file vpMbtKltPolygon.cpp.

bool vpMbtPolygon::roiInsideImage ( const vpImage< unsigned char > &  I,
const std::vector< vpImagePoint > &  corners 
)
staticinherited

Static method to check whether the region defined by the vector of image point is contained entirely in the image.

Parameters
I: The image used for its size.
corners: The vector of points defining a region

Definition at line 615 of file vpMbtPolygon.cpp.

References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().

virtual void vpMbtKltPolygon::setCameraParameters ( const vpCameraParameters _cam)
inlinevirtual

Set the camera parameters

Parameters
_cam: the new camera parameters

Definition at line 158 of file vpMbtKltPolygon.h.

void vpMbtPolygon::setClipping ( const unsigned int &  flags)
inlineinherited

Specify which clipping to use.

See also
vpMbtPolygonClipping
Parameters
flags: New clipping flags.

Definition at line 198 of file vpMbtPolygon.h.

Referenced by vpMbEdgeTracker::addLine(), and vpMbEdgeTracker::setClipping().

void vpMbtPolygon::setFarClippingDistance ( const double &  dist)
inlineinherited

Set the far distance for clipping.

Parameters
dist: Far clipping value.

Definition at line 205 of file vpMbtPolygon.h.

References vpMbtPolygon::FAR_CLIPPING.

Referenced by vpMbEdgeTracker::addLine(), and vpMbEdgeTracker::setFarClippingDistance().

virtual void vpMbtPolygon::setIndex ( const int  i)
inlinevirtualinherited

Set the index of the face.

Parameters
i: the new index of the face.

Definition at line 212 of file vpMbtPolygon.h.

Referenced by vpMbEdgeTracker::addPolygon(), vpMbKltTracker::initFaceFromCorners(), and vpMbEdgeTracker::initFaceFromCorners().

void vpMbtPolygon::setNbPoint ( const unsigned int  nb)
virtualinherited

Set the number of points which are the corners of the polygon.

Parameters
nb: The number of corners.

Definition at line 106 of file vpMbtPolygon.cpp.

References vpMbtPolygon::nbpt, and vpMbtPolygon::p.

Referenced by vpMbtDistanceLine::buildFrom(), vpMbKltTracker::initFaceFromCorners(), and vpMbEdgeTracker::initFaceFromCorners().

void vpMbtPolygon::setNearClippingDistance ( const double &  dist)
inlineinherited

Set the near distance for clipping.

Parameters
dist: Near clipping value.

Definition at line 220 of file vpMbtPolygon.h.

References vpMbtPolygon::NEAR_CLIPPING.

Referenced by vpMbEdgeTracker::addLine(), and vpMbEdgeTracker::setNearClippingDistance().

void vpMbtKltPolygon::updateMask ( IplImage *  _mask,
unsigned int  _nb = 255,
unsigned int  _shiftBorder = 0 
)

Modification of all the pixels that are in the roi to the value of _nb ( default is 255).

Parameters
_mask: the mask to update (0, not in the object, _nb otherwise).
_nb: Optionnal value to set to the pixels included in the face.
_shiftBorder: Optionnal shift for the border in pixel (sort of built-in erosion) to avoid to consider pixels near the limits of the face.

Definition at line 318 of file vpMbtKltPolygon.cpp.

References vpCameraParameters::computeFov(), vpMbtPolygon::computeRoiClipped(), vpMbtPolygon::getMinMaxRoi(), and vpMbtPolygon::getRoiClipped().

Member Data Documentation

unsigned int vpMbtPolygon::clippingFlag
inherited

Clipping flag.

Definition at line 99 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::computeRoiClipped(), and vpMbtPolygon::vpMbtPolygon().

double vpMbtPolygon::distFarClip
inherited

Distance for near clipping.

Definition at line 103 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::vpMbtPolygon().

double vpMbtPolygon::distNearClip
inherited

Distance for near clipping.

Definition at line 101 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::vpMbtPolygon().

int vpMbtPolygon::index
inherited

Index of the polygon. Cannot be unsigned int because deafult value is -1.

Definition at line 85 of file vpMbtPolygon.h.

Referenced by computeInteractionMatrixAndResidu().

bool vpMbtPolygon::isappearing
inherited

flag to specify whether the face is appearing or not

Definition at line 93 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::isVisible(), and vpMbtPolygon::vpMbtPolygon().

bool vpMbtPolygon::isvisible
inherited

flag to specify whether the face is visible or not

Definition at line 91 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::isVisible(), vpMbtKltPolygon(), and vpMbtPolygon::vpMbtPolygon().

unsigned int vpMbtPolygon::nbCornersInsidePrev
inherited

Number of corners inside the image during the last call to getNbCornerInsideImage.

Definition at line 89 of file vpMbtPolygon.h.

Referenced by vpMbtPolygon::getNbCornerInsideImage(), and vpMbtPolygon::vpMbtPolygon().

std::vector<std::pair<vpPoint,unsigned int> > vpMbtPolygon::roiPointsClip
inherited