Visual Servoing Platform  version 3.5.1 under development (2022-12-04)
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, bool clipPolygon = false);
231 
232  using vpMbTracker::getPose;
233  virtual void getPose(vpHomogeneousMatrix &cMo) const;
234  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
235  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
236 
237  virtual std::string getReferenceCameraName() const;
238 
239  virtual inline vpColVector getRobustWeights() const { return m_w; }
240 
241  virtual int getTrackerType() const;
242 
243  virtual void init(const vpImage<unsigned char> &I);
244 
245 #ifdef VISP_HAVE_MODULE_GUI
247  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
248  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, const std::string &initFile1,
252  const std::string &initFile2, bool displayHelp = false,
255 
256  virtual void
257  initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
258  const std::map<std::string, std::string> &mapOfInitFiles, bool displayHelp = false,
259  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
260  virtual void
261  initClick(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
262  const std::map<std::string, std::string> &mapOfInitFiles, bool displayHelp = false,
263  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
264 #endif
265 
267  virtual void initFromPoints(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
268  const std::string &initFile1, const std::string &initFile2);
269  virtual void initFromPoints(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
270  const std::string &initFile1, const std::string &initFile2);
271 
272  virtual void initFromPoints(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
273  const std::map<std::string, std::string> &mapOfInitPoints);
274  virtual void initFromPoints(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
275  const std::map<std::string, std::string> &mapOfInitPoints);
276 
278  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
279  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
280  const std::string &initFile1, const std::string &initFile2);
281  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
282  const std::string &initFile1, const std::string &initFile2);
283 
284  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
285  const std::map<std::string, std::string> &mapOfInitPoses);
286  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
287  const std::map<std::string, std::string> &mapOfInitPoses);
288 
289  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
290  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
291  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
292  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
293 
294  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
295  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
296  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
297  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
298 
299  virtual void loadConfigFile(const std::string &configFile, bool verbose = true);
300  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2, bool verbose = true);
301  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles, bool verbose = true);
302 
303  virtual void loadModel(const std::string &modelFile, bool verbose = false,
305  virtual void loadModel(const std::string &modelFile1, const std::string &modelFile2, bool verbose = false,
308  virtual void
309  loadModel(const std::map<std::string, std::string> &mapOfModelFiles, bool verbose = false,
310  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
311 
312  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo,
313  bool verbose = false, const vpHomogeneousMatrix &T = vpHomogeneousMatrix());
314  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name, const vpHomogeneousMatrix &cMo,
315  bool verbose = false, const vpHomogeneousMatrix &T = vpHomogeneousMatrix());
316 
317  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
318  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
319  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
322  virtual void reInitModel(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
323  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
324  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
327 
328  virtual void
329  reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
330  const std::map<std::string, std::string> &mapOfModelFiles,
331  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses, bool verbose = false,
332  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
333  virtual void
334  reInitModel(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
335  const std::map<std::string, std::string> &mapOfModelFiles,
336  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses, bool verbose = false,
337  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
338 
339  virtual void resetTracker();
340 
341  virtual void setAngleAppear(const double &a);
342  virtual void setAngleAppear(const double &a1, const double &a2);
343  virtual void setAngleAppear(const std::map<std::string, double> &mapOfAngles);
344 
345  virtual void setAngleDisappear(const double &a);
346  virtual void setAngleDisappear(const double &a1, const double &a2);
347  virtual void setAngleDisappear(const std::map<std::string, double> &mapOfAngles);
348 
349  virtual void setCameraParameters(const vpCameraParameters &camera);
350  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2);
351  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
352 
353  virtual void setCameraTransformationMatrix(const std::string &cameraName,
354  const vpHomogeneousMatrix &cameraTransformationMatrix);
355  virtual void
356  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
357 
358  virtual void setClipping(const unsigned int &flags);
359  virtual void setClipping(const unsigned int &flags1, const unsigned int &flags2);
360  virtual void setClipping(const std::map<std::string, unsigned int> &mapOfClippingFlags);
361 
362  virtual void setDepthDenseFilteringMaxDistance(double maxDistance);
363  virtual void setDepthDenseFilteringMethod(int method);
364  virtual void setDepthDenseFilteringMinDistance(double minDistance);
365  virtual void setDepthDenseFilteringOccupancyRatio(double occupancyRatio);
366  virtual void setDepthDenseSamplingStep(unsigned int stepX, unsigned int stepY);
367 
368  virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method);
369  virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method);
370  virtual void setDepthNormalPclPlaneEstimationMethod(int method);
371  virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter);
372  virtual void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold);
373  virtual void setDepthNormalSamplingStep(unsigned int stepX, unsigned int stepY);
374 
375  virtual void setDisplayFeatures(bool displayF);
376 
377  virtual void setFarClippingDistance(const double &dist);
378  virtual void setFarClippingDistance(const double &dist1, const double &dist2);
379  virtual void setFarClippingDistance(const std::map<std::string, double> &mapOfClippingDists);
380 
381  virtual void setFeatureFactors(const std::map<vpTrackerType, double> &mapOfFeatureFactors);
382 
383  virtual void setGoodMovingEdgesRatioThreshold(double threshold);
384 
385 #ifdef VISP_HAVE_OGRE
386  virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio);
387  virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
388 #endif
389 
390 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
391  virtual void setKltMaskBorder(const unsigned int &e);
392  virtual void setKltMaskBorder(const unsigned int &e1, const unsigned int &e2);
393  virtual void setKltMaskBorder(const std::map<std::string, unsigned int> &mapOfErosions);
394 
395  virtual void setKltOpencv(const vpKltOpencv &t);
396  virtual void setKltOpencv(const vpKltOpencv &t1, const vpKltOpencv &t2);
397  virtual void setKltOpencv(const std::map<std::string, vpKltOpencv> &mapOfKlts);
398 
399  virtual void setKltThresholdAcceptation(double th);
400 
401 #endif
402 
403  virtual void setLod(bool useLod, const std::string &name = "");
404 
405  virtual void setMask(const vpImage<bool> &mask);
406 
407  virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name = "");
408  virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name = "");
409 
410  virtual void setMovingEdge(const vpMe &me);
411  virtual void setMovingEdge(const vpMe &me1, const vpMe &me2);
412  virtual void setMovingEdge(const std::map<std::string, vpMe> &mapOfMe);
413 
414  virtual void setNearClippingDistance(const double &dist);
415  virtual void setNearClippingDistance(const double &dist1, const double &dist2);
416  virtual void setNearClippingDistance(const std::map<std::string, double> &mapOfDists);
417 
418  virtual void setOgreShowConfigDialog(bool showConfigDialog);
419  virtual void setOgreVisibilityTest(const bool &v);
420 
421  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
422 
423  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
424  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
425 
426  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
427  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
428  virtual void setPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
429  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
430 
431  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
432  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
433  virtual void setPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
434  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
435 
436  virtual void setProjectionErrorComputation(const bool &flag);
437 
438  virtual void setProjectionErrorDisplay(bool display);
439  virtual void setProjectionErrorDisplayArrowLength(unsigned int length);
440  virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness);
441 
442  virtual void setReferenceCameraName(const std::string &referenceCameraName);
443 
444  virtual void setScanLineVisibilityTest(const bool &v);
445 
446  virtual void setTrackerType(int type);
447  virtual void setTrackerType(const std::map<std::string, int> &mapOfTrackerTypes);
448 
449  virtual void setUseDepthDenseTracking(const std::string &name, const bool &useDepthDenseTracking);
450  virtual void setUseDepthNormalTracking(const std::string &name, const bool &useDepthNormalTracking);
451  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
452 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
453  virtual void setUseKltTracking(const std::string &name, const bool &useKltTracking);
454 #endif
455 
456  virtual void testTracking();
457 
458  virtual void track(const vpImage<unsigned char> &I);
459  virtual void track(const vpImage<vpRGBa> &I_color);
460 
461  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
462  virtual void track(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2);
463 
464  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
465  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages);
466 
467 #ifdef VISP_HAVE_PCL
468  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
469  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
470  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
471  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
472 #endif
473 
474  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
475  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
476  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
477  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
478  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
479  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
480  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
481  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
482 
483 protected:
484  virtual void computeProjectionError();
485 
486  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
487 
488  virtual void computeVVSInit();
489  virtual void computeVVSInit(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
491  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
492  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
494  virtual void computeVVSWeights();
495 
496  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace = 0,
497  const std::string &name = "");
498 
499  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
500  const std::string &name = "");
501 
502  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
503 
504  virtual void initFaceFromLines(vpMbtPolygon &polygon);
505 
506 #ifdef VISP_HAVE_PCL
507  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
508  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
509 #endif
510  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
511  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
512  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
513  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
514 
515 private:
516  class TrackerWrapper : public vpMbEdgeTracker,
517 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
518  public vpMbKltTracker,
519 #endif
520  public vpMbDepthNormalTracker,
521  public vpMbDepthDenseTracker
522  {
523  friend class vpMbGenericTracker;
524 
525  public:
529  vpMatrix m_L;
531  int m_trackerType;
536 
537  TrackerWrapper();
538  explicit TrackerWrapper(int trackerType);
539 
540  virtual ~TrackerWrapper();
541 
542  virtual inline vpColVector getError() const { return m_error; }
543 
544  virtual inline vpColVector getRobustWeights() const { return m_w; }
545 
546  virtual inline int getTrackerType() const { return m_trackerType; }
547 
548  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
549  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
550  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
551  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
552 
553  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
554 
555  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
556  const vpHomogeneousMatrix &cMo,
557  const vpCameraParameters &cam,
558  bool displayFullModel = false);
559 
560  virtual void init(const vpImage<unsigned char> &I);
561 
562  virtual void loadConfigFile(const std::string &configFile, bool verbose = true);
563 
564  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
565  const vpHomogeneousMatrix &cMo, bool verbose = false,
567  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
568  const vpHomogeneousMatrix &cMo, bool verbose = false,
570 
571  virtual void resetTracker();
572 
573  virtual void setCameraParameters(const vpCameraParameters &camera);
574 
575  virtual void setClipping(const unsigned int &flags);
576 
577  virtual void setFarClippingDistance(const double &dist);
578 
579  virtual void setNearClippingDistance(const double &dist);
580 
581  virtual void setOgreVisibilityTest(const bool &v);
582 
583  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
584  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
585 
586  virtual void setProjectionErrorComputation(const bool &flag);
587 
588  virtual void setScanLineVisibilityTest(const bool &v);
589 
590  virtual void setTrackerType(int type);
591 
592  virtual void testTracking();
593 
594  virtual void track(const vpImage<unsigned char> &I);
595  virtual void track(const vpImage<vpRGBa> &I_color);
596 #ifdef VISP_HAVE_PCL
597  // Fix error: using declaration ‘using vpMbDepthDenseTracker::setPose’ conflicts with a previous
598  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
599 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
601 #endif
604  virtual void track(const vpImage<unsigned char> *const ptr_I,
605  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
606 #endif
607 
608  protected:
609  virtual void computeVVS(const vpImage<unsigned char> *const ptr_I);
610  virtual void computeVVSInit();
611  virtual void computeVVSInit(const vpImage<unsigned char> *const ptr_I);
614  virtual void computeVVSInteractionMatrixAndResidu(const vpImage<unsigned char> *const ptr_I);
616  virtual void computeVVSWeights();
617 
618  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace = 0,
619  const std::string &name = "");
620 
621  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
622  const std::string &name = "");
623 
624  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
625  virtual void initFaceFromLines(vpMbtPolygon &polygon);
626 
627  virtual void initMbtTracking(const vpImage<unsigned char> *const ptr_I);
628 
629 #ifdef VISP_HAVE_PCL
630  virtual void postTracking(const vpImage<unsigned char> *const ptr_I,
631  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
632  virtual void preTracking(const vpImage<unsigned char> *const ptr_I,
633  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
634 #endif
635  virtual void postTracking(const vpImage<unsigned char> *const ptr_I = NULL, const unsigned int pointcloud_width = 0,
636  const unsigned int pointcloud_height = 0);
637  virtual void preTracking(const vpImage<unsigned char> *const ptr_I = NULL,
638  const std::vector<vpColVector> *const point_cloud = NULL,
639  const unsigned int pointcloud_width = 0, const unsigned int pointcloud_height = 0);
640 
641  virtual void reInitModel(const vpImage<unsigned char> *const I, const vpImage<vpRGBa> *const I_color,
642  const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose = false,
644 
645 #ifdef VISP_HAVE_PCL
646  // Fix error: using declaration ‘using vpMbDepthDenseTracker::track’ conflicts with a previous
647  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
648 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
650 #endif
652 #endif
653  virtual void setPose(const vpImage<unsigned char> *const I, const vpImage<vpRGBa> *const I_color,
654  const vpHomogeneousMatrix &cdMo);
655  };
656 
657 protected:
664  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
666  std::map<vpTrackerType, double> m_mapOfFeatureFactors;
669  std::map<std::string, TrackerWrapper *> m_mapOfTrackers;
682 
684  unsigned int m_nb_feat_edge;
686  unsigned int m_nb_feat_klt;
688  unsigned int m_nb_feat_depthNormal;
690  unsigned int m_nb_feat_depthDense;
691 };
692 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
Class to define RGB colors available for display functionnalities.
Definition: vpColor.h:158
Implementation of an homogeneous matrix and operations on such kind of matrices.
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition: vpKltOpencv.h:79
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void track(const vpImage< unsigned char > &)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void track(const vpImage< unsigned char > &)
Make the complete tracking of an object by using its CAD model.
virtual void computeVVSInteractionMatrixAndResidu()
virtual void track(const vpImage< unsigned char > &I)
Real-time 6D object pose tracking using its CAD model.
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual std::vector< std::vector< double > > getFeaturesForDisplay()
virtual int getTrackerType() const
std::map< std::string, TrackerWrapper * > m_mapOfTrackers
virtual void setProjectionErrorComputation(const bool &flag)
unsigned int m_nb_feat_edge
Number of moving-edges features.
virtual unsigned int getNbFeaturesEdge() const
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
virtual void computeVVSInteractionMatrixAndResidu()
vpColVector m_w
Robust weights.
virtual void setNearClippingDistance(const double &dist)
virtual unsigned int getNbFeaturesKlt() const
unsigned int m_nb_feat_depthDense
Number of depth dense features.
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual vpColVector getRobustWeights() const
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setScanLineVisibilityTest(const bool &v)
virtual unsigned int getNbFeaturesDepthDense() const
vpColVector m_weightedError
Weighted error.
vpMatrix m_L
Interaction matrix.
virtual void init(const vpImage< unsigned char > &I)
virtual void computeVVSWeights()
virtual void computeVVSInit()
virtual unsigned int getNbFeaturesDepthNormal() const
vpColVector m_error
(s - s*)
std::map< vpTrackerType, double > m_mapOfFeatureFactors
Ponderation between each feature type in the VVS stage.
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")
virtual void setTrackerType(int type)
unsigned int m_nb_feat_klt
Number of klt features.
virtual void initFaceFromLines(vpMbtPolygon &polygon)
unsigned int m_nb_feat_depthNormal
Number of depth normal features.
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 void preTracking(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
virtual void setClipping(const unsigned int &flags)
virtual void loadConfigFile(const std::string &configFile, bool verbose=true)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void setOgreVisibilityTest(const bool &v)
std::string m_referenceCameraName
Name of the reference camera.
virtual vpColVector getError() const
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
virtual void track(const vpImage< unsigned char > &I)
Model based tracker using only KLT.
Main methods for a model-based tracker.
Definition: vpMbTracker.h:105
virtual void setProjectionErrorDisplayArrowLength(unsigned int length)
Definition: vpMbTracker.h:595
virtual double computeCurrentProjectionError(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam)
virtual void track(const vpImage< unsigned char > &I)=0
virtual void resetTracker()=0
virtual void setOgreShowConfigDialog(bool showConfigDialog)
Definition: vpMbTracker.h:647
virtual void setMask(const vpImage< bool > &mask)
Definition: vpMbTracker.h:564
virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
virtual void getCameraParameters(vpCameraParameters &cam) const
Definition: vpMbTracker.h:248
virtual void init(const vpImage< unsigned char > &I)=0
virtual void setDisplayFeatures(bool displayF)
Definition: vpMbTracker.h:518
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
virtual vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:423
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 setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")=0
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")=0
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setCameraParameters(const vpCameraParameters &cam)
Definition: vpMbTracker.h:488
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:481
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:631
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:605
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:332
virtual void setOgreVisibilityTest(const bool &v)
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setLod(bool useLod, const std::string &name="")
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setProjectionErrorDisplay(bool display)
Definition: vpMbTracker.h:590
virtual unsigned int getNbPolygon() const
Definition: vpMbTracker.h:368
virtual void setNearClippingDistance(const double &dist)
virtual void setFarClippingDistance(const double &dist)
virtual vpMbtPolygon * getPolygon(unsigned int index)
Definition: vpMbTracker.h:395
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:585
virtual void setClipping(const unsigned int &flags)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Definition: vpMbTracker.h:558
virtual void computeVVSInteractionMatrixAndResidu()=0
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 initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness)
Definition: vpMbTracker.h:600
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setAngleAppear(const double &a)
Definition: vpMbTracker.h:470
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:621
virtual void computeVVSInit()=0
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(bool orderPolygons=true, bool useVisibility=true, bool clipPolygon=false)
virtual void testTracking()=0
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:256
virtual void loadConfigFile(const std::string &configFile, bool verbose=true)
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:67
Definition: vpMe.h:61
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:82