Visual Servoing Platform  version 3.4.0
vpMbGenericTracker.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Generic model-based tracker.
33  *
34  *****************************************************************************/
40 #ifndef _vpMbGenericTracker_h_
41 #define _vpMbGenericTracker_h_
42 
43 #include <visp3/mbt/vpMbDepthDenseTracker.h>
44 #include <visp3/mbt/vpMbDepthNormalTracker.h>
45 #include <visp3/mbt/vpMbEdgeTracker.h>
46 #include <visp3/mbt/vpMbKltTracker.h>
47 
80 class VISP_EXPORT vpMbGenericTracker : public vpMbTracker
81 {
82 public:
84  EDGE_TRACKER = 1 << 0,
85 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
86  KLT_TRACKER = 1 << 1,
87 #endif
88  DEPTH_NORMAL_TRACKER = 1 << 2,
89  DEPTH_DENSE_TRACKER = 1 << 3
90  };
91 
93  vpMbGenericTracker(unsigned int nbCameras, int trackerType = EDGE_TRACKER);
94  explicit vpMbGenericTracker(const std::vector<int> &trackerTypes);
95  vpMbGenericTracker(const std::vector<std::string> &cameraNames, const std::vector<int> &trackerTypes);
96 
97  virtual ~vpMbGenericTracker();
98 
100  const vpCameraParameters &_cam);
101  virtual double computeCurrentProjectionError(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &_cMo,
102  const vpCameraParameters &_cam);
103 
104  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
105  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
106  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
107  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
108 
109  virtual void display(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
110  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1,
111  const vpCameraParameters &cam2, const vpColor &color, unsigned int thickness = 1,
112  bool displayFullModel = false);
113  virtual void display(const vpImage<vpRGBa> &I1, const vpImage<vpRGBa> &I2, const vpHomogeneousMatrix &c1Mo,
114  const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1, const vpCameraParameters &cam2,
115  const vpColor &color, unsigned int thickness = 1, bool displayFullModel = false);
116 
117  virtual void display(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
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);
121  virtual void display(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
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);
125 
126  virtual std::vector<std::string> getCameraNames() const;
127 
129  virtual void getCameraParameters(vpCameraParameters &camera) const;
130  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
131  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
132 
133  virtual std::map<std::string, int> getCameraTrackerTypes() const;
134 
136  virtual void getClipping(unsigned int &clippingFlag1, unsigned int &clippingFlag2) const;
137  virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags) const;
138 
139  virtual inline vpColVector getError() const { return m_error; }
140 
142  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces(const std::string &cameraName);
143 
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();
148 #endif
149 
150  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
151  virtual void getFeaturesForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfFeatures);
152 
153  virtual double getGoodMovingEdgesRatioThreshold() const;
154 
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;
158 
159  virtual unsigned int getKltMaskBorder() const;
160  virtual int getKltNbPoints() const;
161 
162  virtual vpKltOpencv getKltOpencv() const;
163  virtual void getKltOpencv(vpKltOpencv &klt1, vpKltOpencv &klt2) const;
164  virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts) const;
165 
166 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
167  virtual std::vector<cv::Point2f> getKltPoints() const;
168 #endif
169 
170  virtual double getKltThresholdAcceptation() const;
171 #endif
172 
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;
182 
183  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
184  const vpHomogeneousMatrix &cMo,
185  const vpCameraParameters &cam,
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);
193 
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;
197 
201  virtual inline unsigned int getNbFeaturesDepthDense() const { return m_nb_feat_depthDense; }
205  virtual inline unsigned int getNbFeaturesDepthNormal() const { return m_nb_feat_depthNormal; }
211  virtual inline unsigned int getNbFeaturesEdge() const { return m_nb_feat_edge; }
215  virtual inline unsigned int getNbFeaturesKlt() const { return m_nb_feat_klt; }
216 
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;
219 
220  virtual unsigned int getNbPolygon() const;
221  virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons) const;
222 
223  virtual vpMbtPolygon *getPolygon(unsigned int index);
224  virtual vpMbtPolygon *getPolygon(const std::string &cameraName, unsigned int index);
225 
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);
232 
233  using vpMbTracker::getPose;
234  virtual void getPose(vpHomogeneousMatrix &cMo) const;
235  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
236  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
237 
238  virtual std::string getReferenceCameraName() const;
239 
240  virtual inline vpColVector getRobustWeights() const { return m_w; }
241 
242  virtual int getTrackerType() const;
243 
244  virtual void init(const vpImage<unsigned char> &I);
245 
246 #ifdef VISP_HAVE_MODULE_GUI
248  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
249  const std::string &initFile1, const std::string &initFile2, bool displayHelp = false,
251  virtual void initClick(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
252  const std::string &initFile1, const std::string &initFile2, bool displayHelp = false,
254 
255  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
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>());
258  virtual void initClick(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
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>());
261 #endif
262 
264  virtual void initFromPoints(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
265  const std::string &initFile1, const std::string &initFile2);
266  virtual void initFromPoints(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
267  const std::string &initFile1, const std::string &initFile2);
268 
269  virtual void initFromPoints(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
270  const std::map<std::string, std::string> &mapOfInitPoints);
271  virtual void initFromPoints(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
272  const std::map<std::string, std::string> &mapOfInitPoints);
273 
275  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
276  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
277  const std::string &initFile1, const std::string &initFile2);
278  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
279  const std::string &initFile1, const std::string &initFile2);
280 
281  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
282  const std::map<std::string, std::string> &mapOfInitPoses);
283  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
284  const std::map<std::string, std::string> &mapOfInitPoses);
285 
286  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
287  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
288  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
289  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
290 
291  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
292  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
293  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
294  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
295 
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);
299 
300  virtual void loadModel(const std::string &modelFile, bool verbose = false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix());
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>());
305 
306  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
307  const vpHomogeneousMatrix &cMo, bool verbose = false,
309  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
310  const vpHomogeneousMatrix &cMo, bool verbose = false,
312 
313  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
314  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
315  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
317  virtual void reInitModel(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
318  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
319  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
321 
322  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
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>());
332 
333  virtual void resetTracker();
334 
335  virtual void setAngleAppear(const double &a);
336  virtual void setAngleAppear(const double &a1, const double &a2);
337  virtual void setAngleAppear(const std::map<std::string, double> &mapOfAngles);
338 
339  virtual void setAngleDisappear(const double &a);
340  virtual void setAngleDisappear(const double &a1, const double &a2);
341  virtual void setAngleDisappear(const std::map<std::string, double> &mapOfAngles);
342 
343  virtual void setCameraParameters(const vpCameraParameters &camera);
344  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2);
345  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
346 
347  virtual void setCameraTransformationMatrix(const std::string &cameraName,
348  const vpHomogeneousMatrix &cameraTransformationMatrix);
349  virtual void
350  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
351 
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);
355 
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);
361 
362  virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method);
363  virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method);
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);
368 
369  virtual void setDisplayFeatures(bool displayF);
370 
371  virtual void setFarClippingDistance(const double &dist);
372  virtual void setFarClippingDistance(const double &dist1, const double &dist2);
373  virtual void setFarClippingDistance(const std::map<std::string, double> &mapOfClippingDists);
374 
375  virtual void setFeatureFactors(const std::map<vpTrackerType, double> &mapOfFeatureFactors);
376 
377  virtual void setGoodMovingEdgesRatioThreshold(double threshold);
378 
379 #ifdef VISP_HAVE_OGRE
380  virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio);
381  virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
382 #endif
383 
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);
388 
389  virtual void setKltOpencv(const vpKltOpencv &t);
390  virtual void setKltOpencv(const vpKltOpencv &t1, const vpKltOpencv &t2);
391  virtual void setKltOpencv(const std::map<std::string, vpKltOpencv> &mapOfKlts);
392 
393  virtual void setKltThresholdAcceptation(double th);
394 
395 #endif
396 
397  virtual void setLod(bool useLod, const std::string &name = "");
398 
399  virtual void setMask(const vpImage<bool> &mask);
400 
401  virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name = "");
402  virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name = "");
403 
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);
407 
408  virtual void setNearClippingDistance(const double &dist);
409  virtual void setNearClippingDistance(const double &dist1, const double &dist2);
410  virtual void setNearClippingDistance(const std::map<std::string, double> &mapOfDists);
411 
412  virtual void setOgreShowConfigDialog(bool showConfigDialog);
413  virtual void setOgreVisibilityTest(const bool &v);
414 
415  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
416 
417  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
418  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
419 
420  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
421  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
422  virtual void setPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
423  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
424 
425  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
426  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
427  virtual void setPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
428  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
429 
430  virtual void setProjectionErrorComputation(const bool &flag);
431 
432  virtual void setProjectionErrorDisplay(bool display);
433  virtual void setProjectionErrorDisplayArrowLength(unsigned int length);
434  virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness);
435 
436  virtual void setReferenceCameraName(const std::string &referenceCameraName);
437 
438  virtual void setScanLineVisibilityTest(const bool &v);
439 
440  virtual void setTrackerType(int type);
441  virtual void setTrackerType(const std::map<std::string, int> &mapOfTrackerTypes);
442 
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);
448 #endif
449 
450  virtual void testTracking();
451 
452  virtual void track(const vpImage<unsigned char> &I);
453  virtual void track(const vpImage<vpRGBa> &I_color);
454 
455  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
456  virtual void track(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2);
457 
458  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
459  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages);
460 
461 #ifdef VISP_HAVE_PCL
462  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
463  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
464  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
465  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
466 #endif
467 
468  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
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);
472  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
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);
476 
477 protected:
478  virtual void computeProjectionError();
479 
480  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
481 
482  virtual void computeVVSInit();
483  virtual void computeVVSInit(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
485  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
486  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
488  virtual void computeVVSWeights();
489 
490  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius,
491  int idFace = 0, const std::string &name = "");
492 
493  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
494  const std::string &name = "");
495 
496  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
497 
498  virtual void initFaceFromLines(vpMbtPolygon &polygon);
499 
500 #ifdef VISP_HAVE_PCL
501  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
502  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
503 #endif
504  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
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);
508 
509 private:
510  class TrackerWrapper : public vpMbEdgeTracker,
511 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
512  public vpMbKltTracker,
513 #endif
514  public vpMbDepthNormalTracker,
515  public vpMbDepthDenseTracker
516  {
517  friend class vpMbGenericTracker;
518 
519  public:
523  vpMatrix m_L;
525  int m_trackerType;
530 
531  TrackerWrapper();
532  explicit TrackerWrapper(int trackerType);
533 
534  virtual ~TrackerWrapper();
535 
536  virtual inline vpColVector getError() const { return m_error; }
537 
538  virtual inline vpColVector getRobustWeights() const { return m_w; }
539 
540  virtual inline int getTrackerType() const { return m_trackerType; }
541 
542  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
543  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
544  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
545  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
546 
547  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
548 
549  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
550  const vpHomogeneousMatrix &cMo,
551  const vpCameraParameters &cam,
552  bool displayFullModel=false);
553 
554  virtual void init(const vpImage<unsigned char> &I);
555 
556  virtual void loadConfigFile(const std::string &configFile, bool verbose=true);
557 
558  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
559  const vpHomogeneousMatrix &cMo, bool verbose = false,
561  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
562  const vpHomogeneousMatrix &cMo, bool verbose = false,
564 
565  virtual void resetTracker();
566 
567  virtual void setCameraParameters(const vpCameraParameters &camera);
568 
569  virtual void setClipping(const unsigned int &flags);
570 
571  virtual void setFarClippingDistance(const double &dist);
572 
573  virtual void setNearClippingDistance(const double &dist);
574 
575  virtual void setOgreVisibilityTest(const bool &v);
576 
577  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
578  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
579 
580  virtual void setProjectionErrorComputation(const bool &flag);
581 
582  virtual void setScanLineVisibilityTest(const bool &v);
583 
584  virtual void setTrackerType(int type);
585 
586  virtual void testTracking();
587 
588  virtual void track(const vpImage<unsigned char> &I);
589  virtual void track(const vpImage<vpRGBa> &I_color);
590 #ifdef VISP_HAVE_PCL
591  // Fix error: using declaration ‘using vpMbDepthDenseTracker::setPose’ conflicts with a previous
592  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
593 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
595 #endif
598  virtual void track(const vpImage<unsigned char> *const ptr_I,
599  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
600 #endif
601 
602  protected:
603  virtual void computeVVS(const vpImage<unsigned char> *const ptr_I);
604  virtual void computeVVSInit();
605  virtual void computeVVSInit(const vpImage<unsigned char> *const ptr_I);
608  virtual void computeVVSInteractionMatrixAndResidu(const vpImage<unsigned char> *const ptr_I);
610  virtual void computeVVSWeights();
611 
612  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius,
613  int idFace = 0, const std::string &name = "");
614 
615  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
616  const std::string &name = "");
617 
618  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
619  virtual void initFaceFromLines(vpMbtPolygon &polygon);
620 
621  virtual void initMbtTracking(const vpImage<unsigned char> *const ptr_I);
622 
623 #ifdef VISP_HAVE_PCL
624  virtual void postTracking(const vpImage<unsigned char> *const ptr_I,
625  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
626  virtual void preTracking(const vpImage<unsigned char> *const ptr_I,
627  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
628 #endif
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);
631  virtual void preTracking(const vpImage<unsigned char> *const ptr_I = NULL,
632  const std::vector<vpColVector> *const point_cloud = NULL,
633  const unsigned int pointcloud_width = 0, const unsigned int pointcloud_height = 0);
634 
635  virtual void reInitModel(const vpImage<unsigned char> * const I, const vpImage<vpRGBa> * const I_color,
636  const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose = false,
638 
639 #ifdef VISP_HAVE_PCL
640  // Fix error: using declaration ‘using vpMbDepthDenseTracker::track’ conflicts with a previous
641  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
642 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
644 #endif
646 #endif
647  virtual void setPose(const vpImage<unsigned char> * const I, const vpImage<vpRGBa> * const I_color,
648  const vpHomogeneousMatrix &cdMo);
649  };
650 
651 protected:
658  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
660  std::map<vpTrackerType, double> m_mapOfFeatureFactors;
663  std::map<std::string, TrackerWrapper *> m_mapOfTrackers;
676 
678  unsigned int m_nb_feat_edge;
680  unsigned int m_nb_feat_klt;
682  unsigned int m_nb_feat_depthNormal;
684  unsigned int m_nb_feat_depthDense;
685 
686 };
687 #endif
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.
Definition: vpMatrix.h:153
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
Definition: vpMbTracker.h:256
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:480
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 track(const vpImage< unsigned char > &)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Definition: vpMbTracker.h:557
virtual vpMbtPolygon * getPolygon(unsigned int index)
Definition: vpMbTracker.h:395
Class to define RGB colors available for display functionnalities.
Definition: vpColor.h:157
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)
Definition: vpMbTracker.h:643
virtual void computeVVSInit()
Definition: vpMe.h:60
virtual void setMask(const vpImage< bool > &mask)
Definition: vpMbTracker.h:563
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)
Definition: vpMbTracker.h:594
virtual vpColVector getRobustWeights() const
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:81
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)
Definition: vpMbTracker.h:617
vpColVector m_weightedError
Weighted error.
virtual void setCameraParameters(const vpCameraParameters &cam)
Definition: vpMbTracker.h:487
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:66
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
Definition: vpMbTracker.h:423
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.
Definition: vpMbTracker.h:104
virtual void computeVVSInteractionMatrixAndResidu()
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setAngleAppear(const double &a)
Definition: vpMbTracker.h:469
Model based tracker using only KLT.
virtual std::vector< std::vector< double > > getFeaturesForDisplay()
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:627
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
virtual void computeVVSWeights()
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
unsigned int m_nb_feat_depthDense
Number of depth dense features.
virtual void setProjectionErrorDisplay(bool display)
Definition: vpMbTracker.h:589
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void getCameraParameters(vpCameraParameters &cam) const
Definition: vpMbTracker.h:248
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)
Definition: vpMbTracker.h:599
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.
Definition: vpColVector.h:130
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 ...
Definition: vpKltOpencv.h:78
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual unsigned int getNbPolygon() const
Definition: vpMbTracker.h:368
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:601
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()
Definition: vpMbTracker.h:332
virtual void setDisplayFeatures(bool displayF)
Definition: vpMbTracker.h:517
virtual int getTrackerType() const
unsigned int m_nb_feat_klt
Number of klt features.
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:584
virtual void setNearClippingDistance(const double &dist)