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;
208 virtual inline unsigned int getClipping()
const {
return clippingFlag; }
214 if(!computeCovariance)
215 vpTRACE(
"Warning : The covariance matrix has not been computed. See setCovarianceComputation() to do it.");
217 return covarianceMatrix;
287 return static_cast<unsigned int>(faces.size());
316 if(index >= static_cast<unsigned int>(faces.size()) ){
323 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > getPolygonFaces(
const bool orderPolygons=
true,
324 const bool useVisibility=
true,
const bool clipPolygon=
false);
346 #ifdef VISP_HAVE_MODULE_GUI
347 virtual void initClick(
const vpImage<unsigned char>& I,
const std::string& initFile,
const bool displayHelp =
false );
349 const std::string &displayFile =
"" );
353 virtual void initFromPoints(
const vpImage<unsigned char>& I,
const std::vector<vpImagePoint> &points2D_list,
const std::vector<vpPoint> &points3D_list );
359 virtual void loadModel(
const char *modelFile,
const bool verbose=
false);
360 virtual void loadModel(
const std::string &modelFile,
const bool verbose=
false);
391 virtual void setClipping(
const unsigned int &flags);
413 virtual void setEstimatedDoF(
const vpColVector& v);
415 virtual void setFarClippingDistance(
const double &dist);
417 virtual void setLod(
const bool useLod,
const std::string &name=
"");
419 virtual void setMinLineLengthThresh(
const double minLineLengthThresh,
const std::string &name=
"");
421 virtual void setMinPolygonAreaThresh(
const double minPolygonAreaThresh,
const std::string &name=
"");
423 virtual void setNearClippingDistance(
const double &dist);
441 virtual void setOgreVisibilityTest(
const bool &v);
443 void savePose(
const std::string &filename)
const;
445 #ifdef VISP_HAVE_OGRE
454 faces.setGoodNbRayCastingAttemptsRatio(ratio);
465 faces.setNbRayCastingAttemptsForVisibility(attempts);
480 ogreShowConfigDialog = showConfigDialog;
493 poseSavingFilename = filename;
510 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false)=0;
523 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false)=0;
539 virtual void loadConfigFile(
const std::string& configFile)=0;
544 virtual void resetTracker() = 0;
562 virtual void testTracking() = 0;
575 void addPolygon(
const std::vector<vpPoint>& corners,
const int idFace=-1,
const std::string &polygonName=
"",
576 const bool useLod=
false,
const double minPolygonAreaThreshold=2500.0,
const double minLineLengthThreshold=50.0);
577 void addPolygon(
const vpPoint& p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
const int idFace=-1,
578 const std::string &polygonName=
"",
const bool useLod=
false,
const double minPolygonAreaThreshold=2500.0);
579 void addPolygon(
const vpPoint& p1,
const vpPoint &p2,
const int idFace=-1,
const std::string &polygonName=
"",
580 const bool useLod=
false,
const double minLineLengthThreshold=50);
581 void addPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
const int idFace=-1,
const std::string &polygonName=
"",
582 const bool useLod=
false,
const double minLineLengthThreshold=50);
584 void createCylinderBBox(
const vpPoint& p1,
const vpPoint &p2,
const double &radius, std::vector<std::vector<vpPoint> > &listFaces);
588 #ifdef VISP_HAVE_COIN3D
589 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
590 virtual void extractFaces(SoVRMLIndexedFaceSet* face_set,
vpHomogeneousMatrix &transform,
int &idFace,
const std::string &polygonName=
"");
591 virtual void extractLines(SoVRMLIndexedLineSet* line_set,
int &idFace,
const std::string &polygonName=
"");
592 virtual void extractCylinders(SoVRMLIndexedFaceSet* face_set,
vpHomogeneousMatrix &transform,
int &idFace,
const std::string &polygonName=
"");
595 vpPoint getGravityCenter(
const std::vector<vpPoint>& _pts)
const;
609 virtual void initCircle(
const vpPoint& p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
610 const int idFace=0,
const std::string &name=
"")=0;
621 virtual void initCylinder(
const vpPoint& p1,
const vpPoint &p2,
const double radius,
const int idFace=0,
622 const std::string &name=
"")=0;
634 virtual void initFaceFromCorners(
vpMbtPolygon &polygon)=0;
635 virtual void initFaceFromLines(
vpMbtPolygon &polygon)=0;
637 virtual void loadVRMLModel(
const std::string& modelFile);
638 virtual void loadCAOModel(
const std::string& modelFile, std::vector<std::string>& vectorOfModelFilename,
int& startIdFace,
639 const bool verbose=
false,
const bool parent=
true);
641 void removeComment(std::ifstream& fileId);
644 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
645 std::istringstream is(input);
649 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
653 std::map<std::string, std::string> parseParameters(std::string& endLine);
655 inline std::string &
ltrim(std::string &s)
const {
656 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
660 inline std::string &
rtrim(std::string &s)
const {
661 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
665 inline std::string &
trim(std::string &s)
const {
666 return ltrim(rtrim(s));
bool computeProjError
Flag used to specify if the gradient error criteria has to be computed or not.
virtual void setDisplayFeatures(const bool displayF)
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
virtual void setCovarianceComputation(const bool &flag)
Implementation of a matrix and operations on matrices.
vpMatrix covarianceMatrix
Covariance matrix.
bool parseBoolean(std::string &input)
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.
std::string & rtrim(std::string &s) const
bool modelInitialised
Flag used to ensure that the CAD model is loaded before the initialisation.
virtual vpColVector getRobustWeights() 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.
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
std::string & ltrim(std::string &s) const
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)
virtual vpHomogeneousMatrix getPose() const
bool useScanLine
Use Scanline for visibility tests.
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
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.
std::string & trim(std::string &s) const
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)
std::string poseSavingFilename
Filename used to save the initial pose computed using the initClick() method. It is also used to read...
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
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 void getPose(vpHomogeneousMatrix &cMo_) const
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
unsigned int clippingFlag
Flags specifying which clipping to used.
double distNearClip
Distance for near clipping.
bool useLodGeneral
True if LOD mode is enabled.
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual vpColVector getError() const
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