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> 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(
bool orderPolygons =
true,
bool useVisibility =
true,
bool clipPolygon =
false);
429 #ifdef VISP_HAVE_MODULE_GUI 430 virtual void initClick(
const vpImage<unsigned char> &I,
const std::string &initFile,
bool displayHelp =
false,
432 virtual void initClick(
const vpImage<vpRGBa> &I_color,
const std::string &initFile,
bool displayHelp =
false,
436 const std::string &displayFile =
"");
437 virtual void initClick(
const vpImage<vpRGBa> &I_color,
const std::vector<vpPoint> &points3D_list,
438 const std::string &displayFile =
"");
442 virtual void initFromPoints(
const vpImage<vpRGBa> &I_color,
const std::string &initFile);
444 virtual void initFromPoints(
const vpImage<unsigned char> &I,
const std::vector<vpImagePoint> &points2D_list,
445 const std::vector<vpPoint> &points3D_list);
446 virtual void initFromPoints(
const vpImage<vpRGBa> &I_color,
const std::vector<vpImagePoint> &points2D_list,
447 const std::vector<vpPoint> &points3D_list);
450 virtual void initFromPose(
const vpImage<vpRGBa> &I_color,
const std::string &initFile);
489 virtual void setClipping(
const unsigned int &flags);
519 virtual void setEstimatedDoF(
const vpColVector &v);
521 virtual void setFarClippingDistance(
const double &dist);
535 virtual inline void setLambda(
double gain) { m_lambda = gain; }
537 virtual void setLod(
bool useLod,
const std::string &name =
"");
544 virtual inline void setMaxIter(
unsigned int max) { m_maxIter = max; }
546 virtual void setMinLineLengthThresh(
double minLineLengthThresh,
const std::string &name =
"");
548 virtual void setMinPolygonAreaThresh(
double minPolygonAreaThresh,
const std::string &name =
"");
550 virtual void setNearClippingDistance(
const double &dist);
559 void setProjectionErrorMovingEdge(
const vpMe &me);
561 void setProjectionErrorKernelSize(
const unsigned int &size);
603 virtual void setOgreVisibilityTest(
const bool &v);
605 void savePose(
const std::string &filename)
const;
607 #ifdef VISP_HAVE_OGRE 672 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false) = 0;
686 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false) = 0;
688 virtual std::vector<std::vector<double> > getModelForDisplay(
unsigned int width,
unsigned int height,
691 bool displayFullModel=
false)=0;
708 virtual void loadConfigFile(
const std::string &configFile,
bool verbose=
true);
713 virtual void resetTracker() = 0;
744 virtual void testTracking() = 0;
762 void addPolygon(
const std::vector<vpPoint> &corners,
int idFace = -1,
const std::string &polygonName =
"",
763 bool useLod =
false,
double minPolygonAreaThreshold = 2500.0,
764 double minLineLengthThreshold = 50.0);
765 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
double radius,
int idFace = -1,
766 const std::string &polygonName =
"",
bool useLod =
false,
767 double minPolygonAreaThreshold = 2500.0);
768 void addPolygon(
const vpPoint &p1,
const vpPoint &p2,
int idFace = -1,
const std::string &polygonName =
"",
769 bool useLod =
false,
double minLineLengthThreshold = 50);
770 void addPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
int idFace = -1,
771 const std::string &polygonName =
"",
bool useLod =
false,
772 double minLineLengthThreshold = 50);
774 void addProjectionErrorCircle(
const vpPoint &P1,
const vpPoint &P2,
const vpPoint &P3,
double r,
int idFace = -1,
775 const std::string &name =
"");
776 void addProjectionErrorCylinder(
const vpPoint &P1,
const vpPoint &P2,
double r,
int idFace = -1,
const std::string &name =
"");
777 void addProjectionErrorLine(
vpPoint &p1,
vpPoint &p2,
int polygon = -1, std::string name =
"");
779 void addProjectionErrorPolygon(
const std::vector<vpPoint> &corners,
int idFace = -1,
const std::string &polygonName =
"",
780 bool useLod =
false,
double minPolygonAreaThreshold = 2500.0,
781 const double minLineLengthThreshold = 50.0);
782 void addProjectionErrorPolygon(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
double radius,
int idFace = -1,
783 const std::string &polygonName =
"",
bool useLod =
false,
784 double minPolygonAreaThreshold = 2500.0);
785 void addProjectionErrorPolygon(
const vpPoint &p1,
const vpPoint &p2,
int idFace = -1,
const std::string &polygonName =
"",
786 bool useLod =
false,
double minLineLengthThreshold = 50);
787 void addProjectionErrorPolygon(
const std::vector<std::vector<vpPoint> > &listFaces,
int idFace = -1,
788 const std::string &polygonName =
"",
bool useLod =
false,
789 double minLineLengthThreshold = 50);
791 void createCylinderBBox(
const vpPoint &p1,
const vpPoint &p2,
const double &radius,
792 std::vector<std::vector<vpPoint> > &listFaces);
794 virtual void computeCovarianceMatrixVVS(
const bool isoJoIdentity_,
const vpColVector &w_true,
803 virtual void computeVVSCheckLevenbergMarquardt(
unsigned int iter,
vpColVector &error,
805 double &mu,
bool &reStartFromLastIncrement,
807 virtual void computeVVSInit() = 0;
808 virtual void computeVVSInteractionMatrixAndResidu() = 0;
809 virtual void computeVVSPoseEstimation(
const bool isoJoIdentity_,
unsigned int iter,
vpMatrix &L,
vpMatrix <L,
815 #ifdef VISP_HAVE_COIN3D 816 virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2,
vpHomogeneousMatrix &transform,
int &idFace);
817 virtual void extractFaces(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
818 const std::string &polygonName =
"");
819 virtual void extractLines(SoVRMLIndexedLineSet *line_set,
int &idFace,
const std::string &polygonName =
"");
820 virtual void extractCylinders(SoVRMLIndexedFaceSet *face_set,
vpHomogeneousMatrix &transform,
int &idFace,
821 const std::string &polygonName =
"");
824 vpPoint getGravityCenter(
const std::vector<vpPoint> &_pts)
const;
840 int idFace = 0,
const std::string &name =
"") = 0;
842 #ifdef VISP_HAVE_MODULE_GUI 847 const std::vector<vpPoint> &points3D_list,
const std::string &displayFile =
"");
851 const std::string &initFile);
854 const std::vector<vpImagePoint> &points2D_list,
const std::vector<vpPoint> &points3D_list);
857 const std::string &initFile);
869 virtual void initCylinder(
const vpPoint &p1,
const vpPoint &p2,
double radius,
int idFace = 0,
870 const std::string &name =
"") = 0;
884 virtual void initFaceFromCorners(
vpMbtPolygon &polygon) = 0;
885 virtual void initFaceFromLines(
vpMbtPolygon &polygon) = 0;
887 void initProjectionErrorCircle(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
double radius,
888 int idFace = 0,
const std::string &name =
"");
889 void initProjectionErrorCylinder(
const vpPoint &p1,
const vpPoint &p2,
double radius,
int idFace = 0,
890 const std::string &name =
"");
891 void initProjectionErrorFaceFromCorners(
vpMbtPolygon &polygon);
892 void initProjectionErrorFaceFromLines(
vpMbtPolygon &polygon);
894 virtual void loadVRMLModel(
const std::string &modelFile);
895 virtual void loadCAOModel(
const std::string &modelFile, std::vector<std::string> &vectorOfModelFilename,
896 int &startIdFace,
bool verbose =
false,
bool parent =
true,
900 void projectionErrorResetMovingEdges();
901 void projectionErrorVisibleFace(
unsigned int width,
unsigned int height,
const vpHomogeneousMatrix &_cMo);
903 void removeComment(std::ifstream &fileId);
905 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 RGB 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 a 3D point in the object frame and allows forward projection of a 3D point in the ...
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.
bool m_sodb_init_called
Flag that indicates that SoDB::init(); was called.
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)
vpUniRand m_rand
Random number generator used in vpMbtDistanceLine::buildFrom()
Class for generating random numbers with uniform probability density.
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