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 #include <visp3/mbt/vpMbtDistanceCircle.h> 72 #include <visp3/mbt/vpMbtDistanceCylinder.h> 73 #include <visp3/mbt/vpMbtDistanceLine.h> 75 #ifdef VISP_HAVE_COIN3D 83 #include <Inventor/VRMLnodes/SoVRMLGroup.h> 84 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h> 85 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h> 256 virtual inline unsigned int getClipping()
const {
return clippingFlag; }
267 if (!computeCovariance) {
270 std::cerr <<
"Warning : The covariance matrix has not been computed. " 271 "See setCovarianceComputation() to do it." 275 return covarianceMatrix;
291 virtual inline double getLambda()
const {
return m_lambda; }
298 virtual inline unsigned int getMaxIter()
const {
return m_maxIter; }
368 virtual inline unsigned int getNbPolygon()
const {
return static_cast<unsigned int>(faces.
size()); }
397 if (index >= static_cast<unsigned int>(faces.
size())) {
404 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
405 getPolygonFaces(
const bool orderPolygons =
true,
const bool useVisibility =
true,
const bool clipPolygon =
false);
429 #ifdef VISP_HAVE_MODULE_GUI 430 virtual void initClick(
const vpImage<unsigned char> &I,
const std::string &initFile,
const bool displayHelp =
false,
433 const std::string &displayFile =
"");
437 virtual void initFromPoints(
const vpImage<unsigned char> &I,
const std::vector<vpImagePoint> &points2D_list,
438 const std::vector<vpPoint> &points3D_list);
475 virtual void setClipping(
const unsigned int &flags);
505 virtual void setEstimatedDoF(
const vpColVector &v);
507 virtual void setFarClippingDistance(
const double &dist);
514 virtual inline void setInitialMu(
const double mu) { m_initialMu = mu; }
521 virtual inline void setLambda(
const double gain) { m_lambda = gain; }
523 virtual void setLod(
const bool useLod,
const std::string &name =
"");
530 virtual inline void setMaxIter(
const unsigned int max) { m_maxIter = max; }
532 virtual void setMinLineLengthThresh(
const double minLineLengthThresh,
const std::string &name =
"");
534 virtual void setMinPolygonAreaThresh(
const double minPolygonAreaThresh,
const std::string &name =
"");
536 virtual void setNearClippingDistance(
const double &dist);
545 void setProjectionErrorMovingEdge(
const vpMe &me);
547 void setProjectionErrorKernelSize(
const unsigned int &size);
589 virtual void setOgreVisibilityTest(
const bool &v);
591 void savePose(
const std::string &filename)
const;
593 #ifdef VISP_HAVE_OGRE 658 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false) = 0;
672 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false) = 0;
688 virtual void loadConfigFile(
const std::string &configFile);
693 virtual void resetTracker() = 0;
712 virtual void testTracking() = 0;
723 void addPolygon(
const std::vector<vpPoint> &corners,
const int idFace = -1,
const std::string &polygonName =
"",
724 const bool useLod =
false,
const double minPolygonAreaThreshold = 2500.0,
725 const double minLineLengthThreshold = 50.0);
726 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
const int idFace = -1,
727 const std::string &polygonName =
"",
const bool useLod =
false,
728 const double minPolygonAreaThreshold = 2500.0);
729 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
const int idFace = -1,
const std::string &polygonName =
"",
730 const bool useLod =
false,
const double minLineLengthThreshold = 50);
731 void addPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
const int idFace = -1,
732 const std::string &polygonName =
"",
const bool useLod =
false,
733 const double minLineLengthThreshold = 50);
735 void addProjectionErrorCircle(
const vpPoint &P1,
const vpPoint &P2,
const vpPoint &P3,
const double r,
int idFace = -1,
736 const std::string &name =
"");
737 void addProjectionErrorCylinder(
const vpPoint &P1,
const vpPoint &P2,
const double r,
int idFace = -1,
const std::string &name =
"");
738 void addProjectionErrorLine(
vpPoint &p1,
vpPoint &p2,
int polygon = -1, std::string name =
"");
740 void addProjectionErrorPolygon(
const std::vector<vpPoint> &corners,
const int idFace = -1,
const std::string &polygonName =
"",
741 const bool useLod =
false,
const double minPolygonAreaThreshold = 2500.0,
742 const double minLineLengthThreshold = 50.0);
743 void addProjectionErrorPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
const int idFace = -1,
744 const std::string &polygonName =
"",
const bool useLod =
false,
745 const double minPolygonAreaThreshold = 2500.0);
746 void addProjectionErrorPolygon(
const vpPoint &p1,
const vpPoint &p2,
const int idFace = -1,
const std::string &polygonName =
"",
747 const bool useLod =
false,
const double minLineLengthThreshold = 50);
748 void addProjectionErrorPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
const int idFace = -1,
749 const std::string &polygonName =
"",
const bool useLod =
false,
750 const double minLineLengthThreshold = 50);
752 void createCylinderBBox(
const vpPoint &p1,
const vpPoint &p2,
const double &radius,
753 std::vector<std::vector<vpPoint> > &listFaces);
755 virtual void computeCovarianceMatrixVVS(
const bool isoJoIdentity_,
const vpColVector &w_true,
764 virtual void computeVVSCheckLevenbergMarquardt(
const unsigned int iter,
vpColVector &error,
766 double &mu,
bool &reStartFromLastIncrement,
768 virtual void computeVVSInit() = 0;
769 virtual void computeVVSInteractionMatrixAndResidu() = 0;
770 virtual void computeVVSPoseEstimation(
const bool isoJoIdentity_,
const unsigned int iter,
vpMatrix &L,
vpMatrix <L,
776 #ifdef VISP_HAVE_COIN3D 777 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
778 virtual void extractFaces(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
779 const std::string &polygonName =
"");
780 virtual void extractLines(SoVRMLIndexedLineSet *line_set,
int &idFace,
const std::string &polygonName =
"");
781 virtual void extractCylinders(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
782 const std::string &polygonName =
"");
785 vpPoint getGravityCenter(
const std::vector<vpPoint> &_pts)
const;
799 virtual void initCircle(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
800 const int idFace = 0,
const std::string &name =
"") = 0;
811 virtual void initCylinder(
const vpPoint &p1,
const vpPoint &p2,
const double radius,
const int idFace = 0,
812 const std::string &name =
"") = 0;
826 virtual void initFaceFromCorners(
vpMbtPolygon &polygon) = 0;
827 virtual void initFaceFromLines(
vpMbtPolygon &polygon) = 0;
829 void initProjectionErrorCircle(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
const double radius,
830 const int idFace = 0,
const std::string &name =
"");
831 void initProjectionErrorCylinder(
const vpPoint &p1,
const vpPoint &p2,
const double radius,
const int idFace = 0,
832 const std::string &name =
"");
833 void initProjectionErrorFaceFromCorners(
vpMbtPolygon &polygon);
834 void initProjectionErrorFaceFromLines(
vpMbtPolygon &polygon);
836 virtual void loadVRMLModel(
const std::string &modelFile);
837 virtual void loadCAOModel(
const std::string &modelFile, std::vector<std::string> &vectorOfModelFilename,
838 int &startIdFace,
const bool verbose =
false,
const bool parent =
true,
842 void projectionErrorResetMovingEdges();
845 void removeComment(std::ifstream &fileId);
849 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
850 std::istringstream is(input);
854 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
858 std::map<std::string, std::string> parseParameters(std::string &endLine);
860 inline std::string &
ltrim(std::string &s)
const 862 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
866 inline std::string &
rtrim(std::string &s)
const 868 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
872 inline std::string &
trim(std::string &s)
const {
return ltrim(rtrim(s)); }
bool m_computeInteraction
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)
bool m_projectionErrorDisplay
Display gradient and model orientation for projection error computation.
unsigned int m_projectionErrorDisplayLength
Length of the arrows used to show the gradient and model orientation.
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
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.
vpMe m_projectionErrorMe
Moving-Edges parameters for projection error.
std::string & rtrim(std::string &s) const
virtual double getStopCriteriaEpsilon() const
virtual double getLambda() const
error that can be emited by ViSP classes.
virtual void setMask(const vpImage< bool > &mask)
bool useOgre
Use Ogre3d for visibility tests.
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.
std::string & ltrim(std::string &s) const
virtual double getAngleDisappear() const
bool m_projectionErrorOgreShowConfigDialog
double distFarClip
Distance for near clipping.
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)
virtual vpHomogeneousMatrix getPose() const
bool useScanLine
Use Scanline for visibility tests.
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
virtual void setStopCriteriaEpsilon(const double eps)
virtual double getInitialMu() const
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void getCameraParameters(vpCameraParameters &camera) const
virtual double getProjectionError() const
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
vpMatrix m_SobelX
Sobel kernel in X.
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)
virtual void setProjectionErrorDisplay(const bool display)
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
std::vector< vpMbtDistanceLine * > m_projectionErrorLines
Distance line primitives for projection error.
unsigned int size() const
const vpImage< bool > * m_mask
Mask used to disable tracking on a part of image.
virtual double getNearClippingDistance() const
virtual unsigned int getMaxIter() const
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.
bool ogreShowConfigDialog
vpCameraParameters m_projectionErrorCam
Camera parameters used for projection error computation.
bool applyLodSettingInConfig
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
virtual void setProjectionErrorDisplayArrowLength(const unsigned int length)
vpMatrix m_SobelY
Sobel kernel in Y.
virtual void getPose(vpHomogeneousMatrix &cMo_) const
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 unsigned int getNbPolygon() const
void setPoseSavingFilename(const std::string &filename)
virtual void setScanLineVisibilityTest(const bool &v)
virtual double getFarClippingDistance() const
virtual void setProjectionErrorDisplayArrowThickness(const unsigned int thickness)
unsigned int clippingFlag
Flags specifying which clipping to used.
unsigned int m_projectionErrorKernelSize
Kernel size used to compute the gradient orientation.
std::vector< vpMbtDistanceCircle * > m_projectionErrorCircles
Distance circle primitive for projection error.
double distNearClip
Distance for near clipping.
bool useLodGeneral
True if LOD mode is enabled.
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
unsigned int m_projectionErrorDisplayThickness
Thickness of the arrows used to show the gradient and model orientation.
vpMbHiddenFaces< vpMbtPolygon > m_projectionErrorFaces
Set of faces describing the object, used for projection error.
std::vector< vpMbtDistanceCylinder * > m_projectionErrorCylinders
Distance cylinder primitives for projection error.
virtual void setProjectionErrorComputation(const bool &flag)
virtual vpMatrix getCovarianceMatrix() const