Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
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 
198  virtual unsigned int getNbPoints(unsigned int level = 0) const;
199  virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints, unsigned int level = 0) const;
200 
201  virtual unsigned int getNbPolygon() const;
202  virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons) const;
203 
204  virtual vpMbtPolygon *getPolygon(unsigned int index);
205  virtual vpMbtPolygon *getPolygon(const std::string &cameraName, unsigned int index);
206 
207  virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
208  getPolygonFaces(bool orderPolygons = true, bool useVisibility = true, bool clipPolygon = false);
209  virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
210  std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
211  bool orderPolygons = true, bool useVisibility = true,
212  bool clipPolygon = false);
213 
214  using vpMbTracker::getPose;
215  virtual void getPose(vpHomogeneousMatrix &cMo) const;
216  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
217  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
218 
219  virtual std::string getReferenceCameraName() const;
220 
221  virtual inline vpColVector getRobustWeights() const { return m_w; }
222 
223  virtual int getTrackerType() const;
224 
225  virtual void init(const vpImage<unsigned char> &I);
226 
227 #ifdef VISP_HAVE_MODULE_GUI
229  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
230  const std::string &initFile1, const std::string &initFile2, bool displayHelp = false,
232  virtual void initClick(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
233  const std::string &initFile1, const std::string &initFile2, bool displayHelp = false,
235 
236  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
237  const std::map<std::string, std::string> &mapOfInitFiles, bool displayHelp = false,
238  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
239  virtual void initClick(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
240  const std::map<std::string, std::string> &mapOfInitFiles, bool displayHelp = false,
241  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
242 #endif
243 
245  virtual void initFromPoints(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
246  const std::string &initFile1, const std::string &initFile2);
247  virtual void initFromPoints(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
248  const std::string &initFile1, const std::string &initFile2);
249 
250  virtual void initFromPoints(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
251  const std::map<std::string, std::string> &mapOfInitPoints);
252  virtual void initFromPoints(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
253  const std::map<std::string, std::string> &mapOfInitPoints);
254 
256  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
257  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
258  const std::string &initFile1, const std::string &initFile2);
259  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
260  const std::string &initFile1, const std::string &initFile2);
261 
262  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
263  const std::map<std::string, std::string> &mapOfInitPoses);
264  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
265  const std::map<std::string, std::string> &mapOfInitPoses);
266 
267  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
268  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
269  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
270  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
271 
272  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
273  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
274  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
275  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
276 
277  virtual void loadConfigFile(const std::string &configFile);
278  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2);
279  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles);
280 
281  virtual void loadModel(const std::string &modelFile, bool verbose = false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix());
282  virtual void loadModel(const std::string &modelFile1, const std::string &modelFile2, bool verbose = false,
284  virtual void loadModel(const std::map<std::string, std::string> &mapOfModelFiles, bool verbose = false,
285  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
286 
287  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
288  const vpHomogeneousMatrix &cMo, bool verbose = false,
290  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
291  const vpHomogeneousMatrix &cMo, bool verbose = false,
293 
294  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
295  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
296  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
298  virtual void reInitModel(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
299  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
300  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
302 
303  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
304  const std::map<std::string, std::string> &mapOfModelFiles,
305  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
306  bool verbose = false,
307  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
308  virtual void reInitModel(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
309  const std::map<std::string, std::string> &mapOfModelFiles,
310  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
311  bool verbose = false,
312  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
313 
314  virtual void resetTracker();
315 
316  virtual void setAngleAppear(const double &a);
317  virtual void setAngleAppear(const double &a1, const double &a2);
318  virtual void setAngleAppear(const std::map<std::string, double> &mapOfAngles);
319 
320  virtual void setAngleDisappear(const double &a);
321  virtual void setAngleDisappear(const double &a1, const double &a2);
322  virtual void setAngleDisappear(const std::map<std::string, double> &mapOfAngles);
323 
324  virtual void setCameraParameters(const vpCameraParameters &camera);
325  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2);
326  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
327 
328  virtual void setCameraTransformationMatrix(const std::string &cameraName,
329  const vpHomogeneousMatrix &cameraTransformationMatrix);
330  virtual void
331  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
332 
333  virtual void setClipping(const unsigned int &flags);
334  virtual void setClipping(const unsigned int &flags1, const unsigned int &flags2);
335  virtual void setClipping(const std::map<std::string, unsigned int> &mapOfClippingFlags);
336 
337  virtual void setDepthDenseFilteringMaxDistance(double maxDistance);
338  virtual void setDepthDenseFilteringMethod(int method);
339  virtual void setDepthDenseFilteringMinDistance(double minDistance);
340  virtual void setDepthDenseFilteringOccupancyRatio(double occupancyRatio);
341  virtual void setDepthDenseSamplingStep(unsigned int stepX, unsigned int stepY);
342 
343  virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method);
344  virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method);
345  virtual void setDepthNormalPclPlaneEstimationMethod(int method);
346  virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter);
347  virtual void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold);
348  virtual void setDepthNormalSamplingStep(unsigned int stepX, unsigned int stepY);
349 
350  virtual void setDisplayFeatures(bool displayF);
351 
352  virtual void setFarClippingDistance(const double &dist);
353  virtual void setFarClippingDistance(const double &dist1, const double &dist2);
354  virtual void setFarClippingDistance(const std::map<std::string, double> &mapOfClippingDists);
355 
356  virtual void setFeatureFactors(const std::map<vpTrackerType, double> &mapOfFeatureFactors);
357 
358  virtual void setGoodMovingEdgesRatioThreshold(double threshold);
359 
360 #ifdef VISP_HAVE_OGRE
361  virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio);
362  virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
363 #endif
364 
365 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
366  virtual void setKltMaskBorder(const unsigned int &e);
367  virtual void setKltMaskBorder(const unsigned int &e1, const unsigned int &e2);
368  virtual void setKltMaskBorder(const std::map<std::string, unsigned int> &mapOfErosions);
369 
370  virtual void setKltOpencv(const vpKltOpencv &t);
371  virtual void setKltOpencv(const vpKltOpencv &t1, const vpKltOpencv &t2);
372  virtual void setKltOpencv(const std::map<std::string, vpKltOpencv> &mapOfKlts);
373 
374  virtual void setKltThresholdAcceptation(double th);
375 
376 #endif
377 
378  virtual void setLod(bool useLod, const std::string &name = "");
379 
380  virtual void setMask(const vpImage<bool> &mask);
381 
382  virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name = "");
383  virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name = "");
384 
385  virtual void setMovingEdge(const vpMe &me);
386  virtual void setMovingEdge(const vpMe &me1, const vpMe &me2);
387  virtual void setMovingEdge(const std::map<std::string, vpMe> &mapOfMe);
388 
389  virtual void setNearClippingDistance(const double &dist);
390  virtual void setNearClippingDistance(const double &dist1, const double &dist2);
391  virtual void setNearClippingDistance(const std::map<std::string, double> &mapOfDists);
392 
393  virtual void setOgreShowConfigDialog(bool showConfigDialog);
394  virtual void setOgreVisibilityTest(const bool &v);
395 
396  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
397 
398  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
399  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
400 
401  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
402  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
403  virtual void setPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
404  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
405 
406  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
407  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
408  virtual void setPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
409  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
410 
411  virtual void setProjectionErrorComputation(const bool &flag);
412 
413  virtual void setProjectionErrorDisplay(bool display);
414  virtual void setProjectionErrorDisplayArrowLength(unsigned int length);
415  virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness);
416 
417  virtual void setReferenceCameraName(const std::string &referenceCameraName);
418 
419  virtual void setScanLineVisibilityTest(const bool &v);
420 
421  virtual void setTrackerType(int type);
422  virtual void setTrackerType(const std::map<std::string, int> &mapOfTrackerTypes);
423 
424  virtual void setUseDepthDenseTracking(const std::string &name, const bool &useDepthDenseTracking);
425  virtual void setUseDepthNormalTracking(const std::string &name, const bool &useDepthNormalTracking);
426  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
427 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
428  virtual void setUseKltTracking(const std::string &name, const bool &useKltTracking);
429 #endif
430 
431  virtual void testTracking();
432 
433  virtual void track(const vpImage<unsigned char> &I);
434  virtual void track(const vpImage<vpRGBa> &I_color);
435 
436  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
437  virtual void track(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2);
438 
439  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
440  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages);
441 
442 #ifdef VISP_HAVE_PCL
443  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
444  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
445  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
446  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
447 #endif
448 
449  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
450  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
451  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
452  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
453  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
454  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
455  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
456  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
457 
458 protected:
459  virtual void computeProjectionError();
460 
461  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
462 
463  virtual void computeVVSInit();
464  virtual void computeVVSInit(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
466  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
467  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
469  virtual void computeVVSWeights();
470 
471  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius,
472  int idFace = 0, const std::string &name = "");
473 
474  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
475  const std::string &name = "");
476 
477  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
478 
479  virtual void initFaceFromLines(vpMbtPolygon &polygon);
480 
481 #ifdef VISP_HAVE_PCL
482  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
483  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
484 #endif
485  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
486  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
487  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
488  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
489 
490 private:
491  class TrackerWrapper : public vpMbEdgeTracker,
492 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
493  public vpMbKltTracker,
494 #endif
495  public vpMbDepthNormalTracker,
496  public vpMbDepthDenseTracker
497  {
498  friend class vpMbGenericTracker;
499 
500  public:
504  vpMatrix m_L;
506  int m_trackerType;
511 
512  TrackerWrapper();
513  explicit TrackerWrapper(int trackerType);
514 
515  virtual ~TrackerWrapper();
516 
517  virtual inline vpColVector getError() const { return m_error; }
518 
519  virtual inline vpColVector getRobustWeights() const { return m_w; }
520 
521  virtual inline int getTrackerType() const { return m_trackerType; }
522 
523  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
524  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
525  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
526  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
527 
528  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
529 
530  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
531  const vpHomogeneousMatrix &cMo,
532  const vpCameraParameters &cam,
533  bool displayFullModel=false);
534 
535  virtual void init(const vpImage<unsigned char> &I);
536 
537  virtual void loadConfigFile(const std::string &configFile);
538 
539  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
540  const vpHomogeneousMatrix &cMo, bool verbose = false,
542  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
543  const vpHomogeneousMatrix &cMo, bool verbose = false,
545 
546  virtual void resetTracker();
547 
548  virtual void setCameraParameters(const vpCameraParameters &camera);
549 
550  virtual void setClipping(const unsigned int &flags);
551 
552  virtual void setFarClippingDistance(const double &dist);
553 
554  virtual void setNearClippingDistance(const double &dist);
555 
556  virtual void setOgreVisibilityTest(const bool &v);
557 
558  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
559  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
560 
561  virtual void setProjectionErrorComputation(const bool &flag);
562 
563  virtual void setScanLineVisibilityTest(const bool &v);
564 
565  virtual void setTrackerType(int type);
566 
567  virtual void testTracking();
568 
569  virtual void track(const vpImage<unsigned char> &I);
570  virtual void track(const vpImage<vpRGBa> &I_color);
571 #ifdef VISP_HAVE_PCL
572  // Fix error: using declaration ‘using vpMbDepthDenseTracker::setPose’ conflicts with a previous
573  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
574 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
576 #endif
579  virtual void track(const vpImage<unsigned char> *const ptr_I,
580  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
581 #endif
582 
583  protected:
584  virtual void computeVVS(const vpImage<unsigned char> *const ptr_I);
585  virtual void computeVVSInit();
586  virtual void computeVVSInit(const vpImage<unsigned char> *const ptr_I);
589  virtual void computeVVSInteractionMatrixAndResidu(const vpImage<unsigned char> *const ptr_I);
591  virtual void computeVVSWeights();
592 
593  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius,
594  int idFace = 0, const std::string &name = "");
595 
596  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
597  const std::string &name = "");
598 
599  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
600  virtual void initFaceFromLines(vpMbtPolygon &polygon);
601 
602  virtual void initMbtTracking(const vpImage<unsigned char> *const ptr_I);
603 
604 #ifdef VISP_HAVE_PCL
605  virtual void postTracking(const vpImage<unsigned char> *const ptr_I,
606  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
607  virtual void preTracking(const vpImage<unsigned char> *const ptr_I,
608  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
609 #endif
610  virtual void postTracking(const vpImage<unsigned char> *const ptr_I = NULL, const unsigned int pointcloud_width = 0,
611  const unsigned int pointcloud_height = 0);
612  virtual void preTracking(const vpImage<unsigned char> *const ptr_I = NULL,
613  const std::vector<vpColVector> *const point_cloud = NULL,
614  const unsigned int pointcloud_width = 0, const unsigned int pointcloud_height = 0);
615 
616  virtual void reInitModel(const vpImage<unsigned char> * const I, const vpImage<vpRGBa> * const I_color,
617  const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose = false,
619 
620 #ifdef VISP_HAVE_PCL
621  // Fix error: using declaration ‘using vpMbDepthDenseTracker::track’ conflicts with a previous
622  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
623 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
625 #endif
627 #endif
628  virtual void setPose(const vpImage<unsigned char> * const I, const vpImage<vpRGBa> * const I_color,
629  const vpHomogeneousMatrix &cdMo);
630  };
631 
632 protected:
639  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
641  std::map<vpTrackerType, double> m_mapOfFeatureFactors;
644  std::map<std::string, TrackerWrapper *> m_mapOfTrackers;
657 };
658 #endif
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:252
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 loadConfigFile(const std::string &configFile)
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:164
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
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 void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:476
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 int getTrackerType() const
virtual void track(const vpImage< unsigned char > &)
virtual void loadConfigFile(const std::string &configFile)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Definition: vpMbTracker.h:553
virtual vpMbtPolygon * getPolygon(unsigned int index)
Definition: vpMbTracker.h:391
Class to define colors available for display functionnalities.
Definition: vpColor.h:119
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:639
virtual void computeVVSInit()
Definition: vpMe.h:60
virtual void setMask(const vpImage< bool > &mask)
Definition: vpMbTracker.h:559
Make the complete tracking of an object by using its CAD model.
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 computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages)
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:590
Class that defines what is a point.
Definition: vpPoint.h:58
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 vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:419
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:613
vpColVector m_weightedError
Weighted error.
virtual void setCameraParameters(const vpCameraParameters &cam)
Definition: vpMbTracker.h:483
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 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:465
Model based tracker using only KLT.
virtual std::vector< std::vector< double > > getFeaturesForDisplay()
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:623
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
virtual void computeVVSWeights()
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual void setProjectionErrorDisplay(bool display)
Definition: vpMbTracker.h:585
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
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 vpColVector getError() const
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness)
Definition: vpMbTracker.h:595
virtual void setScanLineVisibilityTest(const bool &v)
virtual vpColVector getRobustWeights() const
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 unsigned int getNbPolygon() const
Definition: vpMbTracker.h:364
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
virtual void preTracking(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
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 void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:597
virtual void setClipping(const unsigned int &flags)
virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
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:328
virtual void setDisplayFeatures(bool displayF)
Definition: vpMbTracker.h:513
virtual void getCameraParameters(vpCameraParameters &cam) const
Definition: vpMbTracker.h:244
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:580
virtual void setNearClippingDistance(const double &dist)