ViSP
2.9.0
|
#include <vpMbTracker.h>
Public Member Functions | |
vpMbTracker () | |
virtual | ~vpMbTracker () |
virtual 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)=0 |
virtual void | display (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)=0 |
virtual void | getCameraParameters (vpCameraParameters &camera) const |
virtual vpMatrix | getCovarianceMatrix () const |
void | getPose (vpHomogeneousMatrix &cMo_) const |
vpHomogeneousMatrix | getPose () const |
virtual void | init (const vpImage< unsigned char > &I)=0 |
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) |
virtual void | loadConfigFile (const std::string &configFile)=0 |
virtual void | loadModel (const std::string &modelFile) |
virtual void | resetTracker ()=0 |
void | savePose (const std::string &filename) |
virtual void | setCameraParameters (const vpCameraParameters &camera) |
virtual void | setCovarianceComputation (const bool &flag) |
void | setDisplayFeatures (const bool displayF) |
virtual void | setPose (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0 |
void | setPoseSavingFilename (const std::string &filename) |
virtual void | testTracking ()=0 |
virtual void | track (const vpImage< unsigned char > &I)=0 |
Protected Member Functions | |
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 | initCylinder (const vpPoint &p1, const vpPoint &p2, const double radius, const unsigned int indexCylinder=0)=0 |
virtual void | initFaceFromCorners (const std::vector< vpPoint > &corners, const unsigned int indexFace=-1)=0 |
virtual void | loadVRMLModel (const std::string &modelFile) |
virtual void | loadCAOModel (const std::string &modelFile) |
Protected Attributes | |
vpCameraParameters | cam |
vpHomogeneousMatrix | cMo |
std::string | modelFileName |
bool | modelInitialised |
std::string | poseSavingFilename |
bool | computeCovariance |
vpMatrix | covarianceMatrix |
bool | displayFeatures |
Main methods for a model-based tracker.
This class provides the main methods for a model based tracker. This pure virtual class must be used in inheritance for a tracker that compute the interaction matrix and the residu vector using a defined information (edge, points of interest, patch, ...)
This class intends to define a common basis for object tracking. This is realised by implementing the main functions:
In addition, two flags are declared in this class and may have to be initialised in the child class :
Definition at line 102 of file vpMbTracker.h.
vpMbTracker::vpMbTracker | ( | ) |
Basic constructor. Set default values.
Definition at line 95 of file vpMbTracker.cpp.
|
virtual |
Basic destructor that doest nothing.
Definition at line 104 of file vpMbTracker.cpp.
|
protected |
Compute , with J the interaction matrix and R the vector of residu.
vpMatrixException::incorrectMatrixSizeError | if the sizes of the matrices do not allow the computation. |
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 vpMbEdgeTracker::computeVVS().
|
pure virtual |
Display the 3D model at a given position using the given camera parameters on a grey level image.
I | : The image. |
cMo | : Pose used to project the 3D model into the image. |
cam | : 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). |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
Referenced by initClick().
|
pure virtual |
Display the 3D model at a given position using the given camera parameters on a color (RGBa) image.
I | : The image. |
cMo | : Pose used to project the 3D model into the image. |
cam | : 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). |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
|
protectedvirtual |
Extract a cylinder to track from the VMRL model. This method calls the initCylinder() method implemented in the child class.
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(), getGravityCenter(), initCylinder(), vpMath::maximum(), vpPoint::setWorldCoordinates(), and vpMatrix::sumSquare().
Referenced by extractGroup().
|
protectedvirtual |
Extract a face of the object to track from the VMRL model. This method calls the initFaceFromCorners() method implemented in the child class.
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 initFaceFromCorners(), and vpPoint::setWorldCoordinates().
Referenced by extractGroup().
|
protectedvirtual |
Extract a VRML object Group.
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 extractCylinders(), extractFaces(), and extractLines().
Referenced by loadVRMLModel().
|
protectedvirtual |
Extract a line of the object to track from the VMRL model. This method calls the initFaceFromCorners() method implemented in the child class.
line_set | : Pointer to the line in the vrml format. |
Definition at line 1378 of file vpMbTracker.cpp.
References initFaceFromCorners(), and vpPoint::setWorldCoordinates().
Referenced by extractGroup().
|
inlinevirtual |
Get the camera parameters.
camera | : copy of the camera parameters used by the tracker. |
Definition at line 158 of file vpMbTracker.h.
|
inlinevirtual |
Compute the center of gravity of a set of point. This is used in the cylinder extraction to find the center of the circles.
vpException::dimensionError | if the set is empty. |
pts | : Set of point to extract the center of gravity. |
Definition at line 1349 of file vpMbTracker.cpp.
References vpException::dimensionError, vpPoint::get_oX(), and vpPoint::setWorldCoordinates().
Referenced by extractCylinders().
|
inline |
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.
cMo_ | : the pose |
Definition at line 177 of file vpMbTracker.h.
|
inline |
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.
Definition at line 186 of file vpMbTracker.h.
|
pure virtual |
Initialise the tracking.
I | : Input image. |
Implemented in vpMbEdgeTracker, vpMbEdgeKltTracker, and vpMbKltTracker.
Referenced by initClick(), initFromPoints(), and initFromPose().
|
virtual |
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):
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. |
vpException::ioError | : The file specified in initFile doesn't exist. |
Definition at line 131 of file vpMbTracker.cpp.
References vpPose::addPoint(), vpException::badValue, vpHomogeneousMatrix::buildFrom(), vpMouseButton::button1, cam, vpPose::clearPoint(), cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, display(), vpDisplay::display(), vpDisplay::displayCharString(), vpDisplay::displayCross(), vpDisplay::displayFrame(), vpDisplay::displayPoint(), vpDisplay::flush(), vpDisplay::getClick(), vpColor::green, vpDisplayOpenCV::init(), init(), vpException::ioError, vpPose::LAGRANGE, poseSavingFilename, vpImageIo::read(), vpColor::red, savePose(), vpPoint::set_x(), vpPoint::set_y(), vpHomogeneousMatrix::setIdentity(), vpPoint::setWorldCoordinates(), and vpPose::VIRTUAL_VS.
|
virtual |
Initialise the tracking by clicking on the image points corresponding to the 3D points (object frame) in the list points3D_list.
I | : Input image |
points3D_list | : List of the 3D points (object frame). |
displayFile | : Path to the image used to display the help. |
Definition at line 352 of file vpMbTracker.cpp.
References vpPose::addPoint(), vpMouseButton::button1, cam, vpPose::clearPoint(), cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, display(), vpDisplay::display(), vpDisplay::displayCharString(), vpDisplay::displayCross(), vpDisplay::displayFrame(), vpDisplay::displayPoint(), vpDisplay::flush(), vpDisplay::getClick(), vpColor::green, vpDisplayOpenCV::init(), init(), vpPose::LAGRANGE, vpImageIo::read(), vpColor::red, vpPoint::set_x(), vpPoint::set_y(), and vpPose::VIRTUAL_VS.
|
protectedpure virtual |
Add a cylinder to track from two points on the axis (defining the length of the cylinder) and its radius.
p1 | : First point on the axis. |
p2 | : Second point on the axis. |
radius | : Radius of the cylinder. |
indexCylinder | : Index of the cylinder. |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
Referenced by extractCylinders(), and loadCAOModel().
|
protectedpure virtual |
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 initialisation of the face depends on the primitive to track.
corners | : The vector of corners representing the face. |
indexFace | : The index of the face. |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
Referenced by extractFaces(), extractLines(), and loadCAOModel().
|
virtual |
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):
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, cam, cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, init(), vpException::ioError, vpPose::LAGRANGE, vpPoint::set_x(), vpPoint::set_y(), vpPoint::setWorldCoordinates(), vpPose::VIRTUAL_VS, and vpERROR_TRACE.
|
virtual |
Initialise the tracking with the list of image points (points2D_list) and the list of corresponding 3D points (object frame) (points3D_list).
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(), cam, cMo, vpPose::computePose(), vpPose::computeResidual(), vpPixelMeterConversion::convertPoint(), vpPose::DEMENTHON, init(), vpPose::LAGRANGE, vpPoint::set_x(), vpPoint::set_y(), vpPoint::setWorldCoordinates(), vpPose::VIRTUAL_VS, and vpERROR_TRACE.
|
virtual |
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):
Where the three firsts lines refer to the translation and the three last to the rotation in thetaU parametrisation (see vpThetaUVector).
I | : Input image |
initFile | : Path to the file containing the pose. |
Definition at line 609 of file vpMbTracker.cpp.
References vpHomogeneousMatrix::buildFrom(), cMo, init(), and vpException::ioError.
Referenced by initFromPose(), and vpMbEdgeTracker::reInitModel().
|
virtual |
Initialise the tracking thanks to the pose.
I | : Input image |
cMo_ | : Pose matrix. |
Definition at line 644 of file vpMbTracker.cpp.
|
virtual |
Initialise the tracking thanks to the pose vector.
I | : Input image |
cPo | : Pose vector. |
Definition at line 656 of file vpMbTracker.cpp.
References initFromPose().
|
protectedvirtual |
Load a 3D model contained in a .cao file.
the structure of the file is (without the comments) :
modelFile | : Full name of the .CAO file containing the model. |
Definition at line 838 of file vpMbTracker.cpp.
References vpException::badValue, initCylinder(), initFaceFromCorners(), vpException::ioError, vpPoint::setWorldCoordinates(), and vpTRACE.
Referenced by loadModel().
|
pure virtual |
Load a config file to parameterise the behavior of the tracker.
Pure virtual method to adapt to each tracker.
configFile | : the (xml) config file to parse |
Implemented in vpMbEdgeTracker, vpMbEdgeKltTracker, and vpMbKltTracker.
|
virtual |
Load a 3D model from the file in parameter. This file must either be a vrml file (.wrl) or a CAO file (.cao). CAO format is described in the loadCAOModel() method.
vpException::ioError | if the file cannot be open, or if its extension is not wrl or cao. |
modelFile | : the file containing the model. |
Reimplemented in vpMbEdgeTracker, and vpMbEdgeKltTracker.
Definition at line 705 of file vpMbTracker.cpp.
References vpIoTools::checkFilename(), vpException::ioError, loadCAOModel(), loadVRMLModel(), modelFileName, and modelInitialised.
Referenced by vpMbEdgeKltTracker::loadModel(), and vpMbEdgeTracker::loadModel().
|
protectedvirtual |
Load the 3D model of the object from a vrml file. Only LineSet and FaceSet are extracted from the vrml file.
vpException::fatalError | if the file cannot be open. |
modelFile | : The full name of the file containing the 3D model. |
Definition at line 763 of file vpMbTracker.cpp.
References extractGroup(), vpException::fatalError, and vpERROR_TRACE.
Referenced by loadModel().
|
pure virtual |
Reset the tracker.
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
void vpMbTracker::savePose | ( | const std::string & | filename | ) |
Save the pose in the given filename
filename | : Path to the file used to save the pose. |
Definition at line 667 of file vpMbTracker.cpp.
References vpPoseVector::buildFrom(), and cMo.
Referenced by initClick().
|
inlinevirtual |
Set the camera parameters.
camera | : the new camera parameters |
Reimplemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
Definition at line 233 of file vpMbTracker.h.
|
inlinevirtual |
Set if the covaraince matrix has to be computed.
flag | : True if the covariance has to be computed, false otherwise |
Definition at line 240 of file vpMbTracker.h.
|
inline |
Enable to display the features.
displayF | : set it to true to display the features. |
Definition at line 247 of file vpMbTracker.h.
|
pure virtual |
Set the pose to be used in entry of the next call to the track() function. This pose will be just used once.
I | : image corresponding to the desired pose. |
cdMo | : Pose to affect. |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
|
inline |
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.
filename | : The new filename. |
Definition at line 269 of file vpMbTracker.h.
|
pure virtual |
Test the quality of the tracking.
vpException | if the test fail. |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
|
pure virtual |
Track the object in the given image
I | : The current image. |
Implemented in vpMbEdgeTracker, vpMbKltTracker, and vpMbEdgeKltTracker.
|
protected |
The camera parameters.
Definition at line 106 of file vpMbTracker.h.
Referenced by vpMbEdgeTracker::addCylinder(), vpMbEdgeTracker::addLine(), vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpMbEdgeTracker::downScale(), vpMbKltTracker::init(), vpMbEdgeTracker::init(), initClick(), vpMbKltTracker::initFaceFromCorners(), initFromPoints(), vpMbEdgeKltTracker::loadConfigFile(), vpMbEdgeTracker::loadConfigFile(), vpMbKltTracker::postTracking(), vpMbEdgeKltTracker::setCameraParameters(), vpMbKltTracker::setCameraParameters(), vpMbKltTracker::setPose(), vpMbEdgeTracker::upScale(), and vpMbEdgeTracker::visibleFace().
|
protected |
The current pose.
Definition at line 108 of file vpMbTracker.h.
Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpMbKltTracker::init(), vpMbEdgeKltTracker::init(), vpMbEdgeTracker::init(), initClick(), initFromPoints(), initFromPose(), vpMbEdgeKltTracker::postTracking(), vpMbKltTracker::postTracking(), vpMbKltTracker::reinit(), vpMbEdgeTracker::reInitLevel(), vpMbEdgeTracker::reInitModel(), vpMbKltTracker::resetTracker(), vpMbEdgeTracker::resetTracker(), savePose(), vpMbEdgeKltTracker::setPose(), vpMbKltTracker::setPose(), vpMbEdgeTracker::setPose(), vpMbEdgeKltTracker::track(), vpMbEdgeTracker::track(), vpMbEdgeKltTracker::trackFirstLoop(), vpMbEdgeTracker::trackMovingEdge(), and vpMbEdgeTracker::updateMovingEdge().
|
protected |
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(), vpMbEdgeTracker::computeVVS(), vpMbKltTracker::resetTracker(), and vpMbEdgeKltTracker::vpMbEdgeKltTracker().
|
protected |
Covariance matrix.
Definition at line 118 of file vpMbTracker.h.
Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), and vpMbEdgeTracker::computeVVS().
|
protected |
If true, the features are displayed.
Definition at line 120 of file vpMbTracker.h.
Referenced by vpMbEdgeKltTracker::display(), vpMbKltTracker::display(), vpMbEdgeKltTracker::postTracking(), and vpMbEdgeTracker::track().
|
protected |
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 loadModel().
|
protected |
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 loadModel().
|
protected |
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 initClick().