45 #ifndef vpMbEdgeTracker_HH 46 #define vpMbEdgeTracker_HH 48 #include <visp3/core/vpPoint.h> 49 #include <visp3/mbt/vpMbTracker.h> 50 #include <visp3/me/vpMe.h> 51 #include <visp3/mbt/vpMbtMeLine.h> 52 #include <visp3/mbt/vpMbtDistanceLine.h> 53 #include <visp3/mbt/vpMbtDistanceCircle.h> 54 #include <visp3/mbt/vpMbtDistanceCylinder.h> 55 #include <visp3/core/vpXmlParser.h> 56 #include <visp3/core/vpRobust.h> 63 #if defined(VISP_HAVE_COIN3D) 65 #include <Inventor/nodes/SoSeparator.h> 66 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h> 67 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h> 68 #include <Inventor/VRMLnodes/SoVRMLCoordinate.h> 69 #include <Inventor/actions/SoWriteAction.h> 70 #include <Inventor/actions/SoSearchAction.h> 71 #include <Inventor/misc/SoChildList.h> 72 #include <Inventor/actions/SoGetMatrixAction.h> 73 #include <Inventor/actions/SoGetPrimitiveCountAction.h> 74 #include <Inventor/actions/SoToVRML2Action.h> 75 #include <Inventor/VRMLnodes/SoVRMLGroup.h> 76 #include <Inventor/VRMLnodes/SoVRMLShape.h> 79 #ifdef VISP_HAVE_OPENCV 80 # if VISP_HAVE_OPENCV_VERSION >= 0x020101 81 # include <opencv2/core/core.hpp> 82 # include <opencv2/imgproc/imgproc.hpp> 83 # include <opencv2/imgproc/imgproc_c.h> 279 std::vector< std::list< vpMbtDistanceLine*> >
lines;
282 std::vector< std::list< vpMbtDistanceCircle*> >
circles;
285 std::vector< std::list< vpMbtDistanceCylinder*> >
cylinders;
306 std::vector< const vpImage<unsigned char>* >
Ipyramid;
323 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false);
325 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false);
334 void getLline(std::list<vpMbtDistanceLine *>& linesList,
const unsigned int level = 0)
const;
335 void getLcircle(std::list<vpMbtDistanceCircle *>& circlesList,
const unsigned int level = 0)
const;
336 void getLcylinder(std::list<vpMbtDistanceCylinder *>& cylindersList,
const unsigned int level = 0)
const;
351 virtual unsigned int getNbPoints(
const unsigned int level=0)
const;
372 const bool verbose=
false);
374 const bool verbose=
false);
385 for (
unsigned int i = 0; i < scales.size(); i += 1){
387 for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[i].begin(); it!=lines[i].end(); ++it){
388 (*it)->setCameraParameters(
cam);
391 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[i].begin(); it!=cylinders[i].end(); ++it){
392 (*it)->setCameraParameters(
cam);
395 for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles[i].begin(); it!=circles[i].end(); ++it){
396 (*it)->setCameraParameters(
cam);
402 virtual void setClipping(
const unsigned int &flags);
417 #ifdef VISP_HAVE_OGRE 430 for (
unsigned int i = 0; i < scales.size(); i += 1){
432 for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[i].begin(); it!=lines[i].end(); ++it){
433 (*it)->useScanLine = v;
458 virtual inline void setLambda(
const double gain) {this->lambda = gain;}
464 void setScales(
const std::vector<bool>& _scales);
493 double &mu,
bool &reStartFromLastIncrement);
499 const unsigned int nbrow,
vpColVector &weighted_error,
503 const unsigned int nberrors_lines,
const unsigned int nberrors_cylinders,
const unsigned int nberrors_circles);
506 void downScale(
const unsigned int _scale);
509 const int idFace=0,
const std::string &name=
"");
511 const std::string &name=
"");
514 unsigned int initMbtTracking(
unsigned int &nberrors_lines,
unsigned int &nberrors_cylinders,
unsigned int &nberrors_circles);
527 void upScale(
const unsigned int _scale);
void setWindowName(const Ogre::String &n)
unsigned int ncylinder
Index of the cylinder to add, and total number of cylinders extracted so far.
void computeVVSFirstPhasePoseEstimation(const unsigned int nerror, const unsigned int iter, const vpColVector &factor, vpColVector &weighted_error, vpMatrix &L, bool &isoJoIdentity_)
Implementation of a matrix and operations on matrices.
virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
double lambda
The gain of the virtual visual servoing stage.
virtual void track(const vpImage< unsigned char > &I)=0
virtual void addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, const double r, const std::string &name="")
void upScale(const unsigned int _scale)
void addLine(vpPoint &p1, vpPoint &p2, int polygon=-1, std::string name="")
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual void computeProjectionError()
Implementation of an homogeneous matrix and operations on such kind of matrices.
void getLline(std::list< vpMbtDistanceLine *> &linesList, const unsigned int level=0) const
double lambda
The gain of the virtual visual servoing stage.
unsigned int scaleLevel
Current scale level used. This attribute must not be modified outside of the downScale() and upScale(...
std::vector< std::list< vpMbtDistanceCircle * > > circles
Vector of the tracked circles.
Class to define colors available for display functionnalities.
vpHomogeneousMatrix cMo
The current pose.
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")=0
virtual ~vpMbEdgeTracker()
unsigned int ncircle
Index of the circle to add, and total number of circles extracted so far.
virtual void cleanPyramid(std::map< std::string, std::vector< const vpImage< unsigned char > * > > &pyramid)
void reInitLevel(const unsigned int _lvl)
Hybrid stereo (or more) tracker based on moving-edges and keypoints tracked using KLT tracker...
Make the complete tracking of an object by using its CAD model.
std::vector< const vpImage< unsigned char > *> Ipyramid
Pyramid of image associated to the current image. This pyramid is computed in the init() and in the t...
void removeCircle(const std::string &name)
virtual void setCameraParameters(const vpCameraParameters &camera)
void displayFeaturesOnImage(const vpImage< unsigned char > &I, const unsigned int lvl)
void removeCylinder(const std::string &name)
vpMe me
The moving edges parameters.
void updateMovingEdge(const vpImage< unsigned char > &I)
virtual void resetTracker()=0
std::vector< std::list< vpMbtDistanceLine * > > lines
Vector of list of all the lines tracked (each line is linked to a list of moving edges). Each element of the vector is for a scale (element 0 = level 0 = no subsampling).
void setGoodMovingEdgesRatioThreshold(const double threshold)
void downScale(const unsigned int _scale)
void computeVVSSecondPhasePoseEstimation(const unsigned int nerror, vpMatrix &L, vpMatrix &L_true, vpMatrix &LVJ_true, vpColVector &W_true, const vpColVector &factor, const unsigned int iter, const bool isoJoIdentity_, vpColVector &weighted_error, double &mu, vpColVector &m_error_prev, vpColVector &m_w_prev, vpHomogeneousMatrix &cMoPrev, double &residu_1, double &r)
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
virtual void init(const vpImage< unsigned char > &I)=0
virtual void setOgreVisibilityTest(const bool &v)
vpAROgre * getOgreContext()
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)=0
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
virtual void setScanLineVisibilityTest(const bool &v)
Implementation of a polygon of the model used by the model-based tracker.
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
virtual void getMovingEdge(vpMe &p_me) const
void computeVVSSecondPhaseCheckLevenbergMarquardt(const unsigned int iter, const unsigned int nbrow, const vpColVector &m_error_prev, const vpColVector &m_w_prev, const vpHomogeneousMatrix &cMoPrev, double &mu, bool &reStartFromLastIncrement)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
unsigned int nbFeaturesForProjErrorComputation
Number of features used in the computation of the projection error.
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
Generic class defining intrinsic camera parameters.
double getGoodMovingEdgesRatioThreshold() const
Main methods for a model-based tracker.
double percentageGdPt
Percentage of good points over total number of points below which tracking is supposed to have failed...
void getLcylinder(std::list< vpMbtDistanceCylinder *> &cylindersList, const unsigned int level=0) const
virtual double getLambda() const
void getLcircle(std::list< vpMbtDistanceCircle *> &circlesList, const unsigned int level=0) const
virtual unsigned int initMbtTracking(std::vector< FeatureType > &indexOfFeatures, std::map< std::string, unsigned int > &mapOfNumberOfRows, std::map< std::string, unsigned int > &mapOfNumberOfLines, std::map< std::string, unsigned int > &mapOfNumberOfCylinders, std::map< std::string, unsigned int > &mapOfNumberOfCircles)
virtual void loadConfigFile(const std::string &configFile)=0
void computeVVSFirstPhase(const vpImage< unsigned char > &I, const unsigned int iter, vpMatrix &L, vpColVector &factor, double &count, vpColVector &error, vpColVector &w_mbt, const unsigned int lvl=0)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
bool samePoint(const vpPoint &P1, const vpPoint &P2) const
virtual unsigned int getNbPoints(const unsigned int level=0) const
void addCylinder(const vpPoint &P1, const vpPoint &P2, const double r, int idFace=-1, const std::string &name="")
virtual void setMovingEdge(const vpMe &me)
virtual void setScales(const std::vector< bool > &scales)
virtual void setOgreVisibilityTest(const bool &v)
Implementation of column vector and the associated operations.
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void testTracking()=0
Contains an M-Estimator and various influence function.
void updateMovingEdgeWeights()
unsigned int nbvisiblepolygone
Number of polygon (face) currently visible.
virtual vpMe getMovingEdge() const
void visibleFace(const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setClipping(const unsigned int &flags)
void addPolygon(const std::vector< vpPoint > &corners, const int idFace=-1, const std::string &polygonName="", const bool useLod=false, const double minPolygonAreaThreshold=2500.0, const double minLineLengthThreshold=50.0)
unsigned int nline
Index of the polygon to add, and total number of polygon extracted so far.
void trackMovingEdge(const vpImage< unsigned char > &I)
void computeVVSFirstPhaseFactor(const vpImage< unsigned char > &I, vpColVector &factor, const unsigned int lvl=0)
virtual void setFarClippingDistance(const double &dist)
void removeLine(const std::string &name)
Make the complete stereo (or more) tracking of an object by using its CAD model.
std::vector< bool > getScales() const
void computeVVSSecondPhase(const vpImage< unsigned char > &I, vpMatrix &L, vpColVector &error_lines, vpColVector &error_cylinders, vpColVector &error_circles, vpColVector &error, const unsigned int lvl)
virtual void computeVVSSecondPhaseWeights(const unsigned int iter, const unsigned int nerror, vpColVector &weighted_error, vpColVector &w_lines, vpColVector &w_cylinders, vpColVector &w_circles, std::map< std::string, unsigned int > &mapOfNumberOfLines, std::map< std::string, unsigned int > &mapOfNumberOfCylinders, std::map< std::string, unsigned int > &mapOfNumberOfCircles, std::map< std::string, vpColVector > &mapOfWeightLines, std::map< std::string, vpColVector > &mapOfWeightCylinders, std::map< std::string, vpColVector > &mapOfWeightCircles, std::map< std::string, vpColVector > &mapOfErrorLines, std::map< std::string, vpColVector > &mapOfErrorCylinders, std::map< std::string, vpColVector > &mapOfErrorCircles, std::map< std::string, vpRobust > &mapOfRobustLines, std::map< std::string, vpRobust > &mapOfRobustCylinders, std::map< std::string, vpRobust > &mapOfRobustCircles, double threshold)
virtual void initPyramid(const std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, std::map< std::string, std::vector< const vpImage< unsigned char > * > > &pyramid)
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, std::map< std::string, unsigned int > &mapOfNumberOfRows, std::map< std::string, unsigned int > &mapOfNbInfos, vpColVector &w_mbt, vpColVector &w_klt, const unsigned int lvl=0)
virtual void setLambda(const double gain)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")=0
virtual void setNearClippingDistance(const double &dist)