![]() |
ViSP
2.6.2
|
#include <vpMbTracker.h>
Public Member Functions | |
vpMbTracker () | |
virtual | ~vpMbTracker () |
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 | init (const vpImage< unsigned char > &_I)=0 |
virtual void | testTracking ()=0 |
virtual void | loadConfigFile (const std::string &_configFile)=0 |
virtual void | track (const vpImage< unsigned char > &_I)=0 |
virtual void | loadModel (const std::string &_modelFile) |
virtual void | display (const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam, const vpColor &_col, const unsigned int _l=1, const bool displayFullModel=false)=0 |
virtual void | setCameraParameters (const vpCameraParameters &_cam) |
virtual void | setCovarianceComputation (const bool &flag) |
virtual void | getCameraParameters (vpCameraParameters &_cam) const |
virtual vpMatrix | getCovarianceMatrix () const |
void | getPose (vpHomogeneousMatrix &_cMo) const |
vpHomogeneousMatrix | getPose () const |
void | setPoseSavingFilename (const std::string &filename) |
void | savePose (const std::string &filename) |
Protected Member Functions | |
virtual void | loadVRMLModel (const std::string &_modelFile) |
virtual void | loadCAOModel (const std::string &_modelFile) |
void | computeJTR (const vpMatrix &_J, const vpColVector &_R, vpMatrix &_JTR) |
virtual void | extractFaces (SoVRMLIndexedFaceSet *_face_set) |
virtual void | extractLines (SoVRMLIndexedLineSet *_line_set) |
virtual void | extractCylinders (SoVRMLIndexedFaceSet *_face_set) |
vpPoint | getGravityCenter (const std::vector< vpPoint > &_pts) |
virtual void | initFaceFromCorners (const std::vector< vpPoint > &_corners, const unsigned int _indexFace=-1)=0 |
virtual void | initCylinder (const vpPoint &_p1, const vpPoint _p2, const double _radius, const unsigned int _indexCylinder=0)=0 |
Deprecated functions | |
virtual void | init (const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_c0Mo)=0 |
Protected Attributes | |
vpCameraParameters | cam |
vpHomogeneousMatrix | cMo |
std::string | modelFileName |
bool | modelInitialised |
bool | cameraInitialised |
bool | coinUsed |
std::string | poseSavingFilename |
bool | computeCovariance |
vpMatrix | covarianceMatrix |
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 95 of file vpMbTracker.h.
vpMbTracker::vpMbTracker | ( | ) |
Basic constructor. Set default values.
Definition at line 94 of file vpMbTracker.cpp.
References cameraInitialised, coinUsed, computeCovariance, and modelInitialised.
|
virtual |
|
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 1226 of file vpMbTracker.cpp.
References vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, and vpMatrix::resize().
Referenced by 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. |
_l | : The thickness of the lines. |
displayFullModel | : If true, the full model is displayed (even the non visible surfaces). |
Implemented in vpMbEdgeTracker.
Referenced by initClick().
|
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. |
Definition at line 1078 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 loadVRMLModel().
|
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. |
Definition at line 1028 of file vpMbTracker.cpp.
References initFaceFromCorners(), and vpPoint::setWorldCoordinates().
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 1171 of file vpMbTracker.cpp.
References initFaceFromCorners(), and vpPoint::setWorldCoordinates().
Referenced by loadVRMLModel().
|
inlinevirtual |
Get the camera parameters.
_cam | : copy of the camera parameters used by the tracker. |
Definition at line 203 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 1142 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 222 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 231 of file vpMbTracker.h.
|
pure virtual |
Initialise the tracking.
_I | : Input image. |
Referenced by initClick(), initFromPoints(), and initFromPose().
|
protectedpure virtual |
Initialise the tracking using the known pose cMo.
_I | : Input image. |
_c0Mo | : Initial pose between the camera and the object. |
Implemented in vpMbEdgeTracker.
|
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 139 of file vpMbTracker.cpp.
References vpPose::addPoint(), 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, init(), vpDisplayOpenCV::init(), vpException::ioError, vpPose::LAGRANGE, poseSavingFilename, vpImageIo::readPPM(), 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 355 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, init(), vpDisplayOpenCV::init(), vpPose::LAGRANGE, vpImageIo::readPPM(), 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.
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.
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 471 of file vpMbTracker.cpp.
References vpPose::addPoint(), 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 550 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 604 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 639 of file vpMbTracker.cpp.
|
virtual |
Initialise the tracking thanks to the pose vector.
_I | : Input image |
cPo | : Pose vector. |
Definition at line 651 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 839 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.
|
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.
Definition at line 687 of file vpMbTracker.cpp.
References vpIoTools::checkFilename(), vpException::ioError, loadCAOModel(), loadVRMLModel(), modelFileName, and modelInitialised.
Referenced by 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 734 of file vpMbTracker.cpp.
References coinUsed, extractCylinders(), extractFaces(), extractLines(), vpException::fatalError, and vpERROR_TRACE.
Referenced by loadModel().
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 662 of file vpMbTracker.cpp.
References vpPoseVector::buildFrom(), and cMo.
Referenced by initClick().
|
inlinevirtual |
Set the camera parameters.
_cam | : the new camera parameters |
Reimplemented in vpMbEdgeTracker.
Definition at line 189 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 196 of file vpMbTracker.h.
|
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 242 of file vpMbTracker.h.
|
pure virtual |
Test the quality of the tracking.
vpException | if the test fail. |
Implemented in vpMbEdgeTracker.
|
pure virtual |
Track the object in the given image
_I | : The current image. |
Implemented in vpMbEdgeTracker.
|
protected |
The camera parameters.
Definition at line 99 of file vpMbTracker.h.
Referenced by vpMbEdgeTracker::addCylinder(), vpMbEdgeTracker::addLine(), vpMbEdgeTracker::computeVVS(), vpMbEdgeTracker::downScale(), initClick(), initFromPoints(), and vpMbEdgeTracker::upScale().
|
protected |
Flag used to ensure that the camera is set before the initialisation.
Definition at line 107 of file vpMbTracker.h.
Referenced by vpMbTracker().
|
protected |
The current pose.
Definition at line 101 of file vpMbTracker.h.
Referenced by vpMbEdgeTracker::computeVVS(), vpMbEdgeTracker::init(), initClick(), initFromPoints(), initFromPose(), vpMbEdgeTracker::reInitLevel(), vpMbEdgeTracker::resetTracker(), savePose(), vpMbEdgeTracker::track(), vpMbEdgeTracker::trackMovingEdge(), and vpMbEdgeTracker::updateMovingEdge().
|
protected |
Flag used to specify that the Coin library has been loaded in order to load a vrml model (used to free the memory).
Definition at line 109 of file vpMbTracker.h.
Referenced by loadVRMLModel(), vpMbTracker(), and ~vpMbTracker().
|
protected |
Flag used to specify if the covariance matrix has to be computed or not.
Definition at line 113 of file vpMbTracker.h.
Referenced by vpMbEdgeTracker::computeVVS(), vpMbEdgeTracker::vpMbEdgeTracker(), and vpMbTracker().
|
protected |
Covariance matrix.
Definition at line 115 of file vpMbTracker.h.
Referenced by vpMbEdgeTracker::computeVVS().
|
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 103 of file vpMbTracker.h.
Referenced by loadModel().
|
protected |
Flag used to ensure that the CAD model is loaded before the initialisation.
Definition at line 105 of file vpMbTracker.h.
Referenced by loadModel(), and vpMbTracker().
|
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 111 of file vpMbTracker.h.
Referenced by initClick().