44 #ifndef vpMbTracker_hh
45 #define vpMbTracker_hh
58 #include <visp3/core/vpHomogeneousMatrix.h>
59 #include <visp3/core/vpImage.h>
60 #include <visp3/core/vpImagePoint.h>
61 #include <visp3/core/vpColVector.h>
62 #include <visp3/core/vpMatrix.h>
63 #include <visp3/core/vpRGBa.h>
64 #include <visp3/core/vpCameraParameters.h>
65 #include <visp3/core/vpPoint.h>
66 #include <visp3/mbt/vpMbtPolygon.h>
67 #include <visp3/mbt/vpMbHiddenFaces.h>
68 #include <visp3/core/vpPolygon.h>
70 #ifdef VISP_HAVE_COIN3D
77 # include <Inventor/VRMLnodes/SoVRMLGroup.h>
78 # include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h>
79 # include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h>
107 GAUSS_NEWTON_OPT = 0,
108 LEVENBERG_MARQUARDT_OPT = 1
109 } vpMbtOptimizationMethod;
199 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false)=0;
212 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false)=0;
232 virtual inline unsigned int getClipping()
const {
return clippingFlag; }
238 if(!computeCovariance)
239 vpTRACE(
"Warning : The covariance matrix has not been computed. See setCovarianceComputation() to do it.");
241 return covarianceMatrix;
310 return static_cast<unsigned int>(faces.
size());
339 if(index >= static_cast<unsigned int>(faces.
size()) ){
346 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > getPolygonFaces(
const bool orderPolygons=
true,
347 const bool useVisibility=
true);
378 #ifdef VISP_HAVE_MODULE_GUI
379 virtual void initClick(
const vpImage<unsigned char>& I,
const std::string& initFile,
const bool displayHelp =
false );
381 const std::string &displayFile =
"" );
385 virtual void initFromPoints(
const vpImage<unsigned char>& I,
const std::vector<vpImagePoint> &points2D_list,
const std::vector<vpPoint> &points3D_list );
398 virtual void loadConfigFile(
const std::string& configFile)=0;
400 virtual void loadModel(
const char *modelFile,
const bool verbose=
false);
401 virtual void loadModel(
const std::string &modelFile,
const bool verbose=
false);
406 virtual void resetTracker() = 0;
408 void savePose(
const std::string &filename);
439 virtual void setClipping(
const unsigned int &flags);
461 virtual void setEstimatedDoF(
const vpColVector& v);
463 virtual void setFarClippingDistance(
const double &dist);
465 virtual void setLod(
const bool useLod,
const std::string &name=
"");
467 virtual void setMinLineLengthThresh(
const double minLineLengthThresh,
const std::string &name=
"");
469 virtual void setMinPolygonAreaThresh(
const double minPolygonAreaThresh,
const std::string &name=
"");
471 virtual void setNearClippingDistance(
const double &dist);
501 poseSavingFilename = filename;
524 ogreShowConfigDialog = showConfigDialog;
527 virtual void setOgreVisibilityTest(
const bool &v);
529 #ifdef VISP_HAVE_OGRE
555 virtual void testTracking() = 0;
565 void addPolygon(
const std::vector<vpPoint>& corners,
const int idFace=-1,
const std::string &polygonName=
"",
566 const bool useLod=
false,
const double minPolygonAreaThreshold=2500.0,
const double minLineLengthThreshold=50.0);
567 void addPolygon(
const vpPoint& p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
const int idFace=-1,
568 const std::string &polygonName=
"",
const bool useLod=
false,
const double minPolygonAreaThreshold=2500.0);
569 void addPolygon(
const vpPoint& p1,
const vpPoint &p2,
const int idFace=-1,
const std::string &polygonName=
"",
570 const bool useLod=
false,
const double minLineLengthThreshold=50);
571 void addPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
const int idFace=-1,
const std::string &polygonName=
"",
572 const bool useLod=
false,
const double minLineLengthThreshold=50);
574 void createCylinderBBox(
const vpPoint& p1,
const vpPoint &p2,
const double &radius, std::vector<std::vector<vpPoint> > &listFaces);
578 #ifdef VISP_HAVE_COIN3D
579 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
580 virtual void extractFaces(SoVRMLIndexedFaceSet* face_set,
vpHomogeneousMatrix &transform,
int &idFace,
const std::string &polygonName=
"");
581 virtual void extractLines(SoVRMLIndexedLineSet* line_set,
int &idFace,
const std::string &polygonName=
"");
582 virtual void extractCylinders(SoVRMLIndexedFaceSet* face_set,
vpHomogeneousMatrix &transform,
int &idFace,
const std::string &polygonName=
"");
585 vpPoint getGravityCenter(
const std::vector<vpPoint>& _pts);
598 virtual void initCircle(
const vpPoint& p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
599 const int idFace=0,
const std::string &name=
"")=0;
610 virtual void initCylinder(
const vpPoint& p1,
const vpPoint &p2,
const double radius,
const int idFace=0,
611 const std::string &name=
"")=0;
623 virtual void initFaceFromCorners(
vpMbtPolygon &polygon)=0;
624 virtual void initFaceFromLines(
vpMbtPolygon &polygon)=0;
626 virtual void loadVRMLModel(
const std::string& modelFile);
627 virtual void loadCAOModel(
const std::string& modelFile, std::vector<std::string>& vectorOfModelFilename,
int& startIdFace,
628 const bool verbose=
false,
const bool parent=
true);
630 void removeComment(std::ifstream& fileId);
633 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
634 std::istringstream is(input);
638 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
642 std::map<std::string, std::string> parseParameters(std::string& endLine);
644 inline std::string &
ltrim(std::string &s) {
645 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
649 inline std::string &
rtrim(std::string &s) {
650 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
654 inline std::string &
trim(std::string &s) {
655 return ltrim(rtrim(s));
bool computeProjError
Flag used to specify if the gradient error criteria has to be computed or not.
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
virtual void setCovarianceComputation(const bool &flag)
std::string & rtrim(std::string &s)
Implementation of a matrix and operations on matrices.
vpMatrix covarianceMatrix
Covariance matrix.
bool parseBoolean(std::string &input)
std::string & trim(std::string &s)
unsigned int nbLines
Number of lines in CAO model.
virtual double getAngleAppear() const
virtual unsigned int getClipping() const
virtual void setAngleDisappear(const double &a)
unsigned int nbCircles
Number of circles in CAO model.
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual vpMbtOptimizationMethod getOptimizationMethod() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::map< std::string, std::string > mapOfParameterNames
Map with [map.first]=parameter_names and [map.second]=type (string, number or boolean) ...
unsigned int nbCylinders
Number of cylinders in CAO model.
unsigned int nbPoints
Number of points in CAO model.
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Class to define colors available for display functionnalities.
vpHomogeneousMatrix cMo
The current pose.
bool modelInitialised
Flag used to ensure that the CAD model is loaded before the initialisation.
vpHomogeneousMatrix getPose() const
error that can be emited by ViSP classes.
bool useOgre
Use Ogre3d for visibility tests.
std::string modelFileName
The name of the file containing the model (it is used to create a file name.0.pos used to store the c...
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
virtual double getAngleDisappear() const
void setOgreShowConfigDialog(const bool showConfigDialog)
double distFarClip
Distance for near clipping.
double projectionError
Error angle between the gradient direction of the model features projected at the resulting pose and ...
vpMatrix oJo
The Degrees of Freedom to estimate.
Implementation of a polygon of the model used by the model-based tracker.
virtual void setCameraParameters(const vpCameraParameters &camera)
void getPose(vpHomogeneousMatrix &cMo_) const
bool useScanLine
Use Scanline for visibility tests.
std::string & ltrim(std::string &s)
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
vpColVector m_error
Error s-s*.
virtual void getCameraParameters(vpCameraParameters &camera) const
virtual double getProjectionError() const
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
unsigned int nbPolygonLines
Number of polygon lines in CAO model.
virtual void setAngleAppear(const double &a)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
double angleAppears
Angle used to detect a face appearance.
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual vpColVector getError()
std::string poseSavingFilename
Filename used to save the initial pose computed using the initClick() method. It is also used to read...
unsigned int size() const
virtual double getNearClippingDistance() const
unsigned int nbPolygonPoints
Number of polygon points in CAO model.
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
bool displayFeatures
If true, the features are displayed.
bool ogreShowConfigDialog
virtual vpColVector getRobustWeights()
bool applyLodSettingInConfig
True if the CAO model is loaded before the call to loadConfigFile, (deduced by the number of polygons...
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
virtual vpMbtPolygon * getPolygon(const unsigned int index)
double angleDisappears
Angle used to detect a face disappearance.
virtual unsigned int getNbPolygon() const
void setPoseSavingFilename(const std::string &filename)
virtual void setScanLineVisibilityTest(const bool &v)
virtual double getFarClippingDistance() const
void setDisplayFeatures(const bool displayF)
unsigned int clippingFlag
Flags specifying which clipping to used.
double distNearClip
Distance for near clipping.
vpMbHiddenFaces< vpMbtPolygon > & getFaces()
bool useLodGeneral
True if LOD mode is enabled.
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
vpColVector m_w
Weights used in the robust scheme.
virtual void setProjectionErrorComputation(const bool &flag)
virtual vpMatrix getCovarianceMatrix() const