40 #ifndef _vpMbGenericTracker_h_ 41 #define _vpMbGenericTracker_h_ 43 #include <visp3/mbt/vpMbDepthDenseTracker.h> 44 #include <visp3/mbt/vpMbDepthNormalTracker.h> 45 #include <visp3/mbt/vpMbEdgeTracker.h> 46 #include <visp3/mbt/vpMbKltTracker.h> 84 EDGE_TRACKER = 1 << 0,
85 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 88 DEPTH_NORMAL_TRACKER = 1 << 2,
89 DEPTH_DENSE_TRACKER = 1 << 3
95 vpMbGenericTracker(
const std::vector<std::string> &cameraNames,
const std::vector<int> &trackerTypes);
105 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
107 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
112 bool displayFullModel =
false);
115 const vpColor &color,
unsigned int thickness = 1,
bool displayFullModel =
false);
118 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
119 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
120 unsigned int thickness = 1,
bool displayFullModel =
false);
122 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
123 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
124 unsigned int thickness = 1,
bool displayFullModel =
false);
126 virtual std::vector<std::string> getCameraNames()
const;
131 virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters)
const;
133 virtual std::map<std::string, int> getCameraTrackerTypes()
const;
136 virtual void getClipping(
unsigned int &clippingFlag1,
unsigned int &clippingFlag2)
const;
137 virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags)
const;
144 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 145 virtual std::list<vpMbtDistanceCircle *> &getFeaturesCircle();
146 virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder();
147 virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt();
150 virtual std::vector<std::vector<double> > getFeaturesForDisplay();
151 virtual void getFeaturesForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfFeatures);
153 virtual double getGoodMovingEdgesRatioThreshold()
const;
155 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 156 virtual std::vector<vpImagePoint> getKltImagePoints()
const;
157 virtual std::map<int, vpImagePoint> getKltImagePointsWithId()
const;
159 virtual unsigned int getKltMaskBorder()
const;
160 virtual int getKltNbPoints()
const;
164 virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts)
const;
166 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 167 virtual std::vector<cv::Point2f> getKltPoints()
const;
170 virtual double getKltThresholdAcceptation()
const;
173 virtual void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList,
unsigned int level = 0)
const;
174 virtual void getLcircle(
const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
175 unsigned int level = 0)
const;
176 virtual void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList,
unsigned int level = 0)
const;
177 virtual void getLcylinder(
const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
178 unsigned int level = 0)
const;
179 virtual void getLline(std::list<vpMbtDistanceLine *> &linesList,
unsigned int level = 0)
const;
180 virtual void getLline(
const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
181 unsigned int level = 0)
const;
183 virtual std::vector<std::vector<double> >
getModelForDisplay(
unsigned int width,
unsigned int height,
186 bool displayFullModel=
false);
187 virtual void getModelForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfModels,
188 const std::map<std::string, unsigned int> &mapOfwidths,
189 const std::map<std::string, unsigned int> &mapOfheights,
190 const std::map<std::string, vpHomogeneousMatrix> &mapOfcMos,
191 const std::map<std::string, vpCameraParameters> &mapOfCams,
192 bool displayFullModel=
false);
194 virtual vpMe getMovingEdge()
const;
195 virtual void getMovingEdge(
vpMe &me1,
vpMe &me2)
const;
196 virtual void getMovingEdge(std::map<std::string, vpMe> &mapOfMovingEdges)
const;
217 virtual unsigned int getNbPoints(
unsigned int level = 0)
const;
218 virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints,
unsigned int level = 0)
const;
221 virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons)
const;
226 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
227 getPolygonFaces(
bool orderPolygons =
true,
bool useVisibility =
true,
bool clipPolygon =
false);
228 virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
229 std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
230 bool orderPolygons =
true,
bool useVisibility =
true,
231 bool clipPolygon =
false);
236 virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
const;
238 virtual std::string getReferenceCameraName()
const;
242 virtual int getTrackerType()
const;
246 #ifdef VISP_HAVE_MODULE_GUI 249 const std::string &initFile1,
const std::string &initFile2,
bool displayHelp =
false,
252 const std::string &initFile1,
const std::string &initFile2,
bool displayHelp =
false,
256 const std::map<std::string, std::string> &mapOfInitFiles,
bool displayHelp =
false,
257 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
259 const std::map<std::string, std::string> &mapOfInitFiles,
bool displayHelp =
false,
260 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
265 const std::string &initFile1,
const std::string &initFile2);
267 const std::string &initFile1,
const std::string &initFile2);
270 const std::map<std::string, std::string> &mapOfInitPoints);
272 const std::map<std::string, std::string> &mapOfInitPoints);
277 const std::string &initFile1,
const std::string &initFile2);
279 const std::string &initFile1,
const std::string &initFile2);
282 const std::map<std::string, std::string> &mapOfInitPoses);
284 const std::map<std::string, std::string> &mapOfInitPoses);
292 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
294 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
296 virtual void loadConfigFile(
const std::string &configFile,
bool verbose=
true);
297 virtual void loadConfigFile(
const std::string &configFile1,
const std::string &configFile2,
bool verbose=
true);
298 virtual void loadConfigFile(
const std::map<std::string, std::string> &mapOfConfigFiles,
bool verbose=
true);
301 virtual void loadModel(
const std::string &modelFile1,
const std::string &modelFile2,
bool verbose =
false,
303 virtual void loadModel(
const std::map<std::string, std::string> &mapOfModelFiles,
bool verbose =
false,
304 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
309 virtual void reInitModel(
const vpImage<vpRGBa> &I_color,
const std::string &cad_name,
314 const std::string &cad_name1,
const std::string &cad_name2,
const vpHomogeneousMatrix &c1Mo,
318 const std::string &cad_name1,
const std::string &cad_name2,
const vpHomogeneousMatrix &c1Mo,
323 const std::map<std::string, std::string> &mapOfModelFiles,
324 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
325 bool verbose =
false,
326 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
327 virtual void reInitModel(
const std::map<std::string,
const vpImage<vpRGBa> *> &mapOfColorImages,
328 const std::map<std::string, std::string> &mapOfModelFiles,
329 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
330 bool verbose =
false,
331 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
337 virtual void setAngleAppear(
const std::map<std::string, double> &mapOfAngles);
341 virtual void setAngleDisappear(
const std::map<std::string, double> &mapOfAngles);
345 virtual void setCameraParameters(
const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
347 virtual void setCameraTransformationMatrix(
const std::string &cameraName,
350 setCameraTransformationMatrix(
const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
352 virtual void setClipping(
const unsigned int &flags);
353 virtual void setClipping(
const unsigned int &flags1,
const unsigned int &flags2);
354 virtual void setClipping(
const std::map<std::string, unsigned int> &mapOfClippingFlags);
356 virtual void setDepthDenseFilteringMaxDistance(
double maxDistance);
357 virtual void setDepthDenseFilteringMethod(
int method);
358 virtual void setDepthDenseFilteringMinDistance(
double minDistance);
359 virtual void setDepthDenseFilteringOccupancyRatio(
double occupancyRatio);
360 virtual void setDepthDenseSamplingStep(
unsigned int stepX,
unsigned int stepY);
364 virtual void setDepthNormalPclPlaneEstimationMethod(
int method);
365 virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(
int maxIter);
366 virtual void setDepthNormalPclPlaneEstimationRansacThreshold(
double threshold);
367 virtual void setDepthNormalSamplingStep(
unsigned int stepX,
unsigned int stepY);
375 virtual void setFeatureFactors(
const std::map<vpTrackerType, double> &mapOfFeatureFactors);
377 virtual void setGoodMovingEdgesRatioThreshold(
double threshold);
379 #ifdef VISP_HAVE_OGRE 384 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 385 virtual void setKltMaskBorder(
const unsigned int &e);
386 virtual void setKltMaskBorder(
const unsigned int &e1,
const unsigned int &e2);
387 virtual void setKltMaskBorder(
const std::map<std::string, unsigned int> &mapOfErosions);
391 virtual void setKltOpencv(
const std::map<std::string, vpKltOpencv> &mapOfKlts);
393 virtual void setKltThresholdAcceptation(
double th);
397 virtual void setLod(
bool useLod,
const std::string &name =
"");
404 virtual void setMovingEdge(
const vpMe &me);
405 virtual void setMovingEdge(
const vpMe &me1,
const vpMe &me2);
406 virtual void setMovingEdge(
const std::map<std::string, vpMe> &mapOfMe);
426 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
428 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
436 virtual void setReferenceCameraName(
const std::string &referenceCameraName);
440 virtual void setTrackerType(
int type);
441 virtual void setTrackerType(
const std::map<std::string, int> &mapOfTrackerTypes);
443 virtual void setUseDepthDenseTracking(
const std::string &name,
const bool &useDepthDenseTracking);
444 virtual void setUseDepthNormalTracking(
const std::string &name,
const bool &useDepthNormalTracking);
445 virtual void setUseEdgeTracking(
const std::string &name,
const bool &useEdgeTracking);
446 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 447 virtual void setUseKltTracking(
const std::string &name,
const bool &useKltTracking);
463 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
465 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
469 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
470 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
471 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
473 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
474 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
475 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
478 virtual void computeProjectionError();
486 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
491 int idFace = 0,
const std::string &name =
"");
494 const std::string &name =
"");
502 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
505 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
506 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
507 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
511 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 532 explicit TrackerWrapper(
int trackerType);
534 virtual ~TrackerWrapper();
540 virtual inline int getTrackerType()
const {
return m_trackerType; }
543 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
545 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
549 virtual std::vector<std::vector<double> >
getModelForDisplay(
unsigned int width,
unsigned int height,
552 bool displayFullModel=
false);
556 virtual void loadConfigFile(
const std::string &configFile,
bool verbose=
true);
569 virtual void setClipping(
const unsigned int &flags);
593 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6)) 599 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
613 int idFace = 0,
const std::string &name =
"");
616 const std::string &name =
"");
625 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
627 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
629 virtual void postTracking(
const vpImage<unsigned char> *
const ptr_I = NULL,
const unsigned int pointcloud_width = 0,
630 const unsigned int pointcloud_height = 0);
632 const std::vector<vpColVector> *
const point_cloud = NULL,
633 const unsigned int pointcloud_width = 0,
const unsigned int pointcloud_height = 0);
642 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6)) virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(bool orderPolygons=true, bool useVisibility=true, bool clipPolygon=false)
Implementation of a matrix and operations on matrices.
virtual void track(const vpImage< unsigned char > &I)
virtual void track(const vpImage< unsigned char > &I)=0
virtual void computeVVSInteractionMatrixAndResidu()=0
virtual void computeVVSInit()=0
unsigned int m_nb_feat_edge
Number of moving-edges features.
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
vpColVector m_w
Robust weights.
virtual unsigned int getNbFeaturesDepthDense() const
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual unsigned int getClipping() const
virtual void setAngleDisappear(const double &a)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void setTrackerType(int type)
virtual void track(const vpImage< unsigned char > &I)
virtual void resetTracker()
virtual void track(const vpImage< unsigned char > &)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual vpMbtPolygon * getPolygon(unsigned int index)
Class to define RGB colors available for display functionnalities.
virtual void setClipping(const unsigned int &flags)
virtual void track(const vpImage< unsigned char > &)
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")=0
virtual void setOgreShowConfigDialog(bool showConfigDialog)
virtual void computeVVSInit()
virtual void setMask(const vpImage< bool > &mask)
Make the complete tracking of an object by using its CAD model.
virtual unsigned int getNbFeaturesDepthNormal() const
virtual void computeVVSInteractionMatrixAndResidu()
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
Real-time 6D object pose tracking using its CAD model.
std::map< vpTrackerType, double > m_mapOfFeatureFactors
Ponderation between each feature type in the VVS stage.
virtual void resetTracker()=0
std::map< std::string, TrackerWrapper * > m_mapOfTrackers
virtual void setLod(bool useLod, const std::string &name="")
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)=0
virtual void setProjectionErrorDisplayArrowLength(unsigned int length)
virtual vpColVector getRobustWeights() const
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
virtual void init(const vpImage< unsigned char > &I)=0
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
vpMatrix m_L
Interaction matrix.
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
vpColVector m_weightedError
Weighted error.
virtual void setCameraParameters(const vpCameraParameters &cam)
Implementation of a polygon of the model used by the model-based tracker.
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
virtual void setProjectionErrorComputation(const bool &flag)
virtual vpHomogeneousMatrix getPose() const
virtual void loadConfigFile(const std::string &configFile, bool verbose=true)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
virtual void computeVVSInteractionMatrixAndResidu()
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setAngleAppear(const double &a)
Model based tracker using only KLT.
virtual std::vector< std::vector< double > > getFeaturesForDisplay()
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
virtual void computeVVSWeights()
virtual void testTracking()
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
unsigned int m_nb_feat_depthDense
Number of depth dense features.
virtual void setProjectionErrorDisplay(bool display)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void getCameraParameters(vpCameraParameters &cam) const
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)=0
virtual void setNearClippingDistance(const double &dist)
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void preTracking(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setOgreVisibilityTest(const bool &v)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")
virtual double computeCurrentProjectionError(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam)
vpColVector m_error
(s - s*)
virtual void init(const vpImage< unsigned char > &I)
Implementation of column vector and the associated operations.
virtual void setOgreVisibilityTest(const bool &v)
std::string m_referenceCameraName
Name of the reference camera.
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")=0
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void setFarClippingDistance(const double &dist)
virtual void testTracking()=0
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual unsigned int getNbPolygon() const
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)
virtual vpColVector getError() const
unsigned int m_nb_feat_depthNormal
Number of depth normal features.
virtual void loadConfigFile(const std::string &configFile, bool verbose=true)
virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
virtual unsigned int getNbFeaturesEdge() const
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages)
virtual unsigned int getNbFeaturesKlt() const
virtual void setFarClippingDistance(const double &dist)
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual void setDisplayFeatures(bool displayF)
virtual int getTrackerType() const
double m_thresholdOutlier
unsigned int m_nb_feat_klt
Number of klt features.
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setNearClippingDistance(const double &dist)