45 #ifndef vpMbTracker_hh 46 #define vpMbTracker_hh 58 #include <visp3/core/vpCameraParameters.h> 59 #include <visp3/core/vpColVector.h> 60 #include <visp3/core/vpHomogeneousMatrix.h> 61 #include <visp3/core/vpImage.h> 62 #include <visp3/core/vpImagePoint.h> 63 #include <visp3/core/vpMatrix.h> 64 #include <visp3/core/vpPoint.h> 65 #include <visp3/core/vpPolygon.h> 66 #include <visp3/core/vpRGBa.h> 67 #include <visp3/core/vpRobust.h> 68 #include <visp3/mbt/vpMbHiddenFaces.h> 69 #include <visp3/mbt/vpMbtPolygon.h> 71 #ifdef VISP_HAVE_COIN3D 79 #include <Inventor/VRMLnodes/SoVRMLGroup.h> 80 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h> 81 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h> 223 virtual inline unsigned int getClipping()
const {
return clippingFlag; }
234 if (!computeCovariance) {
237 std::cerr <<
"Warning : The covariance matrix has not been computed. " 238 "See setCovarianceComputation() to do it." 242 return covarianceMatrix;
258 virtual inline double getLambda()
const {
return m_lambda; }
265 virtual inline unsigned int getMaxIter()
const {
return m_maxIter; }
335 virtual inline unsigned int getNbPolygon()
const {
return static_cast<unsigned int>(faces.
size()); }
364 if (index >= static_cast<unsigned int>(faces.
size())) {
371 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
372 getPolygonFaces(
const bool orderPolygons =
true,
const bool useVisibility =
true,
const bool clipPolygon =
false);
396 #ifdef VISP_HAVE_MODULE_GUI 397 virtual void initClick(
const vpImage<unsigned char> &I,
const std::string &initFile,
const bool displayHelp =
false);
399 const std::string &displayFile =
"");
403 virtual void initFromPoints(
const vpImage<unsigned char> &I,
const std::vector<vpImagePoint> &points2D_list,
404 const std::vector<vpPoint> &points3D_list);
410 virtual void loadModel(
const char *modelFile,
const bool verbose =
false);
411 virtual void loadModel(
const std::string &modelFile,
const bool verbose =
false);
442 virtual void setClipping(
const unsigned int &flags);
472 virtual void setEstimatedDoF(
const vpColVector &v);
474 virtual void setFarClippingDistance(
const double &dist);
481 virtual inline void setInitialMu(
const double mu) { m_initialMu = mu; }
488 virtual inline void setLambda(
const double gain) { m_lambda = gain; }
490 virtual void setLod(
const bool useLod,
const std::string &name =
"");
497 virtual inline void setMaxIter(
const unsigned int max) { m_maxIter = max; }
499 virtual void setMinLineLengthThresh(
const double minLineLengthThresh,
const std::string &name =
"");
501 virtual void setMinPolygonAreaThresh(
const double minPolygonAreaThresh,
const std::string &name =
"");
503 virtual void setNearClippingDistance(
const double &dist);
535 virtual void setOgreVisibilityTest(
const bool &v);
537 void savePose(
const std::string &filename)
const;
539 #ifdef VISP_HAVE_OGRE 604 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false) = 0;
618 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false) = 0;
634 virtual void loadConfigFile(
const std::string &configFile) = 0;
639 virtual void resetTracker() = 0;
658 virtual void testTracking() = 0;
671 void addPolygon(
const std::vector<vpPoint> &corners,
const int idFace = -1,
const std::string &polygonName =
"",
672 const bool useLod =
false,
const double minPolygonAreaThreshold = 2500.0,
673 const double minLineLengthThreshold = 50.0);
674 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
const int idFace = -1,
675 const std::string &polygonName =
"",
const bool useLod =
false,
676 const double minPolygonAreaThreshold = 2500.0);
677 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
const int idFace = -1,
const std::string &polygonName =
"",
678 const bool useLod =
false,
const double minLineLengthThreshold = 50);
679 void addPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
const int idFace = -1,
680 const std::string &polygonName =
"",
const bool useLod =
false,
681 const double minLineLengthThreshold = 50);
683 void createCylinderBBox(
const vpPoint &p1,
const vpPoint &p2,
const double &radius,
684 std::vector<std::vector<vpPoint> > &listFaces);
686 virtual void computeCovarianceMatrixVVS(
const bool isoJoIdentity_,
const vpColVector &w_true,
692 virtual void computeVVSCheckLevenbergMarquardt(
const unsigned int iter,
vpColVector &error,
694 double &mu,
bool &reStartFromLastIncrement,
696 virtual void computeVVSInit() = 0;
697 virtual void computeVVSInteractionMatrixAndResidu() = 0;
698 virtual void computeVVSPoseEstimation(
const bool isoJoIdentity_,
const unsigned int iter,
vpMatrix &L,
vpMatrix <L,
704 #ifdef VISP_HAVE_COIN3D 705 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
706 virtual void extractFaces(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
707 const std::string &polygonName =
"");
708 virtual void extractLines(SoVRMLIndexedLineSet *line_set,
int &idFace,
const std::string &polygonName =
"");
709 virtual void extractCylinders(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
710 const std::string &polygonName =
"");
713 vpPoint getGravityCenter(
const std::vector<vpPoint> &_pts)
const;
727 virtual void initCircle(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
728 const int idFace = 0,
const std::string &name =
"") = 0;
739 virtual void initCylinder(
const vpPoint &p1,
const vpPoint &p2,
const double radius,
const int idFace = 0,
740 const std::string &name =
"") = 0;
754 virtual void initFaceFromCorners(
vpMbtPolygon &polygon) = 0;
755 virtual void initFaceFromLines(
vpMbtPolygon &polygon) = 0;
757 virtual void loadVRMLModel(
const std::string &modelFile);
758 virtual void loadCAOModel(
const std::string &modelFile, std::vector<std::string> &vectorOfModelFilename,
759 int &startIdFace,
const bool verbose =
false,
const bool parent =
true);
761 void removeComment(std::ifstream &fileId);
765 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
766 std::istringstream is(input);
770 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
774 std::map<std::string, std::string> parseParameters(std::string &endLine);
776 inline std::string &
ltrim(std::string &s)
const 778 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
782 inline std::string &
rtrim(std::string &s)
const 784 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
788 inline std::string &
trim(std::string &s)
const {
return ltrim(rtrim(s)); }
virtual unsigned int getClipping() const
bool m_computeInteraction
virtual double getStopCriteriaEpsilon() const
virtual void setDisplayFeatures(const bool displayF)
virtual void setCovarianceComputation(const bool &flag)
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Implementation of a matrix and operations on matrices.
vpMatrix covarianceMatrix
Covariance matrix.
bool parseBoolean(std::string &input)
virtual void getPose(vpHomogeneousMatrix &cMo_) const
unsigned int nbLines
Number of lines in CAO model.
unsigned int size() 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 unsigned int getMaxIter() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::map< std::string, std::string > mapOfParameterNames
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.
virtual double getInitialMu() const
vpHomogeneousMatrix cMo
The current pose.
virtual double getProjectionError() const
error that can be emited by ViSP classes.
bool useOgre
Use Ogre3d for visibility tests.
virtual vpMbtOptimizationMethod getOptimizationMethod() const
std::string modelFileName
virtual void setMaxIter(const unsigned int max)
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
virtual void setInitialMu(const double mu)
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
double distFarClip
Distance for near clipping.
virtual vpHomogeneousMatrix getPose() const
virtual double getAngleDisappear() const
vpMatrix oJo
The Degrees of Freedom to estimate.
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Implementation of a polygon of the model used by the model-based tracker.
virtual void setCameraParameters(const vpCameraParameters &camera)
bool useScanLine
Use Scanline for visibility tests.
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
virtual void setStopCriteriaEpsilon(const double eps)
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
std::string & trim(std::string &s) const
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
double m_lambda
Gain of the virtual visual servoing stage.
unsigned int nbPolygonLines
Number of polygon lines in CAO model.
virtual void setAngleAppear(const double &a)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
virtual void setLambda(const double gain)
double angleAppears
Angle used to detect a face appearance.
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
std::string poseSavingFilename
unsigned int nbPolygonPoints
Number of polygon points in CAO model.
double m_stopCriteriaEpsilon
Epsilon threshold to stop the VVS optimization loop.
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
bool displayFeatures
If true, the features are displayed.
virtual void getCameraParameters(vpCameraParameters &camera) const
bool ogreShowConfigDialog
virtual unsigned int getNbPolygon() const
bool applyLodSettingInConfig
Implementation of column vector and the associated operations.
virtual vpMatrix getCovarianceMatrix() const
Implementation of a pose vector and operations on poses.
virtual vpMbtPolygon * getPolygon(const unsigned int index)
Contains an M-Estimator and various influence function.
double angleDisappears
Angle used to detect a face disappearance.
virtual double getLambda() const
std::string & rtrim(std::string &s) const
void setPoseSavingFilename(const std::string &filename)
virtual void setScanLineVisibilityTest(const bool &v)
virtual double getNearClippingDistance() 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()
std::string & ltrim(std::string &s) const
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
virtual double getFarClippingDistance() const
virtual void setProjectionErrorComputation(const bool &flag)
virtual double getAngleAppear() const