ViSP  2.9.0

#include <vpMbEdgeTracker.h>

+ Inheritance diagram for vpMbEdgeTracker:

Public Member Functions

 vpMbEdgeTracker ()
 
virtual ~vpMbEdgeTracker ()
 
void display (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
 
void display (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
 
virtual double getAngleAppear () const
 
virtual double getAngleDisappear () const
 
virtual unsigned int getClipping () const
 
vpMbHiddenFaces< vpMbtPolygon > & getFaces ()
 
virtual double getFarClippingDistance () const
 
double getFirstThreshold () const
 
virtual double getLambda () const
 
void getLline (std::list< vpMbtDistanceLine * > &linesList, const unsigned int level=0)
 
void getLcylinder (std::list< vpMbtDistanceCylinder * > &cylindersList, const unsigned int level=0)
 
void getMovingEdge (vpMe &p_me) const
 
virtual double getNearClippingDistance () const
 
unsigned int getNbPoints (const unsigned int level=0) const
 
unsigned int getNbPolygon () const
 
vpMbtPolygongetPolygon (const unsigned int index)
 
std::vector< bool > getScales () const
 
void loadConfigFile (const std::string &configFile)
 
void loadConfigFile (const char *configFile)
 
void loadModel (const std::string &cad_name)
 
void loadModel (const char *cad_name)
 
void reInitModel (const vpImage< unsigned char > &I, const char *cad_name, const vpHomogeneousMatrix &cMo)
 
void resetTracker ()
 
virtual void setAngleAppear (const double &a)
 
virtual void setAngleDisappear (const double &a)
 
virtual void setCameraParameters (const vpCameraParameters &camera)
 
virtual void setClipping (const unsigned int &flags)
 
void setDisplayMovingEdges (const bool displayMe)
 
virtual void setFarClippingDistance (const double &dist)
 
void setFirstThreshold (const double threshold1)
 
virtual void setLambda (const double gain)
 
void setMovingEdge (const vpMe &me)
 
virtual void setNearClippingDistance (const double &dist)
 
virtual void setOgreVisibilityTest (const bool &v)
 
virtual void setPose (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
 
void setScales (const std::vector< bool > &_scales)
 
void track (const vpImage< unsigned char > &I)
 
virtual void getCameraParameters (vpCameraParameters &camera) const
 
virtual vpMatrix getCovarianceMatrix () const
 
void getPose (vpHomogeneousMatrix &cMo_) const
 
vpHomogeneousMatrix getPose () const
 
virtual void initClick (const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false)
 
virtual void initClick (const vpImage< unsigned char > &I, const std::vector< vpPoint > &points3D_list, const std::string &displayFile="")
 
virtual void initFromPoints (const vpImage< unsigned char > &I, const std::string &initFile)
 
virtual void initFromPoints (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &points2D_list, const std::vector< vpPoint > &points3D_list)
 
virtual void initFromPose (const vpImage< unsigned char > &I, const std::string &initFile)
 
virtual void initFromPose (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
 
virtual void initFromPose (const vpImage< unsigned char > &I, const vpPoseVector &cPo)
 
void savePose (const std::string &filename)
 
virtual void setCovarianceComputation (const bool &flag)
 
void setDisplayFeatures (const bool displayF)
 
void setPoseSavingFilename (const std::string &filename)
 

Protected Member Functions

void addCylinder (const vpPoint &P1, const vpPoint &P2, const double r, const std::string &name="")
 
void addLine (vpPoint &p1, vpPoint &p2, int polygone=-1, std::string name="")
 
void addPolygon (vpMbtPolygon &p)
 
void cleanPyramid (std::vector< const vpImage< unsigned char > * > &_pyramid)
 
void computeVVS (const vpImage< unsigned char > &_I)
 
void downScale (const unsigned int _scale)
 
void init (const vpImage< unsigned char > &I)
 
virtual void initCylinder (const vpPoint &p1, const vpPoint &p2, const double radius, const unsigned int indexCylinder=0)
 
virtual void initFaceFromCorners (const std::vector< vpPoint > &_corners, const unsigned int _indexFace=-1)
 
void initMovingEdge (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
 
void initPyramid (const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
 
void reInitLevel (const unsigned int _lvl)
 
void reinitMovingEdge (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
 
void removeCylinder (const std::string &name)
 
void removeLine (const std::string &name)
 
void testTracking ()
 
void trackMovingEdge (const vpImage< unsigned char > &I)
 
void updateMovingEdge (const vpImage< unsigned char > &I)
 
void upScale (const unsigned int _scale)
 
void visibleFace (const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
 
void computeJTR (const vpMatrix &J, const vpColVector &R, vpMatrix &JTR)
 
virtual void extractGroup (SoVRMLGroup *sceneGraphVRML2, vpHomogeneousMatrix &transform, unsigned int &indexFace)
 
virtual void extractFaces (SoVRMLIndexedFaceSet *face_set, vpHomogeneousMatrix &transform, unsigned int &indexFace)
 
virtual void extractLines (SoVRMLIndexedLineSet *line_set)
 
virtual void extractCylinders (SoVRMLIndexedFaceSet *face_set, vpHomogeneousMatrix &transform)
 
vpPoint getGravityCenter (const std::vector< vpPoint > &_pts)
 
virtual void loadVRMLModel (const std::string &modelFile)
 
virtual void loadCAOModel (const std::string &modelFile)
 
Deprecated functions
vp_deprecated void visibleFace (const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
 

Protected Attributes

int compute_interaction
 
double lambda
 
vpMe me
 
std::vector< std::list< vpMbtDistanceLine * > > lines
 
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
 
unsigned int nline
 
unsigned int ncylinder
 
int index_polygon
 
vpMbHiddenFaces< vpMbtPolygonfaces
 
unsigned int nbvisiblepolygone
 
double percentageGdPt
 
std::vector< bool > scales
 
std::vector< const vpImage< unsigned char > * > Ipyramid
 
unsigned int scaleLevel
 
bool useOgre
 
double angleAppears
 
double angleDisappears
 
double distNearClip
 
double distFarClip
 
unsigned int clippingFlag
 
vpCameraParameters cam
 
vpHomogeneousMatrix cMo
 
std::string modelFileName
 
bool modelInitialised
 
std::string poseSavingFilename
 
bool computeCovariance
 
vpMatrix covarianceMatrix
 
bool displayFeatures
 

Detailed Description

Make the complete tracking of an object by using its CAD model.

This class allows to track an object or a scene given its 3D model. A video can be found in the http://www.irisa.fr/lagadic/visp/computer-vision.html web page. The Tutorial: Model-based tracking is also a good starting point to use this class.

The tracker requires the knowledge of the 3D model that could be provided in a vrml or in a cao file. The cao format is described in loadCAOModel(). It may also use an xml file used to tune the behavior of the tracker and an init file used to compute the pose at the very first image.

The following code shows the simplest way to use the tracker.

#include <visp/vpMbEdgeTracker.h>
#include <visp/vpImage.h>
#include <visp/vpImageIo.h>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpCameraParameters.h>
#include <visp/vpException.h>
#include <visp/vpDisplayX.h>
int main()
{
vpMbEdgeTracker tracker; // Create a model based tracker.
vpHomogeneousMatrix cMo; // Pose computed using the tracker.
// Acquire an image
vpImageIo::read(I, "cube.pgm");
#if defined VISP_HAVE_X11
display.init(I,100,100,"Mb Edge Tracker");
#endif
#if defined VISP_HAVE_XML2
tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker
#endif
tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file).
tracker.loadModel("cube.cao"); // Load the 3d model in cao format. No 3rd party library is required
tracker.initClick(I, "cube.init"); // Initialise manually the pose by clicking on the image points associated to the 3d points contained in the cube.init file.
while(true){
// Acquire a new image
tracker.track(I); // Track the object on this image
tracker.getPose(cMo); // Get the pose
tracker.display(I, cMo, cam, vpColor::darkRed, 1); // Display the model at the computed pose.
}
// Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeTracker::loadConfigFile()
return 0;
}

For application with large inter-images displacement, multi-scale tracking is also possible, by setting the number of scales used and by activating (or not) them using a vector of booleans, as presented in the following code:

...
vpHomogeneousMatrix cMo; // Pose computed using the tracker.
std::vector< bool > scales(3); //Three scales used
scales.push_back(true); //First scale : active
scales.push_back(false); //Second scale (/2) : not active
scales.push_back(true); //Third scale (/4) : active
tracker.setScales(scales); // Set active scales for multi-scale tracking
tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker
tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file).
...
// Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeTracker::loadConfigFile()
vpXmlParser::cleanup();

The tracker can also be used without display, in that case the initial pose must be known (object always at the same initial pose for example) or computed using another method:

#include <visp/vpMbEdgeTracker.h>
#include <visp/vpImage.h>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpCameraParameters.h>
#include <visp/vpImageIo.h>
int main()
{
vpMbEdgeTracker tracker; // Create a model based tracker.
vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker.
//acquire an image
vpImageIo::read(I, "cube.pgm"); // Example of acquisition
#if defined VISP_HAVE_XML2
tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker
#endif
tracker.loadModel("cube.cao"); // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used.
tracker.initFromPose(I, cMo); // initialize the tracker with the given pose.
while(true){
// acquire a new image
tracker.track(I); // track the object on this image
tracker.getPose(cMo); // get the pose
}
// Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeTracker::loadConfigFile()
return 0;
}

Finally it can be used not to track an object but just to display a model at a given pose:

#include <visp/vpMbEdgeTracker.h>
#include <visp/vpImage.h>
#include <visp/vpImageIo.h>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpCameraParameters.h>
#include <visp/vpDisplayX.h>
int main()
{
vpMbEdgeTracker tracker; // Create a model based tracker.
vpHomogeneousMatrix cMo; // Pose used to display the model.
// Acquire an image
vpImageIo::read(I, "cube.pgm");
#if defined VISP_HAVE_X11
display.init(I,100,100,"Mb Edge Tracker");
#endif
#if defined VISP_HAVE_XML2
tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker
#endif
tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file).
tracker.loadModel("cube.cao"); // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used.
while(true){
// acquire a new image
// Get the pose using any method
tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose.
}
// Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeTracker::loadConfigFile()
return 0;
}
Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 267 of file vpMbEdgeTracker.h.

Constructor & Destructor Documentation

vpMbEdgeTracker::vpMbEdgeTracker ( )

Basic constructor

Definition at line 77 of file vpMbEdgeTracker.cpp.

References faces, vpMbHiddenFaces< PolygonType >::getOgreContext(), scales, and vpAROgre::setWindowName().

vpMbEdgeTracker::~vpMbEdgeTracker ( )
virtual

Basic destructor useful to deallocate the memory.

Definition at line 94 of file vpMbEdgeTracker.cpp.

References cleanPyramid(), cylinders, Ipyramid, lines, and scales.

Member Function Documentation

void vpMbEdgeTracker::addCylinder ( const vpPoint P1,
const vpPoint P2,
const double  r,
const std::string &  name = "" 
)
protected

Add a cylinder to the list of cylinders.

Parameters
P1: The first extremity of the axis.
P2: The second extremity of the axis.
r: The radius of the cylinder.
name: the optional name of the cylinder

Definition at line 1396 of file vpMbEdgeTracker.cpp.

References vpMbtDistanceCylinder::buildFrom(), vpMbTracker::cam, cylinders, downScale(), vpMath::maximum(), me, ncylinder, vpMbtDistanceCylinder::p1, vpMbtDistanceCylinder::p2, vpMbtDistanceCylinder::radius, scales, vpMbtDistanceCylinder::setCameraParameters(), vpMbtDistanceCylinder::setIndex(), vpMbtDistanceCylinder::setMovingEdge(), vpMbtDistanceCylinder::setName(), and upScale().

Referenced by initCylinder().

void vpMbEdgeTracker::addLine ( vpPoint P1,
vpPoint P2,
int  polygone = -1,
std::string  name = "" 
)
protected

Add a line belonging to the $ index $ th polygone to the list of lines. It is defined by its two extremities.

If the line already exists, the ploygone's index is added to the list of polygon to which it belongs.

Parameters
P1: The first extremity of the line.
P2: The second extremity of the line.
polygone: The index of the polygon to which the line belongs.
name: the optional name of the line

Definition at line 1313 of file vpMbEdgeTracker.cpp.

References vpMbtDistanceLine::buildFrom(), vpMbTracker::cam, clippingFlag, distFarClip, distNearClip, downScale(), faces, vpMbtPolygon::FAR_CLIPPING, vpMbtDistanceLine::getPolygon(), vpMbtDistanceLine::hiddenface, vpMbtDistanceLine::Lindex_polygon, lines, me, vpMbtPolygon::NEAR_CLIPPING, nline, vpMbtPolygon::NO_CLIPPING, vpMbtDistanceLine::p1, vpMbtDistanceLine::p2, scales, vpMbtDistanceLine::setCameraParameters(), vpMbtPolygon::setClipping(), vpMbtPolygon::setFarClippingDistance(), vpMbtDistanceLine::setIndex(), vpMbtDistanceLine::setMovingEdge(), vpMbtDistanceLine::setName(), vpMbtPolygon::setNearClippingDistance(), and upScale().

Referenced by addPolygon().

void vpMbEdgeTracker::addPolygon ( vpMbtPolygon p)
protected

Add a polygon to the list of polygons.

Parameters
p: The polygon to add.

Definition at line 1458 of file vpMbEdgeTracker.cpp.

References addLine(), vpMbHiddenFaces< PolygonType >::addPolygon(), faces, vpMbtPolygon::getNbPoint(), index_polygon, vpMbtPolygon::p, and vpMbtPolygon::setIndex().

Referenced by initFaceFromCorners().

void vpMbEdgeTracker::cleanPyramid ( std::vector< const vpImage< unsigned char > * > &  _pyramid)
protected

Clean the pyramid of image allocated with the initPyramid() method. The vector has a size equal to zero at the end of the method.

Parameters
_pyramid: The pyramid of image to clean.

Definition at line 1991 of file vpMbEdgeTracker.cpp.

Referenced by vpMbEdgeKltTracker::init(), init(), vpMbEdgeKltTracker::setPose(), vpMbEdgeKltTracker::track(), track(), and ~vpMbEdgeTracker().

void vpMbTracker::computeJTR ( const vpMatrix interaction,
const vpColVector error,
vpMatrix JTR 
)
protectedinherited

Compute $ J^T R $, with J the interaction matrix and R the vector of residu.

Exceptions
vpMatrixException::incorrectMatrixSizeErrorif the sizes of the matrices do not allow the computation.
Warning
The JTR matrix is resized.
Parameters
interaction: The interaction matrix (size Nx6).
error: The residu vector (size Nx1).
JTR: The resulting JTR matrix (size 6x1).

Definition at line 1433 of file vpMbTracker.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, and vpMatrix::resize().

Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), and computeVVS().

void vpMbEdgeTracker::computeVVS ( const vpImage< unsigned char > &  _I)
protected

Compute the visual servoing loop to get the pose of the feature set.

Exceptions
vpTrackingException::notEnoughPointErrorif the number of detected feature is equal to zero.
Parameters
_I: The current image.

Definition at line 177 of file vpMbEdgeTracker.cpp.

References vpMbTracker::cam, vpMbtDistanceLine::closeToImageBorder(), vpMbTracker::cMo, compute_interaction, vpMbTracker::computeCovariance, vpMatrix::computeCovarianceMatrix(), vpMbtDistanceLine::computeInteractionMatrixError(), vpMbtDistanceCylinder::computeInteractionMatrixError(), vpMbTracker::computeJTR(), vpMbTracker::covarianceMatrix, cylinders, vpMatrix::diag(), vpExponentialMap::direct(), vpMbtDistanceLine::error, vpMbtDistanceCylinder::error, vpCameraParameters::get_px(), vpMeTracker::getMeList(), vpMatrix::getRows(), vpMeSite::getState(), vpMbtDistanceLine::hiddenface, vpMbtDistanceLine::initInteractionMatrixError(), vpMbtDistanceCylinder::initInteractionMatrixError(), vpHomogeneousMatrix::inverse(), vpMbHiddenFaces< PolygonType >::isAppearing(), vpMbtDistanceLine::L, vpMbtDistanceCylinder::L, lambda, vpMbtDistanceLine::Lindex_polygon, lines, vpMeSite::M_ESTIMATOR, vpMbtDistanceLine::meline, vpMbtDistanceCylinder::meline1, vpMbtDistanceCylinder::meline2, vpRobust::MEstimator(), vpMbtDistanceLine::nbFeature, vpMbtDistanceCylinder::nbFeature, vpMbtDistanceCylinder::nbFeaturel1, vpMbtDistanceCylinder::nbFeaturel2, vpMeSite::NO_SUPPRESSION, vpTrackingException::notEnoughPointError, vpMatrix::pseudoInverse(), vpMbtDistanceLine::Reinit, vpMbtDistanceCylinder::Reinit, vpColVector::resize(), scaleLevel, vpRobust::setIteration(), vpMbtDistanceLine::setMeanWeight(), vpMbtDistanceCylinder::setMeanWeight1(), vpMbtDistanceCylinder::setMeanWeight2(), vpMeSite::setState(), vpRobust::setThreshold(), vpMath::sign(), vpMath::sqr(), vpRobust::TUKEY, and vpERROR_TRACE.

Referenced by track().

void vpMbEdgeTracker::display ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cMo_,
const vpCameraParameters camera,
const vpColor col,
const unsigned int  thickness = 1,
const bool  displayFullModel = false 
)
virtual

Display the 3D model from a given position of the camera.

Parameters
I: The image.
cMo_: Pose used to project the 3D model into the image.
camera: The camera parameters.
col: The desired color.
thickness: The thickness of the lines.
displayFullModel: If true, the full model is displayed (even the non visible surfaces).

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 1072 of file vpMbEdgeTracker.cpp.

References cylinders, vpMbtDistanceLine::display(), vpMbHiddenFaces< PolygonType >::displayOgre(), faces, lines, scaleLevel, scales, and useOgre.

void vpMbEdgeTracker::display ( const vpImage< vpRGBa > &  I,
const vpHomogeneousMatrix cMo_,
const vpCameraParameters camera,
const vpColor col,
const unsigned int  thickness = 1,
const bool  displayFullModel = false 
)
virtual

Display the 3D model from a given position of the camera.

Parameters
I: The image.
cMo_: Pose used to project the 3D model into the image.
camera: The camera parameters.
col: The desired color.
thickness: The thickness of the lines.
displayFullModel: If true, the full model is displayed (even the non visible surfaces).

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 1110 of file vpMbEdgeTracker.cpp.

References cylinders, vpMbtDistanceLine::display(), vpMbHiddenFaces< PolygonType >::displayOgre(), faces, lines, scaleLevel, scales, and useOgre.

void vpMbEdgeTracker::downScale ( const unsigned int  _scale)
protected

Modify the camera parameters to have them corresponding to the current scale. The new parameters are divided by $ 2^{\_scale} $.

Parameters
_scale: Scale to use.

Definition at line 2060 of file vpMbEdgeTracker.cpp.

References vpMbTracker::cam, vpCameraParameters::get_K(), vpCameraParameters::initFromCalibrationMatrix(), and scaleLevel.

Referenced by addCylinder(), addLine(), vpMbEdgeKltTracker::init(), init(), vpMbEdgeKltTracker::setPose(), vpMbEdgeKltTracker::track(), and track().

void vpMbTracker::extractCylinders ( SoVRMLIndexedFaceSet *  face_set,
vpHomogeneousMatrix transform 
)
protectedvirtualinherited

Extract a cylinder to track from the VMRL model. This method calls the initCylinder() method implemented in the child class.

Warning
This method extract cylinder described using an indexed face set not a cylinder set since software such as AC3D or blender export a cylinder using this data type. the object name is used, if it begins with "cyl" then this method is called otherwise the extractFaces() is used.
Parameters
face_set: Pointer to the cylinder in the vrml format.
transform: Transformation matrix applied to the cylinder.

Definition at line 1282 of file vpMbTracker.cpp.

References vpException::badValue, vpException::dimensionError, vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), vpMbTracker::getGravityCenter(), vpMbTracker::initCylinder(), vpMath::maximum(), vpPoint::setWorldCoordinates(), and vpMatrix::sumSquare().

Referenced by vpMbTracker::extractGroup().

void vpMbTracker::extractFaces ( SoVRMLIndexedFaceSet *  face_set,
vpHomogeneousMatrix transform,
unsigned int &  indexFace 
)
protectedvirtualinherited

Extract a face of the object to track from the VMRL model. This method calls the initFaceFromCorners() method implemented in the child class.

Parameters
face_set: Pointer to the face in the vrml format.
transform: Transformation matrix applied to the face.
indexFace: Face index.

Definition at line 1228 of file vpMbTracker.cpp.

References vpMbTracker::initFaceFromCorners(), and vpPoint::setWorldCoordinates().

Referenced by vpMbTracker::extractGroup().

void vpMbTracker::extractGroup ( SoVRMLGroup *  sceneGraphVRML2,
vpHomogeneousMatrix transform,
unsigned int &  indexFace 
)
protectedvirtualinherited

Extract a VRML object Group.

Parameters
sceneGraphVRML2: Current node (either Transform, or Group node).
transform: Transformation matrix for this group.
indexFace: Index of the face.

Definition at line 1141 of file vpMbTracker.cpp.

References vpMbTracker::extractCylinders(), vpMbTracker::extractFaces(), and vpMbTracker::extractLines().

Referenced by vpMbTracker::loadVRMLModel().

void vpMbTracker::extractLines ( SoVRMLIndexedLineSet *  line_set)
protectedvirtualinherited

Extract a line of the object to track from the VMRL model. This method calls the initFaceFromCorners() method implemented in the child class.

Parameters
line_set: Pointer to the line in the vrml format.

Definition at line 1378 of file vpMbTracker.cpp.

References vpMbTracker::initFaceFromCorners(), and vpPoint::setWorldCoordinates().

Referenced by vpMbTracker::extractGroup().

virtual double vpMbEdgeTracker::getAngleAppear ( ) const
inlinevirtual

Return the angle used to test polygons appearance.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 342 of file vpMbEdgeTracker.h.

virtual double vpMbEdgeTracker::getAngleDisappear ( ) const
inlinevirtual

Return the angle used to test polygons disappearance.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 345 of file vpMbEdgeTracker.h.

virtual void vpMbTracker::getCameraParameters ( vpCameraParameters camera) const
inlinevirtualinherited

Get the camera parameters.

Parameters
camera: copy of the camera parameters used by the tracker.
Examples:
mbtEdgeKltTracking.cpp, mbtEdgeTracking.cpp, mbtKltTracking.cpp, tutorial-mb-edge-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, and tutorial-mb-klt-tracker.cpp.

Definition at line 158 of file vpMbTracker.h.

virtual unsigned int vpMbEdgeTracker::getClipping ( ) const
inlinevirtual

Get the clipping used.

See also
vpMbtPolygonClipping
Returns
Clipping flags.

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 354 of file vpMbEdgeTracker.h.

virtual vpMatrix vpMbTracker::getCovarianceMatrix ( ) const
inlinevirtualinherited

Get the covariance matrix.

Definition at line 163 of file vpMbTracker.h.

References vpTRACE.

vpMbHiddenFaces<vpMbtPolygon>& vpMbEdgeTracker::getFaces ( )
inline

Return a reference to the faces structure.

Definition at line 357 of file vpMbEdgeTracker.h.

virtual double vpMbEdgeTracker::getFarClippingDistance ( ) const
inlinevirtual

Get the far distance for clipping.

Returns
Far clipping value.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 364 of file vpMbEdgeTracker.h.

double vpMbEdgeTracker::getFirstThreshold ( ) const
inline

Definition at line 366 of file vpMbEdgeTracker.h.

vpPoint vpMbTracker::getGravityCenter ( const std::vector< vpPoint > &  pts)
protectedinherited

Compute the center of gravity of a set of point. This is used in the cylinder extraction to find the center of the circles.

Exceptions
vpException::dimensionErrorif the set is empty.
Parameters
pts: Set of point to extract the center of gravity.
Returns
Center of gravity of the set.

Definition at line 1349 of file vpMbTracker.cpp.

References vpException::dimensionError, vpPoint::get_oX(), and vpPoint::setWorldCoordinates().

Referenced by vpMbTracker::extractCylinders().

virtual double vpMbEdgeTracker::getLambda ( ) const
inlinevirtual

Get the value of the gain used to compute the control law.

Returns
the value for the gain.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 373 of file vpMbEdgeTracker.h.

void vpMbEdgeTracker::getLcylinder ( std::list< vpMbtDistanceCylinder * > &  cylindersList,
const unsigned int  level = 0 
)

Get the list of the cylinders tracked for the specified level. Each cylinder contains the list of the vpMeSite.

Exceptions
vpException::dimensionErrorif the second parameter does not correspond to an used level.
Parameters
level: Level corresponding to the list to return.
cylindersList: The list of the cylinders of the model.

Definition at line 2040 of file vpMbEdgeTracker.cpp.

References cylinders, vpException::dimensionError, and scales.

void vpMbEdgeTracker::getLline ( std::list< vpMbtDistanceLine * > &  linesList,
const unsigned int  level = 0 
)

Get the list of the lines tracked for the specified level. Each line contains the list of the vpMeSite.

Exceptions
vpException::dimensionErrorif the second parameter does not correspond to an used level.
Parameters
level: Level corresponding to the list to return.
linesList: The list of the lines of the model.

Definition at line 2016 of file vpMbEdgeTracker.cpp.

References vpException::dimensionError, lines, and scales.

void vpMbEdgeTracker::getMovingEdge ( vpMe p_me) const
inline

Get the moving edge parameters.

Returns
an instance of the moving edge parameters used by the tracker.

Definition at line 383 of file vpMbEdgeTracker.h.

unsigned int vpMbEdgeTracker::getNbPoints ( const unsigned int  level = 0) const

Return the number of good points (vpMeSite) tracked. A good point is a vpMeSite with its flag "suppress" equal to 0. Only these points are used during the virtual visual servoing stage.

Exceptions
vpException::dimensionErrorif level does not represent a used level.
Returns
the number of good points.

Definition at line 1735 of file vpMbEdgeTracker.cpp.

References cylinders, vpException::dimensionError, vpMeTracker::getMeList(), vpMbtDistanceLine::isVisible(), lines, vpMbtDistanceLine::meline, vpMbtDistanceCylinder::meline1, vpMbtDistanceCylinder::meline2, vpMeSite::NO_SUPPRESSION, and scales.

unsigned int vpMbEdgeTracker::getNbPolygon ( ) const

Get the number of polygon (face) representing the object to track.

Returns
Number of polygon.

Definition at line 1796 of file vpMbEdgeTracker.cpp.

References faces, and vpMbHiddenFaces< PolygonType >::size().

virtual double vpMbEdgeTracker::getNearClippingDistance ( ) const
inlinevirtual

Get the near distance for clipping.

Returns
Near clipping value.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 390 of file vpMbEdgeTracker.h.

vpMbtPolygon * vpMbEdgeTracker::getPolygon ( const unsigned int  index)

Return the polygon (face) "index".

Exceptions
vpException::dimensionErrorif index does not represent a good polygon.
Parameters
index: Index of the polygon to return.
Returns
Pointer to the polygon index.

Definition at line 1781 of file vpMbEdgeTracker.cpp.

References vpException::dimensionError, faces, and vpMbHiddenFaces< PolygonType >::size().

void vpMbTracker::getPose ( vpHomogeneousMatrix cMo_) const
inlineinherited

Get the current pose between the object and the camera. cMo is the matrix which can be used to express coordinates from the object frame to camera frame.

Parameters
cMo_: the pose
Examples:
mbtEdgeKltTracking.cpp, mbtEdgeTracking.cpp, mbtKltTracking.cpp, tutorial-mb-edge-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, and tutorial-mb-klt-tracker.cpp.

Definition at line 177 of file vpMbTracker.h.

vpHomogeneousMatrix vpMbTracker::getPose ( ) const
inlineinherited

Get the current pose between the object and the camera. cMo is the matrix which can be used to express coordinates from the object frame to camera frame.

Returns
the current pose

Definition at line 186 of file vpMbTracker.h.

std::vector<bool> vpMbEdgeTracker::getScales ( ) const
inline

Return the scales levels used for the tracking.

Returns
The scales levels used for the tracking.

Definition at line 401 of file vpMbEdgeTracker.h.

void vpMbTracker::initClick ( const vpImage< unsigned char > &  I,
const std::string &  initFile,
const bool  displayHelp = false 
)
virtualinherited

Initialise the tracking by clicking on the image points corresponding to the 3D points (object frame) in the file initFile. The structure of this file is (without the comments):

4 // Number of points in the file (minimum is four)
0.01 0.01 0.01 // \
... // | 3D coordinates in the object basis
0.01 -0.01 -0.01 // /
Parameters
I: Input image
initFile: File containing the points where to click
displayHelp: Optionnal display of an image ( 'initFile.ppm' ). This image may be used to show where to click.
Exceptions
vpException::ioError: The file specified in initFile doesn't exist.
See also
setPathNamePoseSaving()
Examples:
mbtEdgeKltTracking.cpp, mbtEdgeTracking.cpp, mbtKltTracking.cpp, tutorial-mb-edge-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, and tutorial-mb-klt-tracker.cpp.

Definition at line 131 of file vpMbTracker.cpp.

References vpPose::addPoint(), vpException::badValue, vpHomogeneousMatrix::buildFrom(), vpMouseButton::button1, vpMbTracker::cam, vpPose::clearPoint(), vpMbTracker::cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, vpMbTracker::display(), vpDisplay::display(), vpDisplay::displayCharString(), vpDisplay::displayCross(), vpDisplay::displayFrame(), vpDisplay::displayPoint(), vpDisplay::flush(), vpDisplay::getClick(), vpColor::green, vpDisplayOpenCV::init(), vpMbTracker::init(), vpException::ioError, vpPose::LAGRANGE, vpMbTracker::poseSavingFilename, vpImageIo::read(), vpColor::red, vpMbTracker::savePose(), vpPoint::set_x(), vpPoint::set_y(), vpHomogeneousMatrix::setIdentity(), vpPoint::setWorldCoordinates(), and vpPose::VIRTUAL_VS.

void vpMbTracker::initClick ( const vpImage< unsigned char > &  I,
const std::vector< vpPoint > &  points3D_list,
const std::string &  displayFile = "" 
)
virtualinherited
void vpMbEdgeTracker::initCylinder ( const vpPoint p1,
const vpPoint p2,
const double  radius,
const unsigned int  indexCylinder = 0 
)
protectedvirtual

Add a cylinder to track from tow points on the axis (defining the length of the cylinder) and its radius.

Parameters
p1: First point on the axis.
p2: Second point on the axis.
radius: Radius of the cylinder.
indexCylinder: Index of the cylinder.

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 1620 of file vpMbEdgeTracker.cpp.

References addCylinder(), and ncylinder.

Referenced by vpMbEdgeKltTracker::initCylinder().

void vpMbEdgeTracker::initFaceFromCorners ( const std::vector< vpPoint > &  _corners,
const unsigned int  _indexFace = -1 
)
protectedvirtual

Add a face to track from its corners (in the object frame). This method is called from the loadModel() one to add a face of the object to track. The initialization of the face depends on the primitive to track.

Parameters
_corners: The vector of corners representing the face.
_indexFace: The index of the face.

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 1595 of file vpMbEdgeTracker.cpp.

References vpMbtPolygon::addPoint(), addPolygon(), vpMbtPolygon::setIndex(), and vpMbtPolygon::setNbPoint().

Referenced by vpMbEdgeKltTracker::initFaceFromCorners().

void vpMbTracker::initFromPoints ( const vpImage< unsigned char > &  I,
const std::string &  initFile 
)
virtualinherited

Initialise the tracking by reading the 3D points (object frame) and the image points in initFile. The structure of this file is (without the comments):

4 // Number of 3D points in the file (minimum is four)
0.01 0.01 0.01 // \
... // | 3D coordinates in meters in the object frame
0.01 -0.01 -0.01 // /
4 // Number of image points in the file (has to be the same as the number of 3D points)
100 200 // \
... // | 2D coordinates in pixel in the image
50 10 // /
Parameters
I: Input image
initFile: Path to the file containing all the points.

Definition at line 469 of file vpMbTracker.cpp.

References vpPose::addPoint(), vpException::badValue, vpMbTracker::cam, vpMbTracker::cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, vpMbTracker::init(), vpException::ioError, vpPose::LAGRANGE, vpPoint::set_x(), vpPoint::set_y(), vpPoint::setWorldCoordinates(), vpPose::VIRTUAL_VS, and vpERROR_TRACE.

void vpMbTracker::initFromPoints ( const vpImage< unsigned char > &  I,
const std::vector< vpImagePoint > &  points2D_list,
const std::vector< vpPoint > &  points3D_list 
)
virtualinherited

Initialise the tracking with the list of image points (points2D_list) and the list of corresponding 3D points (object frame) (points3D_list).

Parameters
I: Input image
points2D_list: List of image points.
points3D_list: List of 3D points (object frame).

Definition at line 554 of file vpMbTracker.cpp.

References vpPose::addPoint(), vpMbTracker::cam, vpMbTracker::cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, vpMbTracker::init(), vpPose::LAGRANGE, vpPoint::set_x(), vpPoint::set_y(), vpPoint::setWorldCoordinates(), vpPose::VIRTUAL_VS, and vpERROR_TRACE.

void vpMbTracker::initFromPose ( const vpImage< unsigned char > &  I,
const std::string &  initFile 
)
virtualinherited

Initialise the tracking thanks to the pose in vpPoseVector format, and read in the file initFile. The structure of this file is (without the comments):

// The six value of the pose vector
0.0000 // \
0.0000 // |
1.0000 // | Exemple of value for the pose vector where Z = 1 meter
0.0000 // |
0.0000 // |
0.0000 // /

Where the three firsts lines refer to the translation and the three last to the rotation in thetaU parametrisation (see vpThetaUVector).

Parameters
I: Input image
initFile: Path to the file containing the pose.
Examples:
mbtEdgeKltTracking.cpp, mbtEdgeTracking.cpp, and mbtKltTracking.cpp.

Definition at line 609 of file vpMbTracker.cpp.

References vpHomogeneousMatrix::buildFrom(), vpMbTracker::cMo, vpMbTracker::init(), and vpException::ioError.

Referenced by vpMbTracker::initFromPose(), and reInitModel().

void vpMbTracker::initFromPose ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cMo_ 
)
virtualinherited

Initialise the tracking thanks to the pose.

Parameters
I: Input image
cMo_: Pose matrix.

Definition at line 644 of file vpMbTracker.cpp.

References vpMbTracker::cMo, and vpMbTracker::init().

void vpMbTracker::initFromPose ( const vpImage< unsigned char > &  I,
const vpPoseVector cPo 
)
virtualinherited

Initialise the tracking thanks to the pose vector.

Parameters
I: Input image
cPo: Pose vector.

Definition at line 656 of file vpMbTracker.cpp.

References vpMbTracker::initFromPose().

void vpMbEdgeTracker::initMovingEdge ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix _cMo 
)
protected

Initialize the moving edge thanks to a given pose of the camera. The 3D model is projected into the image to create moving edges along the lines.

Parameters
I: The image.
_cMo: The pose of the camera used to initialize the moving edges.

Definition at line 1146 of file vpMbEdgeTracker.cpp.

References cylinders, vpMbtDistanceLine::hiddenface, vpMbtDistanceLine::initMovingEdge(), vpMbtDistanceCylinder::initMovingEdge(), vpMbHiddenFaces< PolygonType >::isVisible(), vpMbtDistanceLine::Lindex_polygon, lines, vpMbtDistanceLine::meline, vpMbtDistanceCylinder::meline1, vpMbtDistanceCylinder::meline2, scaleLevel, and vpMbtDistanceLine::setVisible().

Referenced by vpMbEdgeKltTracker::init(), init(), vpMbEdgeKltTracker::postTracking(), vpMbEdgeKltTracker::setPose(), vpMbEdgeKltTracker::track(), and track().

void vpMbEdgeTracker::initPyramid ( const vpImage< unsigned char > &  _I,
std::vector< const vpImage< unsigned char > * > &  _pyramid 
)
protected

Compute the pyramid of image associated to the image in parameter. The scales computed are the ones corresponding to the scales attribute of the class. If OpenCV is detected, the functions used to computed a smoothed pyramid come from OpenCV, otherwise a simple subsampling (no smoothing, no interpolation) is realized.

Warning
The pyramid contains pointers to vpImage. To properly deallocate the pyramid. All the element but the first (which is a pointer to the input image) must be freed. A proper cleaning is implemented in the cleanPyramid() method.
Parameters
_I: The input image.
_pyramid: The pyramid of image to build from the input image.

Definition at line 1945 of file vpMbEdgeTracker.cpp.

References vpImage< Type >::bitmap, vpImageConvert::convert(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and scales.

Referenced by vpMbEdgeKltTracker::init(), init(), vpMbEdgeKltTracker::setPose(), vpMbEdgeKltTracker::track(), and track().

void vpMbTracker::loadCAOModel ( const std::string &  modelFile)
protectedvirtualinherited

Load a 3D model contained in a .cao file.

the structure of the file is (without the comments) :

V1
8 // Number of points describing the object
0.01 0.01 0.01 // \
... // | coordinates of the points in the object frame (in m.)
0.01 0.01 0.01 // /
3 // Number of lines to track.
0 2 // \
1 4 // | Index of the points representing the extremities of the lines
1 5 // /
0 // Number of polygon (face) to track using the line previously described
// Face described as follow : nbLine IndexLine1 indexLine2 ... indexLineN
3 // Number of polygon (face) to track using the line previously described
4 0 2 3 4 // Face described as follow : nbPoint IndexPoint1 IndexPoint2 ... IndexPointN
4 1 3 5 7
3 1 5 6
1 // Number of cylinder
6 7 0.05 // Index of the limits points on the axis (used to know the 'height' of the cylinder) and radius of the cyclinder (in m.)
Parameters
modelFile: Full name of the .CAO file containing the model.

Definition at line 838 of file vpMbTracker.cpp.

References vpException::badValue, vpMbTracker::initCylinder(), vpMbTracker::initFaceFromCorners(), vpException::ioError, vpPoint::setWorldCoordinates(), and vpTRACE.

Referenced by vpMbTracker::loadModel().

void vpMbEdgeTracker::loadConfigFile ( const std::string &  configFile)
virtual

Load the xml configuration file. An example of such a file is provided in loadConfigFile(const char*) documentation. From the configuration file initialize the parameters corresponding to the objects: moving-edges, camera and visibility angles.

Warning
To clean up memory allocated by the xml library, the user has to call vpXmlParser::cleanup() before the exit().
Parameters
configFile: full name of the xml file.
See also
loadConfigFile(const char*), vpXmlParser::cleanup()

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 961 of file vpMbEdgeTracker.cpp.

void vpMbEdgeTracker::loadConfigFile ( const char *  configFile)

Load the xml configuration file. From the configuration file initialize the parameters corresponding to the objects: moving-edges, camera and visibility angles.

Warning
To clean up memory allocated by the xml library, the user has to call vpXmlParser::cleanup() before the exit().
Exceptions
vpException::ioErrorif the file has not been properly parsed (file not found or wrong format for the data).
Parameters
configFile: full name of the xml file.

The XML configuration file has the following form:

<?xml version="1.0"?>
<conf>
<ecm>
<mask>
<size>5</size>
<nb_mask>180</nb_mask>
</mask>
<range>
<tracking>7</tracking>
</range>
<contrast>
<edge_threshold>5000</edge_threshold>
<mu1>0.5</mu1>
<mu2>0.5</mu2>
</contrast>
</ecm>
<sample>
<step>4</step>
<nb_sample>250</nb_sample>
</sample>
<face>
<near_clipping>0.01</near_clipping>
<far_clipping>0.90</far_clipping>
<fov_clipping>1</fov_clipping>
</face>
<camera>
<u0>320</u0>
<v0>240</v0>
<px>686.24</px>
<py>686.24</py>
</camera>
</conf>
See also
loadConfigFile(const std::string&), vpXmlParser::cleanup()

Definition at line 1017 of file vpMbEdgeTracker.cpp.

References angleAppears, angleDisappears, vpMbTracker::cam, clippingFlag, vpMath::deg(), vpMbtPolygon::FOV_CLIPPING, vpMbXmlParser::getAngleAppear(), vpMbXmlParser::getAngleDisappear(), vpMbXmlParser::getCameraParameters(), vpMbXmlParser::getFarClippingDistance(), vpMbXmlParser::getFovClipping(), vpMbtXmlParser::getMe(), vpMbXmlParser::getNearClippingDistance(), vpMbXmlParser::hasFarClippingDistance(), vpMbXmlParser::hasNearClippingDistance(), vpException::ioError, me, vpMbtXmlParser::parse(), vpMath::rad(), vpMbXmlParser::setAngleAppear(), vpMbXmlParser::setAngleDisappear(), vpMbXmlParser::setCameraParameters(), setCameraParameters(), setClipping(), setFarClippingDistance(), vpMbtXmlParser::setMovingEdge(), setMovingEdge(), setNearClippingDistance(), vpERROR_TRACE, and vpTRACE.

void vpMbEdgeTracker::loadModel ( const std::string &  file)
virtual

Load a 3D model contained in a file.

Parameters
file: Full name the file containing the 3D model description. The extension of this file is either .wrl or .cao.
See also
vpMbTracker::loadModel()

Reimplemented from vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 1581 of file vpMbEdgeTracker.cpp.

References vpMbTracker::loadModel().

Referenced by reInitModel().

void vpMbEdgeTracker::loadModel ( const char *  file)

Load a 3D model contained in a file. This file is either a vrml or a cao file.

Parameters
file: Full name the file containing the 3D model description. The extension of this file is either .wrl or .cao.
See also
vpMbTracker::loadModel()

Definition at line 1566 of file vpMbEdgeTracker.cpp.

References vpMbTracker::loadModel().

void vpMbTracker::loadVRMLModel ( const std::string &  modelFile)
protectedvirtualinherited

Load the 3D model of the object from a vrml file. Only LineSet and FaceSet are extracted from the vrml file.

Warning
When this class is called, remember that you have to call Call SoDD::finish() before ending the program.
int main()
{
...
#ifdef VISP_HAVE_COIN
SoDB::finish();
#endif
}
The cylinders extracted using this method do not use the Cylinder keyword of vrml since vrml exporter such as Blender or AC3D consider a cylinder as an IndexedFaceSet. To test whether an indexedFaceSet is a cylinder or not, the name of the geometry is read. If the name begins with "cyl" then the faceset is supposed to be a cylinder. For example, the line
geometry DEF cyl_cylinder1 IndexedFaceSet
defines a cylinder named cyl_cylinder1.
Exceptions
vpException::fatalErrorif the file cannot be open.
Parameters
modelFile: The full name of the file containing the 3D model.

Definition at line 763 of file vpMbTracker.cpp.

References vpMbTracker::extractGroup(), vpException::fatalError, and vpERROR_TRACE.

Referenced by vpMbTracker::loadModel().

void vpMbEdgeTracker::reInitLevel ( const unsigned int  _lvl)
protected

Re initialize the moving edges associated to a given level. This method is used to re-initialize the level if the tracking failed on this level but succeeded on the other one.

Parameters
_lvl: The level to re-initialize.

Definition at line 2105 of file vpMbEdgeTracker.cpp.

References vpMbTracker::cMo, cylinders, Ipyramid, lines, vpMbtDistanceLine::reinitMovingEdge(), vpMbtDistanceCylinder::reinitMovingEdge(), scaleLevel, trackMovingEdge(), and updateMovingEdge().

Referenced by track().

void vpMbEdgeTracker::reInitModel ( const vpImage< unsigned char > &  I,
const char *  cad_name,
const vpHomogeneousMatrix cMo_ 
)

Re-initialize the model used by the tracker.

Parameters
I: The image containing the object to initialize.
cad_name: Path to the file containing the 3D model description.
cMo_: The new vpHomogeneousMatrix between the camera and the new model

Definition at line 1686 of file vpMbEdgeTracker.cpp.

References vpMbTracker::cMo, cylinders, faces, index_polygon, vpMbTracker::initFromPose(), lines, loadModel(), nbvisiblepolygone, ncylinder, nline, vpMbHiddenFaces< PolygonType >::reset(), scales, and vpHomogeneousMatrix::setIdentity().

void vpMbEdgeTracker::reinitMovingEdge ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix _cMo 
)
protected

Reinitialize the lines if it is required.

A line is reinitialized if the 2D line do not match enough with the projected 3D line.

Parameters
I: the image.
_cMo: the pose of the used to re-initialize the moving edges

Definition at line 1263 of file vpMbEdgeTracker.cpp.

References cylinders, vpMbtDistanceLine::isVisible(), lines, vpMbtDistanceLine::Reinit, vpMbtDistanceCylinder::Reinit, vpMbtDistanceLine::reinitMovingEdge(), vpMbtDistanceCylinder::reinitMovingEdge(), and scaleLevel.

Referenced by vpMbEdgeKltTracker::postTracking(), and track().

void vpMbEdgeTracker::removeCylinder ( const std::string &  name)
protected

Remove a cylinder by its name.

Parameters
name: The name of the cylinder to remove.

Definition at line 1435 of file vpMbEdgeTracker.cpp.

References cylinders, vpMbtDistanceCylinder::getName(), and scales.

void vpMbEdgeTracker::removeLine ( const std::string &  name)
protected

Remove a line using its name.

Parameters
name: The name of the line to remove.

Definition at line 1367 of file vpMbEdgeTracker.cpp.

References vpMbtDistanceLine::getName(), lines, and scales.

void vpMbEdgeTracker::resetTracker ( )
virtual

Reset the tracker. The model is removed and the pose is set to identity. The tracker needs to be initialized with a new model and a new pose.

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 1634 of file vpMbEdgeTracker.cpp.

References angleAppears, angleDisappears, clippingFlag, vpMbTracker::cMo, compute_interaction, cylinders, faces, index_polygon, lambda, lines, nbvisiblepolygone, ncylinder, nline, vpMbtPolygon::NO_CLIPPING, percentageGdPt, vpMath::rad(), vpMbHiddenFaces< PolygonType >::reset(), scales, vpHomogeneousMatrix::setIdentity(), and setScales().

Referenced by vpMbEdgeKltTracker::resetTracker().

void vpMbTracker::savePose ( const std::string &  filename)
inherited

Save the pose in the given filename

Parameters
filename: Path to the file used to save the pose.

Definition at line 667 of file vpMbTracker.cpp.

References vpPoseVector::buildFrom(), and vpMbTracker::cMo.

Referenced by vpMbTracker::initClick().

virtual void vpMbEdgeTracker::setAngleAppear ( const double &  a)
inlinevirtual

Set the angle used to test polygons appearance. If the angle between the normal of the polygon and the line going from the camera to the polygon center has a value lower than this parameter, the polygon is considered as appearing. The polygon will then be tracked.

Warning
This angle will only be used when setOgreVisibilityTest(true) is called.
Parameters
a: new angle in radian.

Reimplemented in vpMbEdgeKltTracker.

Examples:
tutorial-mb-edge-tracker.cpp.

Definition at line 423 of file vpMbEdgeTracker.h.

Referenced by vpMbEdgeKltTracker::setAngleAppear().

virtual void vpMbEdgeTracker::setAngleDisappear ( const double &  a)
inlinevirtual

Set the angle used to test polygons disappearance. If the angle between the normal of the polygon and the line going from the camera to the polygon center has a value greater than this parameter, the polygon is considered as disappearing. The tracking of the polygon will then be stopped.

Warning
This angle will only be used when setOgreVisibilityTest(true) is called.
Parameters
a: new angle in radian.

Reimplemented in vpMbEdgeKltTracker.

Examples:
tutorial-mb-edge-tracker.cpp.

Definition at line 437 of file vpMbEdgeTracker.h.

Referenced by vpMbEdgeKltTracker::setAngleDisappear().

virtual void vpMbEdgeTracker::setCameraParameters ( const vpCameraParameters camera)
inlinevirtual

Set the camera parameters.

Parameters
camera: the new camera parameters

Reimplemented from vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 444 of file vpMbEdgeTracker.h.

Referenced by loadConfigFile(), and vpMbEdgeKltTracker::setCameraParameters().

void vpMbEdgeTracker::setClipping ( const unsigned int &  flags)
virtual

Specify which clipping to use.

See also
vpMbtPolygonClipping
Parameters
flags: New clipping flags.

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 1914 of file vpMbEdgeTracker.cpp.

References clippingFlag, vpMbtDistanceLine::getPolygon(), lines, scales, and vpMbtPolygon::setClipping().

Referenced by vpMbEdgeKltTracker::loadConfigFile(), loadConfigFile(), and vpMbEdgeKltTracker::setClipping().

virtual void vpMbTracker::setCovarianceComputation ( const bool &  flag)
inlinevirtualinherited

Set if the covaraince matrix has to be computed.

Parameters
flag: True if the covariance has to be computed, false otherwise

Definition at line 240 of file vpMbTracker.h.

void vpMbTracker::setDisplayFeatures ( const bool  displayF)
inlineinherited

Enable to display the features.

Parameters
displayF: set it to true to display the features.
Examples:
mbtEdgeKltTracking.cpp, mbtKltTracking.cpp, tutorial-mb-edge-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, and tutorial-mb-klt-tracker.cpp.

Definition at line 247 of file vpMbTracker.h.

void vpMbEdgeTracker::setDisplayMovingEdges ( const bool  displayMe)
inline

Enable to display the points along the line 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.
Parameters
displayMe: set it to true to display the points.
Examples:
mbtEdgeTracking.cpp.

Definition at line 472 of file vpMbEdgeTracker.h.

void vpMbEdgeTracker::setFarClippingDistance ( const double &  dist)
virtual
void vpMbEdgeTracker::setFirstThreshold ( const double  threshold1)
inline

Set the first threshold used to check if the tracking failed. It corresponds to the percentage of good point which is necessary.

The condition which has to be be satisfied is the following : $ nbGoodPoint > threshold1 \times (nbGoodPoint + nbBadPoint)$.

The threshold is ideally between 0 and 1.

Parameters
threshold1: The new value of the threshold.

Definition at line 485 of file vpMbEdgeTracker.h.

virtual void vpMbEdgeTracker::setLambda ( const double  gain)
inlinevirtual

Set the value of the gain used to compute the control law.

Parameters
gain: the desired value for the gain.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 492 of file vpMbEdgeTracker.h.

Referenced by vpMbEdgeKltTracker::setLambda().

void vpMbEdgeTracker::setMovingEdge ( const vpMe p_me)

Set the moving edge parameters.

Parameters
p_me: an instance of vpMe containing all the desired parameters
Examples:
mbtEdgeKltTracking.cpp, mbtEdgeTracking.cpp, tutorial-mb-edge-tracker.cpp, and tutorial-mb-hybrid-tracker.cpp.

Definition at line 130 of file vpMbEdgeTracker.cpp.

References cylinders, lines, me, scales, and vpMbtDistanceCylinder::setMovingEdge().

Referenced by vpMbEdgeKltTracker::loadConfigFile(), and loadConfigFile().

void vpMbEdgeTracker::setNearClippingDistance ( const double &  dist)
virtual
void vpMbEdgeTracker::setOgreVisibilityTest ( const bool &  v)
virtual

Use Ogre3D for visibility tests

Warning
This function has to be called before the initialization of the tracker.
Parameters
v: True to use it, False otherwise

Reimplemented in vpMbEdgeKltTracker.

Examples:
mbtEdgeTracking.cpp, and tutorial-mb-edge-tracker.cpp.

Definition at line 157 of file vpMbEdgeTracker.cpp.

References useOgre.

void vpMbEdgeTracker::setPose ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cdMo 
)
virtual

Set the pose to be used in entry of the next call to the track() function. This pose will be just used once.

Warning
This function has to be called after the initialization of the tracker.
Parameters
I: image corresponding to the desired pose.
cdMo: Pose to affect.

Implements vpMbTracker.

Reimplemented in vpMbEdgeKltTracker.

Definition at line 932 of file vpMbEdgeTracker.cpp.

References vpMbTracker::cMo, init(), lines, vpMbtDistanceLine::meline, and scaleLevel.

void vpMbTracker::setPoseSavingFilename ( const std::string &  filename)
inlineinherited

Set the filename used to save the initial pose computed using the initClick() method. It is also used to read a previous pose in the same method. If the file is not set then, the initClick() method will create a .0.pos file in the root directory. This directory is the path to the file given to the method initClick() used to know the coordinates in the object frame.

Parameters
filename: The new filename.

Definition at line 269 of file vpMbTracker.h.

void vpMbEdgeTracker::setScales ( const std::vector< bool > &  scale)

Set the scales to use to realize the tracking. The vector of boolean activates or not the scales to set for the object tracking. The first element of the list correspond to the tracking on the full image, the second element corresponds to the tracking on an image subsampled by two.

Using multi scale tracking allows to track the object with greater moves. It requires the computation of a pyramid of images, but the total tracking can be faster than a tracking based only on the full scale. The pose is computed from the smallest image to the biggest. This may be dangerous if the object to track is small in the image, because the subsampled scale(s) will have only few points to compute the pose (it could result in a loss of precision).

Warning
This method must be used before the tracker has been initialized ( before the call of the loadConfigFile() or loadModel() methods).
At least one level must be activated.
Parameters
scale: The vector describing the levels to use.

Definition at line 1822 of file vpMbEdgeTracker.cpp.

References cylinders, lines, scales, and vpERROR_TRACE.

Referenced by resetTracker().

void vpMbEdgeTracker::updateMovingEdge ( const vpImage< unsigned char > &  I)
protected
void vpMbEdgeTracker::upScale ( const unsigned int  _scale)
protected

Modify the camera parameters to have them corresponding to the current scale. The new parameters are multiplied by $ 2^{\_scale} $.

Parameters
_scale: Scale to use.

Definition at line 2082 of file vpMbEdgeTracker.cpp.

References vpMbTracker::cam, vpCameraParameters::get_K(), vpCameraParameters::initFromCalibrationMatrix(), and scaleLevel.

Referenced by addCylinder(), addLine(), vpMbEdgeKltTracker::init(), init(), vpMbEdgeKltTracker::setPose(), vpMbEdgeKltTracker::track(), and track().

void vpMbEdgeTracker::visibleFace ( const vpImage< unsigned char > &  _I,
const vpHomogeneousMatrix _cMo,
bool &  newvisibleline 
)
protected

Detect the visible faces in the image and says if a new one appeared.

Warning
If in one iteration one face appears and one disappears, then the function will not detect the new face.
Parameters
_I: Image to test if a face is entirely in the image.
_cMo: The pose of the camera used to project the 3D model into the image.
newvisibleline: This parameter is set to true if a new face appeared.

Definition at line 1526 of file vpMbEdgeTracker.cpp.

References angleAppears, angleDisappears, vpMbTracker::cam, faces, nbvisiblepolygone, vpMbHiddenFaces< PolygonType >::setVisible(), vpMbHiddenFaces< PolygonType >::setVisibleOgre(), and useOgre.

Referenced by init(), and track().

void vpMbEdgeTracker::visibleFace ( const vpHomogeneousMatrix _cMo,
bool &  newvisibleline 
)
protected
Deprecated:
This method is deprecated since it is no more used since ViSP 2.7.0.

Detect the visible faces in the image and says if a new one appeared.

Warning
If in one iteration one face appears and one disappears, then the function will not detect the new face.
Parameters
_cMo: The pose of the camera used to project the 3D model into the image.
newvisibleline: This parameter is set to true if a new face appeared.

Definition at line 1487 of file vpMbEdgeTracker.cpp.

References faces, nbvisiblepolygone, vpMath::rad(), vpMbHiddenFaces< PolygonType >::setVisible(), vpMbHiddenFaces< PolygonType >::setVisibleOgre(), and useOgre.

Member Data Documentation

double vpMbEdgeTracker::angleAppears
protected

Angle used to detect a face appearance.

Definition at line 317 of file vpMbEdgeTracker.h.

Referenced by vpMbEdgeKltTracker::loadConfigFile(), loadConfigFile(), resetTracker(), and visibleFace().

double vpMbEdgeTracker::angleDisappears
protected

Angle used to detect a face disappearance.

Definition at line 320 of file vpMbEdgeTracker.h.

Referenced by vpMbEdgeKltTracker::loadConfigFile(), loadConfigFile(), resetTracker(), and visibleFace().

unsigned int vpMbEdgeTracker::clippingFlag
protected
int vpMbEdgeTracker::compute_interaction
protected

If this flag is true, the interaction matrix extracted from the feature set is computed at each iteration in the visual servoing loop.

Definition at line 275 of file vpMbEdgeTracker.h.

Referenced by computeVVS(), and resetTracker().

bool vpMbTracker::computeCovariance
protectedinherited

Flag used to specify if the covariance matrix has to be computed or not.

Definition at line 116 of file vpMbTracker.h.

Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), computeVVS(), vpMbKltTracker::resetTracker(), and vpMbEdgeKltTracker::vpMbEdgeKltTracker().

vpMatrix vpMbTracker::covarianceMatrix
protectedinherited

Covariance matrix.

Definition at line 118 of file vpMbTracker.h.

Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), and computeVVS().

bool vpMbTracker::displayFeatures
protectedinherited

If true, the features are displayed.

Definition at line 120 of file vpMbTracker.h.

Referenced by vpMbEdgeKltTracker::display(), vpMbKltTracker::display(), vpMbEdgeKltTracker::postTracking(), and track().

double vpMbEdgeTracker::distFarClip
protected

Distance for near clipping.

Definition at line 326 of file vpMbEdgeTracker.h.

Referenced by addLine(), setFarClippingDistance(), and setNearClippingDistance().

double vpMbEdgeTracker::distNearClip
protected

Distance for near clipping.

Definition at line 323 of file vpMbEdgeTracker.h.

Referenced by addLine(), setFarClippingDistance(), and setNearClippingDistance().

int vpMbEdgeTracker::index_polygon
protected

Index of the polygon to add, and total number of polygon extracted so far. Cannot be unsigned because the default index of a polygon is -1.

Definition at line 293 of file vpMbEdgeTracker.h.

Referenced by addPolygon(), reInitModel(), and resetTracker().

std::vector< const vpImage<unsigned char>* > vpMbEdgeTracker::Ipyramid
protected

Pyramid of image associated to the current image. This pyramid is computed in the init() and in the track() methods.

Definition at line 308 of file vpMbEdgeTracker.h.

Referenced by vpMbEdgeKltTracker::init(), init(), reInitLevel(), vpMbEdgeKltTracker::setPose(), vpMbEdgeKltTracker::track(), track(), and ~vpMbEdgeTracker().

double vpMbEdgeTracker::lambda
protected

The gain of the virtual visual servoing stage.

Definition at line 277 of file vpMbEdgeTracker.h.

Referenced by computeVVS(), vpMbEdgeKltTracker::getLambda(), and resetTracker().

vpMe vpMbEdgeTracker::me
protected

The moving edges parameters.

Definition at line 280 of file vpMbEdgeTracker.h.

Referenced by addCylinder(), addLine(), vpMbEdgeKltTracker::loadConfigFile(), loadConfigFile(), and setMovingEdge().

std::string vpMbTracker::modelFileName
protectedinherited

The name of the file containing the model (it is used to create a file name.0.pos used to store the compute pose in the initClick method).

Definition at line 110 of file vpMbTracker.h.

Referenced by vpMbTracker::loadModel().

bool vpMbTracker::modelInitialised
protectedinherited

Flag used to ensure that the CAD model is loaded before the initialisation.

Definition at line 112 of file vpMbTracker.h.

Referenced by vpMbKltTracker::init(), and vpMbTracker::loadModel().

unsigned int vpMbEdgeTracker::nbvisiblepolygone
protected
unsigned int vpMbEdgeTracker::ncylinder
protected

Index of the cylinder to add, and total number of polygon extracted so far.

Definition at line 290 of file vpMbEdgeTracker.h.

Referenced by addCylinder(), initCylinder(), reInitModel(), and resetTracker().

unsigned int vpMbEdgeTracker::nline
protected

Index of the polygon to add, and total number of polygon extracted so far.

Definition at line 287 of file vpMbEdgeTracker.h.

Referenced by addLine(), reInitModel(), and resetTracker().

double vpMbEdgeTracker::percentageGdPt
protected

Percentage of good points over total number of points below which tracking is supposed to have failed.

Definition at line 302 of file vpMbEdgeTracker.h.

Referenced by resetTracker(), and testTracking().

std::string vpMbTracker::poseSavingFilename
protectedinherited

Filename used to save the initial pose computed using the initClick() method. It is also used to read a previous pose in the same method.

Definition at line 114 of file vpMbTracker.h.

Referenced by vpMbTracker::initClick().

unsigned int vpMbEdgeTracker::scaleLevel
protected

Current scale level used. This attribute must not be modified outside of the downScale() and upScale() methods, as it used to specify to some methods which set of distanceLine use.

Definition at line 311 of file vpMbEdgeTracker.h.

Referenced by computeVVS(), vpMbEdgeKltTracker::display(), display(), downScale(), initMovingEdge(), reInitLevel(), reinitMovingEdge(), vpMbEdgeKltTracker::setPose(), setPose(), testTracking(), trackMovingEdge(), updateMovingEdge(), and upScale().

bool vpMbEdgeTracker::useOgre
protected

Use Ogre3d for visibility tests.

Definition at line 314 of file vpMbEdgeTracker.h.

Referenced by display(), init(), setOgreVisibilityTest(), and visibleFace().