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>
62 #if defined(VISP_HAVE_COIN3D)
64 #include <Inventor/nodes/SoSeparator.h>
65 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h>
66 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h>
67 #include <Inventor/VRMLnodes/SoVRMLCoordinate.h>
68 #include <Inventor/actions/SoWriteAction.h>
69 #include <Inventor/actions/SoSearchAction.h>
70 #include <Inventor/misc/SoChildList.h>
71 #include <Inventor/actions/SoGetMatrixAction.h>
72 #include <Inventor/actions/SoGetPrimitiveCountAction.h>
73 #include <Inventor/actions/SoToVRML2Action.h>
74 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
75 #include <Inventor/VRMLnodes/SoVRMLShape.h>
78 #ifdef VISP_HAVE_OPENCV
79 # if VISP_HAVE_OPENCV_VERSION >= 0x020101
80 # include <opencv2/core/core.hpp>
81 # include <opencv2/imgproc/imgproc.hpp>
82 # include <opencv2/imgproc/imgproc_c.h>
275 std::vector< std::list< vpMbtDistanceLine*> >
lines;
278 std::vector< std::list< vpMbtDistanceCircle*> >
circles;
281 std::vector< std::list< vpMbtDistanceCylinder*> >
cylinders;
302 std::vector< const vpImage<unsigned char>* >
Ipyramid;
313 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false);
315 const vpColor& col ,
const unsigned int thickness=1,
const bool displayFullModel =
false);
322 virtual inline double getLambda()
const {
return lambda;}
324 void getLline(std::list<vpMbtDistanceLine *>& linesList,
const unsigned int level = 0);
325 void getLcircle(std::list<vpMbtDistanceCircle *>& circlesList,
const unsigned int level = 0);
326 void getLcylinder(std::list<vpMbtDistanceCylinder *>& cylindersList,
const unsigned int level = 0);
341 unsigned int getNbPoints(
const unsigned int level=0)
const;
362 const bool verbose=
false);
364 const bool verbose=
false);
375 for (
unsigned int i = 0; i < scales.size(); i += 1){
377 for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[i].begin(); it!=lines[i].end(); ++it){
378 (*it)->setCameraParameters(cam);
381 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[i].begin(); it!=cylinders[i].end(); ++it){
382 (*it)->setCameraParameters(cam);
385 for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles[i].begin(); it!=circles[i].end(); ++it){
386 (*it)->setCameraParameters(cam);
392 virtual void setClipping(
const unsigned int &flags);
407 #ifdef VISP_HAVE_OGRE
408 faces.getOgreContext()->setWindowName(
"MBT Edge");
420 for (
unsigned int i = 0; i < scales.size(); i += 1){
422 for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[i].begin(); it!=lines[i].end(); ++it){
423 (*it)->useScanLine = v;
448 virtual inline void setLambda(
const double gain) {this->lambda = gain;}
450 void setMovingEdge(
const vpMe &me);
454 void setScales(
const std::vector<bool>& _scales);
456 void setUseEdgeTracking(
const std::string &name,
const bool &useEdgeTracking);
462 void addCircle(
const vpPoint &P1,
const vpPoint &P2,
const vpPoint &P3,
const double r,
int idFace = -1,
const std::string& name =
"");
463 void addCylinder(
const vpPoint &P1,
const vpPoint &P2,
const double r,
int idFace = -1,
const std::string& name =
"");
464 void addLine(
vpPoint &p1,
vpPoint &p2,
int polygon = -1, std::string name =
"");
469 void downScale(
const unsigned int _scale);
472 const int idFace=0,
const std::string &name=
"");
474 const std::string &name=
"");
479 void reInitLevel(
const unsigned int _lvl);
481 void removeCircle(
const std::string& name);
482 void removeCylinder(
const std::string& name);
483 void removeLine(
const std::string& name);
484 void resetMovingEdge();
488 void upScale(
const unsigned int _scale);
std::vector< bool > getScales() const
unsigned int ncylinder
Index of the cylinder to add, and total number of cylinders extracted so far.
virtual void track(const vpImage< unsigned char > &I)=0
Implementation of an homogeneous matrix and operations on such kind of matrices.
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.
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")=0
unsigned int ncircle
Index of the circle to add, and total number of circles extracted so far.
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...
virtual void setCameraParameters(const vpCameraParameters &camera)
vpMe me
The moving edges parameters.
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)
Class that defines what is a point.
virtual void init(const vpImage< unsigned char > &I)=0
virtual void setOgreVisibilityTest(const bool &v)
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 getMovingEdge(vpMe &p_me) const
vpMe getMovingEdge() const
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
Generic class defining intrinsic camera parameters.
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...
virtual void loadConfigFile(const std::string &configFile)=0
virtual double getLambda() const
virtual void setOgreVisibilityTest(const bool &v)
double getGoodMovingEdgesRatioThreshold() const
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void testTracking()=0
unsigned int nbvisiblepolygone
Number of polygon (face) currently visible.
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.
virtual void setFarClippingDistance(const double &dist)
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)