47 #ifndef vpMbTracker_hh
48 #define vpMbTracker_hh
61 #include <visp/vpHomogeneousMatrix.h>
62 #include <visp/vpImage.h>
63 #include <visp/vpImagePoint.h>
64 #include <visp/vpColVector.h>
65 #include <visp/vpMatrix.h>
66 #include <visp/vpRGBa.h>
67 #include <visp/vpCameraParameters.h>
68 #include <visp/vpPoint.h>
69 #include <visp/vpMbtPolygon.h>
70 #include <visp/vpMbHiddenFaces.h>
71 #include <visp/vpPolygon.h>
80 # include <Inventor/VRMLnodes/SoVRMLGroup.h>
81 # include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h>
82 # include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h>
187 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false)=0;
200 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false)=0;
220 virtual inline unsigned int getClipping()
const {
return clippingFlag; }
226 if(!computeCovariance)
227 vpTRACE(
"Warning : The covariance matrix has not been computed. See setCovarianceComputation() to do it.");
229 return covarianceMatrix;
291 return static_cast<unsigned int>(faces.
size());
311 if(index >= static_cast<unsigned int>(faces.
size()) ){
318 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > getPolygonFaces(
const bool orderPolygons=
true,
319 const bool useVisibility=
true);
350 virtual void initClick(
const vpImage<unsigned char>& I,
const std::string& initFile,
const bool displayHelp =
false );
352 const std::string &displayFile =
"" );
355 virtual void initFromPoints(
const vpImage<unsigned char>& I,
const std::vector<vpImagePoint> &points2D_list,
const std::vector<vpPoint> &points3D_list );
368 virtual void loadConfigFile(
const std::string& configFile)=0;
370 virtual void loadModel(
const char *modelFile,
const bool verbose=
false);
371 virtual void loadModel(
const std::string &modelFile,
const bool verbose=
false);
376 virtual void resetTracker() = 0;
378 void savePose(
const std::string &filename);
409 virtual void setClipping(
const unsigned int &flags);
418 virtual void setEstimatedDoF(
const vpColVector& v);
433 virtual void setFarClippingDistance(
const double &dist);
435 virtual void setLod(
const bool useLod,
const std::string &name=
"");
437 virtual void setMinLineLengthThresh(
const double minLineLengthThresh,
const std::string &name=
"");
439 virtual void setMinPolygonAreaThresh(
const double minPolygonAreaThresh,
const std::string &name=
"");
441 virtual void setNearClippingDistance(
const double &dist);
464 poseSavingFilename = filename;
467 virtual void setOgreVisibilityTest(
const bool &v);
474 virtual void testTracking() = 0;
484 void addPolygon(
const std::vector<vpPoint>& corners,
const int idFace=-1,
const std::string &polygonName=
"",
485 const bool useLod=
false,
const double minPolygonAreaThreshold=2500.0,
const double minLineLengthThreshold=50.0);
486 void addPolygon(
const vpPoint& p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
const int idFace=-1,
487 const std::string &polygonName=
"",
const bool useLod=
false,
const double minPolygonAreaThreshold=2500.0);
488 void addPolygon(
const vpPoint& p1,
const vpPoint &p2,
const int idFace=-1,
const std::string &polygonName=
"",
489 const bool useLod=
false,
const double minLineLengthThreshold=50);
494 #ifdef VISP_HAVE_COIN
495 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
496 virtual void extractFaces(SoVRMLIndexedFaceSet* face_set,
vpHomogeneousMatrix &transform,
int &idFace);
497 virtual void extractLines(SoVRMLIndexedLineSet* line_set,
int &idFace);
498 virtual void extractCylinders(SoVRMLIndexedFaceSet* face_set,
vpHomogeneousMatrix &transform,
int &idFace);
501 vpPoint getGravityCenter(
const std::vector<vpPoint>& _pts);
514 virtual void initCircle(
const vpPoint& p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
515 const int idFace=0,
const std::string &name=
"")=0;
526 virtual void initCylinder(
const vpPoint& p1,
const vpPoint &p2,
const double radius,
const int idFace=0,
527 const std::string &name=
"")=0;
539 virtual void initFaceFromCorners(
vpMbtPolygon &polygon)=0;
540 virtual void initFaceFromLines(
vpMbtPolygon &polygon)=0;
542 virtual void loadVRMLModel(
const std::string& modelFile);
543 virtual void loadCAOModel(
const std::string& modelFile, std::vector<std::string>& vectorOfModelFilename,
int& startIdFace,
544 const bool verbose=
false,
const bool parent=
true);
546 void removeComment(std::ifstream& fileId);
549 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
550 std::istringstream is(input);
554 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
558 std::map<std::string, std::string> parseParameters(std::string& endLine);
560 inline std::string &
ltrim(std::string &s) {
561 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
565 inline std::string &
rtrim(std::string &s) {
566 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
570 inline std::string &
trim(std::string &s) {
571 return ltrim(rtrim(s));
virtual void setCovarianceComputation(const bool &flag)
std::string & rtrim(std::string &s)
Definition of the vpMatrix class.
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.
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
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.
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.
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
virtual double getAngleDisappear() const
double distFarClip
Distance for near clipping.
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
std::string & ltrim(std::string &s)
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
vpColVector m_error
Error s-s*.
virtual void getCameraParameters(vpCameraParameters &camera) 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)
double angleAppears
Angle used to detect a face appearance.
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.
virtual vpColVector getRobustWeights()
bool applyLodSettingInConfig
True if the CAO model is loaded before the call to loadConfigFile, (deduced by the number of polygons...
Class that provides a data structure for the column vectors as well as a set of operations on these v...
The pose is a complete representation of every rigid motion in the euclidian space.
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 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 vpMatrix getCovarianceMatrix() const