45 #ifndef vpMbTracker_hh 46 #define vpMbTracker_hh 52 #include <visp3/core/vpCameraParameters.h> 53 #include <visp3/core/vpColVector.h> 54 #include <visp3/core/vpHomogeneousMatrix.h> 55 #include <visp3/core/vpImage.h> 56 #include <visp3/core/vpImagePoint.h> 57 #include <visp3/core/vpMatrix.h> 58 #include <visp3/core/vpPoint.h> 59 #include <visp3/core/vpPolygon.h> 60 #include <visp3/core/vpRGBa.h> 61 #include <visp3/core/vpRobust.h> 62 #include <visp3/mbt/vpMbHiddenFaces.h> 63 #include <visp3/mbt/vpMbtPolygon.h> 65 #include <visp3/mbt/vpMbtDistanceCircle.h> 66 #include <visp3/mbt/vpMbtDistanceCylinder.h> 67 #include <visp3/mbt/vpMbtDistanceLine.h> 69 #ifdef VISP_HAVE_COIN3D 77 #include <Inventor/VRMLnodes/SoVRMLGroup.h> 78 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h> 79 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h> 252 virtual inline unsigned int getClipping()
const {
return clippingFlag; }
263 if (!computeCovariance) {
266 std::cerr <<
"Warning : The covariance matrix has not been computed. " 267 "See setCovarianceComputation() to do it." 271 return covarianceMatrix;
287 virtual inline double getLambda()
const {
return m_lambda; }
294 virtual inline unsigned int getMaxIter()
const {
return m_maxIter; }
364 virtual inline unsigned int getNbPolygon()
const {
return static_cast<unsigned int>(faces.
size()); }
393 if (index >= static_cast<unsigned int>(faces.
size())) {
400 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
401 getPolygonFaces(
bool orderPolygons =
true,
bool useVisibility =
true,
bool clipPolygon =
false);
425 #ifdef VISP_HAVE_MODULE_GUI 426 virtual void initClick(
const vpImage<unsigned char> &I,
const std::string &initFile,
bool displayHelp =
false,
428 virtual void initClick(
const vpImage<vpRGBa> &I_color,
const std::string &initFile,
bool displayHelp =
false,
432 const std::string &displayFile =
"");
433 virtual void initClick(
const vpImage<vpRGBa> &I_color,
const std::vector<vpPoint> &points3D_list,
434 const std::string &displayFile =
"");
438 virtual void initFromPoints(
const vpImage<vpRGBa> &I_color,
const std::string &initFile);
440 virtual void initFromPoints(
const vpImage<unsigned char> &I,
const std::vector<vpImagePoint> &points2D_list,
441 const std::vector<vpPoint> &points3D_list);
442 virtual void initFromPoints(
const vpImage<vpRGBa> &I_color,
const std::vector<vpImagePoint> &points2D_list,
443 const std::vector<vpPoint> &points3D_list);
446 virtual void initFromPose(
const vpImage<vpRGBa> &I_color,
const std::string &initFile);
485 virtual void setClipping(
const unsigned int &flags);
515 virtual void setEstimatedDoF(
const vpColVector &v);
517 virtual void setFarClippingDistance(
const double &dist);
531 virtual inline void setLambda(
double gain) { m_lambda = gain; }
533 virtual void setLod(
bool useLod,
const std::string &name =
"");
540 virtual inline void setMaxIter(
unsigned int max) { m_maxIter = max; }
542 virtual void setMinLineLengthThresh(
double minLineLengthThresh,
const std::string &name =
"");
544 virtual void setMinPolygonAreaThresh(
double minPolygonAreaThresh,
const std::string &name =
"");
546 virtual void setNearClippingDistance(
const double &dist);
555 void setProjectionErrorMovingEdge(
const vpMe &me);
557 void setProjectionErrorKernelSize(
const unsigned int &size);
599 virtual void setOgreVisibilityTest(
const bool &v);
601 void savePose(
const std::string &filename)
const;
603 #ifdef VISP_HAVE_OGRE 668 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false) = 0;
682 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false) = 0;
684 virtual std::vector<std::vector<double> > getModelForDisplay(
unsigned int width,
unsigned int height,
687 bool displayFullModel=
false)=0;
703 virtual void loadConfigFile(
const std::string &configFile);
708 virtual void resetTracker() = 0;
739 virtual void testTracking() = 0;
757 void addPolygon(
const std::vector<vpPoint> &corners,
int idFace = -1,
const std::string &polygonName =
"",
758 bool useLod =
false,
double minPolygonAreaThreshold = 2500.0,
759 double minLineLengthThreshold = 50.0);
760 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
double radius,
int idFace = -1,
761 const std::string &polygonName =
"",
bool useLod =
false,
762 double minPolygonAreaThreshold = 2500.0);
763 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
int idFace = -1,
const std::string &polygonName =
"",
764 bool useLod =
false,
double minLineLengthThreshold = 50);
765 void addPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
int idFace = -1,
766 const std::string &polygonName =
"",
bool useLod =
false,
767 double minLineLengthThreshold = 50);
769 void addProjectionErrorCircle(
const vpPoint &P1,
const vpPoint &P2,
const vpPoint &P3,
double r,
int idFace = -1,
770 const std::string &name =
"");
771 void addProjectionErrorCylinder(
const vpPoint &P1,
const vpPoint &P2,
double r,
int idFace = -1,
const std::string &name =
"");
772 void addProjectionErrorLine(
vpPoint &p1,
vpPoint &p2,
int polygon = -1, std::string name =
"");
774 void addProjectionErrorPolygon(
const std::vector<vpPoint> &corners,
int idFace = -1,
const std::string &polygonName =
"",
775 bool useLod =
false,
double minPolygonAreaThreshold = 2500.0,
776 const double minLineLengthThreshold = 50.0);
777 void addProjectionErrorPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
double radius,
int idFace = -1,
778 const std::string &polygonName =
"",
bool useLod =
false,
779 double minPolygonAreaThreshold = 2500.0);
780 void addProjectionErrorPolygon(
const vpPoint &p1,
const vpPoint &p2,
int idFace = -1,
const std::string &polygonName =
"",
781 bool useLod =
false,
double minLineLengthThreshold = 50);
782 void addProjectionErrorPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
int idFace = -1,
783 const std::string &polygonName =
"",
bool useLod =
false,
784 double minLineLengthThreshold = 50);
786 void createCylinderBBox(
const vpPoint &p1,
const vpPoint &p2,
const double &radius,
787 std::vector<std::vector<vpPoint> > &listFaces);
789 virtual void computeCovarianceMatrixVVS(
const bool isoJoIdentity_,
const vpColVector &w_true,
798 virtual void computeVVSCheckLevenbergMarquardt(
unsigned int iter,
vpColVector &error,
800 double &mu,
bool &reStartFromLastIncrement,
802 virtual void computeVVSInit() = 0;
803 virtual void computeVVSInteractionMatrixAndResidu() = 0;
804 virtual void computeVVSPoseEstimation(
const bool isoJoIdentity_,
unsigned int iter,
vpMatrix &L,
vpMatrix <L,
810 #ifdef VISP_HAVE_COIN3D 811 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
812 virtual void extractFaces(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
813 const std::string &polygonName =
"");
814 virtual void extractLines(SoVRMLIndexedLineSet *line_set,
int &idFace,
const std::string &polygonName =
"");
815 virtual void extractCylinders(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
816 const std::string &polygonName =
"");
819 vpPoint getGravityCenter(
const std::vector<vpPoint> &_pts)
const;
835 int idFace = 0,
const std::string &name =
"") = 0;
837 #ifdef VISP_HAVE_MODULE_GUI 842 const std::vector<vpPoint> &points3D_list,
const std::string &displayFile =
"");
846 const std::string &initFile);
849 const std::vector<vpImagePoint> &points2D_list,
const std::vector<vpPoint> &points3D_list);
852 const std::string &initFile);
864 virtual void initCylinder(
const vpPoint &p1,
const vpPoint &p2,
double radius,
int idFace = 0,
865 const std::string &name =
"") = 0;
879 virtual void initFaceFromCorners(
vpMbtPolygon &polygon) = 0;
880 virtual void initFaceFromLines(
vpMbtPolygon &polygon) = 0;
882 void initProjectionErrorCircle(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
double radius,
883 int idFace = 0,
const std::string &name =
"");
884 void initProjectionErrorCylinder(
const vpPoint &p1,
const vpPoint &p2,
double radius,
int idFace = 0,
885 const std::string &name =
"");
886 void initProjectionErrorFaceFromCorners(
vpMbtPolygon &polygon);
887 void initProjectionErrorFaceFromLines(
vpMbtPolygon &polygon);
889 virtual void loadVRMLModel(
const std::string &modelFile);
890 virtual void loadCAOModel(
const std::string &modelFile, std::vector<std::string> &vectorOfModelFilename,
891 int &startIdFace,
bool verbose =
false,
bool parent =
true,
895 void projectionErrorResetMovingEdges();
896 void projectionErrorVisibleFace(
unsigned int width,
unsigned int height,
const vpHomogeneousMatrix &_cMo);
898 void removeComment(std::ifstream &fileId);
900 std::map<std::string, std::string> parseParameters(std::string &endLine);
virtual unsigned int getClipping() const
bool m_computeInteraction
virtual double getStopCriteriaEpsilon() const
virtual void setCovarianceComputation(const bool &flag)
Implementation of a matrix and operations on matrices.
vpMatrix covarianceMatrix
Covariance matrix.
bool m_projectionErrorDisplay
Display gradient and model orientation for projection error computation.
vpCameraParameters m_cam
The camera parameters.
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.
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 vpMbtPolygon * getPolygon(unsigned int index)
virtual double getInitialMu() const
vpMe m_projectionErrorMe
Moving-Edges parameters for projection error.
virtual void setOgreShowConfigDialog(bool showConfigDialog)
virtual double getProjectionError() const
error that can be emited by ViSP classes.
virtual void setMask(const vpImage< bool > &mask)
bool useOgre
Use Ogre3d for visibility tests.
virtual vpMbtOptimizationMethod getOptimizationMethod() const
std::string modelFileName
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
virtual void setProjectionErrorDisplayArrowLength(unsigned int length)
Class that defines what is a point.
bool m_projectionErrorOgreShowConfigDialog
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)
virtual void getPose(vpHomogeneousMatrix &cMo) const
virtual void setCameraParameters(const vpCameraParameters &cam)
Implementation of a polygon of the model used by the model-based tracker.
virtual void setInitialMu(double mu)
bool useScanLine
Use Scanline for visibility tests.
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
virtual void setLambda(double gain)
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.
vpMatrix m_SobelX
Sobel kernel in X.
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.
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.
virtual void setProjectionErrorDisplay(bool display)
virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness)
const vpImage< bool > * m_mask
Mask used to disable tracking on a part of image.
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
virtual unsigned int getNbPolygon() const
vpCameraParameters m_projectionErrorCam
Camera parameters used for projection error computation.
virtual void setMaxIter(unsigned int max)
bool applyLodSettingInConfig
Implementation of column vector and the associated operations.
virtual vpMatrix getCovarianceMatrix() const
Implementation of a pose vector and operations on poses.
vpMatrix m_SobelY
Sobel kernel in Y.
Contains an M-Estimator and various influence function.
double angleDisappears
Angle used to detect a face disappearance.
virtual double getLambda() 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.
unsigned int m_projectionErrorKernelSize
Kernel size used to compute the gradient orientation.
std::vector< vpMbtDistanceCircle * > m_projectionErrorCircles
Distance circle primitive for projection error.
vpImage< unsigned char > m_I
Grayscale image buffer, used when passing color images.
double distNearClip
Distance for near clipping.
bool useLodGeneral
True if LOD mode is enabled.
vpHomogeneousMatrix m_cMo
The current pose.
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual void setDisplayFeatures(bool displayF)
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.
virtual void getCameraParameters(vpCameraParameters &cam) const
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 double getFarClippingDistance() const
virtual void setProjectionErrorComputation(const bool &flag)
virtual double getAngleAppear() const