Visual Servoing Platform  version 3.2.1 under development (2019-11-19)
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(const unsigned int nbCameras, const 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, const unsigned int thickness = 1, const bool displayFullModel = false);
106  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
107  const vpColor &col, const unsigned int thickness = 1, const 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, const unsigned int thickness = 1,
112  const 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, const unsigned int thickness = 1, const 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  const unsigned int thickness = 1, const 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  const unsigned int thickness = 1, const bool displayFullModel = false);
125 
126  virtual std::vector<std::string> getCameraNames() const;
127 
129  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
130  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
131 
132  virtual std::map<std::string, int> getCameraTrackerTypes() const;
133 
135  virtual void getClipping(unsigned int &clippingFlag1, unsigned int &clippingFlag2) const;
136  virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags) const;
137 
138  virtual inline vpColVector getError() const { return m_error; }
139 
141  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces(const std::string &cameraName);
142 
143 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
144  virtual std::list<vpMbtDistanceCircle *> &getFeaturesCircle();
145  virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder();
146  virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt();
147 #endif
148 
149  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
150  virtual void getFeaturesForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfFeatures);
151 
152  virtual double getGoodMovingEdgesRatioThreshold() const;
153 
154 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
155  virtual std::vector<vpImagePoint> getKltImagePoints() const;
156  virtual std::map<int, vpImagePoint> getKltImagePointsWithId() const;
157 
158  virtual unsigned int getKltMaskBorder() const;
159  virtual int getKltNbPoints() const;
160 
161  virtual vpKltOpencv getKltOpencv() const;
162  virtual void getKltOpencv(vpKltOpencv &klt1, vpKltOpencv &klt2) const;
163  virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts) const;
164 
165 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
166  virtual std::vector<cv::Point2f> getKltPoints() const;
167 #endif
168 
169  virtual double getKltThresholdAcceptation() const;
170 #endif
171 
172  virtual void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList, const unsigned int level = 0) const;
173  virtual void getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
174  const unsigned int level = 0) const;
175  virtual void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList, const unsigned int level = 0) const;
176  virtual void getLcylinder(const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
177  const unsigned int level = 0) const;
178  virtual void getLline(std::list<vpMbtDistanceLine *> &linesList, const unsigned int level = 0) const;
179  virtual void getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
180  const unsigned int level = 0) const;
181 
182  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
183  const vpHomogeneousMatrix &cMo,
184  const vpCameraParameters &cam,
185  const bool displayFullModel=false);
186  virtual void getModelForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfModels,
187  unsigned int width, unsigned int height,
188  const vpHomogeneousMatrix &cMo,
189  const vpCameraParameters &cam,
190  const bool displayFullModel=false);
191 
192  virtual vpMe getMovingEdge() const;
193  virtual void getMovingEdge(vpMe &me1, vpMe &me2) const;
194  virtual void getMovingEdge(std::map<std::string, vpMe> &mapOfMovingEdges) const;
195 
196  virtual unsigned int getNbPoints(const unsigned int level = 0) const;
197  virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints, const unsigned int level = 0) const;
198 
199  virtual inline unsigned int getNbPolygon() const;
200  virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons) const;
201 
202  virtual vpMbtPolygon *getPolygon(const unsigned int index);
203  virtual vpMbtPolygon *getPolygon(const std::string &cameraName, const unsigned int index);
204 
205  virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
206  getPolygonFaces(const bool orderPolygons = true, const bool useVisibility = true, const bool clipPolygon = false);
207  virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
208  std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
209  const bool orderPolygons = true, const bool useVisibility = true,
210  const bool clipPolygon = false);
211 
212  using vpMbTracker::getPose;
213  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
214  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
215 
216  virtual inline vpColVector getRobustWeights() const { return m_w; }
217 
218  virtual int getTrackerType() const;
219 
220  virtual void init(const vpImage<unsigned char> &I);
221 
222 #ifdef VISP_HAVE_MODULE_GUI
224  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
225  const std::string &initFile1, const std::string &initFile2, const bool displayHelp = false,
227  virtual void initClick(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
228  const std::string &initFile1, const std::string &initFile2, const bool displayHelp = false,
230 
231  virtual void initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
232  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp = false,
233  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
234  virtual void initClick(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
235  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp = false,
236  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
237 #endif
238 
240  virtual void initFromPoints(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
241  const std::string &initFile1, const std::string &initFile2);
242  virtual void initFromPoints(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
243  const std::string &initFile1, const std::string &initFile2);
244 
245  virtual void initFromPoints(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
246  const std::map<std::string, std::string> &mapOfInitPoints);
247  virtual void initFromPoints(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
248  const std::map<std::string, std::string> &mapOfInitPoints);
249 
251  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
252  const std::string &initFile1, const std::string &initFile2);
253  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
254  const std::string &initFile1, const std::string &initFile2);
255 
256  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
257  const std::map<std::string, std::string> &mapOfInitPoses);
258  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
259  const std::map<std::string, std::string> &mapOfInitPoses);
260 
261  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
262  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
263  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
264  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
265 
266  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
267  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
268  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
269  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
270 
271  virtual void loadConfigFile(const std::string &configFile);
272  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2);
273  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles);
274 
275  virtual void loadModel(const std::string &modelFile, const bool verbose = false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix());
276  virtual void loadModel(const std::string &modelFile1, const std::string &modelFile2, const bool verbose = false,
278  virtual void loadModel(const std::map<std::string, std::string> &mapOfModelFiles, const bool verbose = false,
279  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
280 
281  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
282  const vpHomogeneousMatrix &cMo_, const bool verbose = false,
284  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
285  const vpHomogeneousMatrix &cMo_, const bool verbose = false,
287 
288  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
289  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
290  const vpHomogeneousMatrix &c2Mo, const bool verbose = false,
292  virtual void reInitModel(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
293  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
294  const vpHomogeneousMatrix &c2Mo, const bool verbose = false,
296 
297  virtual void reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
298  const std::map<std::string, std::string> &mapOfModelFiles,
299  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
300  const bool verbose = false,
301  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
302  virtual void reInitModel(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
303  const std::map<std::string, std::string> &mapOfModelFiles,
304  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
305  const bool verbose = false,
306  const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
307 
308  virtual void resetTracker();
309 
310  virtual void setAngleAppear(const double &a);
311  virtual void setAngleAppear(const double &a1, const double &a2);
312  virtual void setAngleAppear(const std::map<std::string, double> &mapOfAngles);
313 
314  virtual void setAngleDisappear(const double &a);
315  virtual void setAngleDisappear(const double &a1, const double &a2);
316  virtual void setAngleDisappear(const std::map<std::string, double> &mapOfAngles);
317 
318  virtual void setCameraParameters(const vpCameraParameters &camera);
319  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2);
320  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
321 
322  virtual void setCameraTransformationMatrix(const std::string &cameraName,
323  const vpHomogeneousMatrix &cameraTransformationMatrix);
324  virtual void
325  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
326 
327  virtual void setClipping(const unsigned int &flags);
328  virtual void setClipping(const unsigned int &flags1, const unsigned int &flags2);
329  virtual void setClipping(const std::map<std::string, unsigned int> &mapOfClippingFlags);
330 
331  virtual void setDepthDenseFilteringMaxDistance(const double maxDistance);
332  virtual void setDepthDenseFilteringMethod(const int method);
333  virtual void setDepthDenseFilteringMinDistance(const double minDistance);
334  virtual void setDepthDenseFilteringOccupancyRatio(const double occupancyRatio);
335  virtual void setDepthDenseSamplingStep(const unsigned int stepX, const unsigned int stepY);
336 
337  virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method);
338  virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method);
339  virtual void setDepthNormalPclPlaneEstimationMethod(const int method);
340  virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter);
341  virtual void setDepthNormalPclPlaneEstimationRansacThreshold(const double thresold);
342  virtual void setDepthNormalSamplingStep(const unsigned int stepX, const unsigned int stepY);
343 
344  virtual void setDisplayFeatures(const bool displayF);
345 
346  virtual void setFarClippingDistance(const double &dist);
347  virtual void setFarClippingDistance(const double &dist1, const double &dist2);
348  virtual void setFarClippingDistance(const std::map<std::string, double> &mapOfClippingDists);
349 
350  virtual void setFeatureFactors(const std::map<vpTrackerType, double> &mapOfFeatureFactors);
351 
352  virtual void setGoodMovingEdgesRatioThreshold(const double threshold);
353 
354 #ifdef VISP_HAVE_OGRE
355  virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio);
356  virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
357 #endif
358 
359 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
360  virtual void setKltMaskBorder(const unsigned int &e);
361  virtual void setKltMaskBorder(const unsigned int &e1, const unsigned int &e2);
362  virtual void setKltMaskBorder(const std::map<std::string, unsigned int> &mapOfErosions);
363 
364  virtual void setKltOpencv(const vpKltOpencv &t);
365  virtual void setKltOpencv(const vpKltOpencv &t1, const vpKltOpencv &t2);
366  virtual void setKltOpencv(const std::map<std::string, vpKltOpencv> &mapOfKlts);
367 
368  virtual void setKltThresholdAcceptation(const double th);
369 
370 #endif
371 
372  virtual void setLod(const bool useLod, const std::string &name = "");
373 
374  virtual void setMask(const vpImage<bool> &mask);
375 
376  virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name = "");
377  virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name = "");
378 
379  virtual void setMovingEdge(const vpMe &me);
380  virtual void setMovingEdge(const vpMe &me1, const vpMe &me2);
381  virtual void setMovingEdge(const std::map<std::string, vpMe> &mapOfMe);
382 
383  virtual void setNearClippingDistance(const double &dist);
384  virtual void setNearClippingDistance(const double &dist1, const double &dist2);
385  virtual void setNearClippingDistance(const std::map<std::string, double> &mapOfDists);
386 
387  virtual void setOgreShowConfigDialog(const bool showConfigDialog);
388  virtual void setOgreVisibilityTest(const bool &v);
389 
390  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt);
391 
392  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
393  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
394 
395  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
396  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
397  virtual void setPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
398  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
399 
400  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
401  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
402  virtual void setPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
403  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
404 
405  virtual void setProjectionErrorComputation(const bool &flag);
406 
407  virtual void setProjectionErrorDisplay(const bool display);
408  virtual void setProjectionErrorDisplayArrowLength(const unsigned int length);
409  virtual void setProjectionErrorDisplayArrowThickness(const unsigned int thickness);
410 
411  virtual void setReferenceCameraName(const std::string &referenceCameraName);
412 
413  virtual void setScanLineVisibilityTest(const bool &v);
414 
415  virtual void setTrackerType(const int type);
416  virtual void setTrackerType(const std::map<std::string, int> &mapOfTrackerTypes);
417 
418  virtual void setUseDepthDenseTracking(const std::string &name, const bool &useDepthDenseTracking);
419  virtual void setUseDepthNormalTracking(const std::string &name, const bool &useDepthNormalTracking);
420  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
421 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
422  virtual void setUseKltTracking(const std::string &name, const bool &useKltTracking);
423 #endif
424 
425  virtual void testTracking();
426 
427  virtual void track(const vpImage<unsigned char> &I);
428  virtual void track(const vpImage<vpRGBa> &I_color);
429 
430  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
431  virtual void track(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2);
432 
433  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
434  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages);
435 
436 #ifdef VISP_HAVE_PCL
437  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
438  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
439  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
440  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
441 #endif
442 
443  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
444  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
445  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
446  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
447  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
448  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
449  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
450  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
451 
452 protected:
453  virtual void computeProjectionError();
454 
455  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
456 
457  virtual void computeVVSInit();
458  virtual void computeVVSInit(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
460  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
461  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
463  virtual void computeVVSWeights();
464 
465  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius,
466  const int idFace = 0, const std::string &name = "");
467 
468  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace = 0,
469  const std::string &name = "");
470 
471  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
472 
473  virtual void initFaceFromLines(vpMbtPolygon &polygon);
474 
475 #ifdef VISP_HAVE_PCL
476  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
477  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
478 #endif
479  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
480  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
481  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
482  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
483 
484 private:
485  class TrackerWrapper : public vpMbEdgeTracker,
486 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
487  public vpMbKltTracker,
488 #endif
489  public vpMbDepthNormalTracker,
490  public vpMbDepthDenseTracker
491  {
492  friend class vpMbGenericTracker;
493 
494  public:
498  vpMatrix m_L;
500  int m_trackerType;
505 
506  TrackerWrapper();
507  explicit TrackerWrapper(const int trackerType);
508 
509  virtual ~TrackerWrapper();
510 
511  virtual inline vpColVector getError() const { return m_error; }
512 
513  virtual inline vpColVector getRobustWeights() const { return m_w; }
514 
515  virtual inline int getTrackerType() const { return m_trackerType; }
516 
517  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
518  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
519  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
520  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
521 
522  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
523 
524  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
525  const vpHomogeneousMatrix &cMo,
526  const vpCameraParameters &cam,
527  const bool displayFullModel=false);
528 
529  virtual void init(const vpImage<unsigned char> &I);
530 
531  virtual void loadConfigFile(const std::string &configFile);
532 
533  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
534  const vpHomogeneousMatrix &cMo_, const bool verbose = false,
536  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
537  const vpHomogeneousMatrix &cMo_, const bool verbose = false,
539 
540  virtual void resetTracker();
541 
542  virtual void setCameraParameters(const vpCameraParameters &camera);
543 
544  virtual void setClipping(const unsigned int &flags);
545 
546  virtual void setFarClippingDistance(const double &dist);
547 
548  virtual void setNearClippingDistance(const double &dist);
549 
550  virtual void setOgreVisibilityTest(const bool &v);
551 
552  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
553  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
554 
555  virtual void setProjectionErrorComputation(const bool &flag);
556 
557  virtual void setScanLineVisibilityTest(const bool &v);
558 
559  virtual void setTrackerType(const int type);
560 
561  virtual void testTracking();
562 
563  virtual void track(const vpImage<unsigned char> &I);
564  virtual void track(const vpImage<vpRGBa> &I_color);
565 #ifdef VISP_HAVE_PCL
566  // Fix error: using declaration ‘using vpMbDepthDenseTracker::setPose’ conflicts with a previous
567  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
568 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
570 #endif
573  virtual void track(const vpImage<unsigned char> *const ptr_I,
574  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
575 #endif
576 
577  protected:
578  virtual void computeVVS(const vpImage<unsigned char> *const ptr_I);
579  virtual void computeVVSInit();
580  virtual void computeVVSInit(const vpImage<unsigned char> *const ptr_I);
583  virtual void computeVVSInteractionMatrixAndResidu(const vpImage<unsigned char> *const ptr_I);
585  virtual void computeVVSWeights();
586 
587  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius,
588  const int idFace = 0, const std::string &name = "");
589 
590  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace = 0,
591  const std::string &name = "");
592 
593  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
594  virtual void initFaceFromLines(vpMbtPolygon &polygon);
595 
596  virtual void initMbtTracking(const vpImage<unsigned char> *const ptr_I);
597 
598 #ifdef VISP_HAVE_PCL
599  virtual void postTracking(const vpImage<unsigned char> *const ptr_I,
600  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
601  virtual void preTracking(const vpImage<unsigned char> *const ptr_I,
602  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
603 #endif
604  virtual void postTracking(const vpImage<unsigned char> *const ptr_I = NULL, const unsigned int pointcloud_width = 0,
605  const unsigned int pointcloud_height = 0);
606  virtual void preTracking(const vpImage<unsigned char> *const ptr_I = NULL,
607  const std::vector<vpColVector> *const point_cloud = NULL,
608  const unsigned int pointcloud_width = 0, const unsigned int pointcloud_height = 0);
609 
610  virtual void reInitModel(const vpImage<unsigned char> * const I, const vpImage<vpRGBa> * const I_color,
611  const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose = false,
613 
614 #ifdef VISP_HAVE_PCL
615  // Fix error: using declaration ‘using vpMbDepthDenseTracker::track’ conflicts with a previous
616  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
617 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
619 #endif
621 #endif
622  virtual void setPose(const vpImage<unsigned char> * const I, const vpImage<vpRGBa> * const I_color,
623  const vpHomogeneousMatrix &cdMo);
624  };
625 
626 protected:
633  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
635  std::map<vpTrackerType, double> m_mapOfFeatureFactors;
638  std::map<std::string, TrackerWrapper *> m_mapOfTrackers;
651 };
652 #endif
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:252
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const bool displayFullModel=false)
virtual void setDisplayFeatures(const bool displayF)
Definition: vpMbTracker.h:513
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Definition: vpMbTracker.h:639
virtual void loadConfigFile(const std::string &configFile)
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 initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
virtual void computeVVSInit()=0
vpColVector m_w
Robust weights.
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:476
Implementation of an homogeneous matrix and operations on such kind of matrices.
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 void loadModel(const std::string &modelFile, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
virtual void setClipping(const unsigned int &flags)
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")=0
virtual void track(const vpImage< unsigned char > &)
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)
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 setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)=0
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:613
vpColVector m_weightedError
Weighted error.
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const bool displayFullModel=false)=0
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:66
virtual void setCameraParameters(const vpCameraParameters &camera)
Definition: vpMbTracker.h:483
virtual void setProjectionErrorComputation(const bool &flag)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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
virtual void setProjectionErrorDisplay(const bool display)
Definition: vpMbTracker.h:585
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 computeVVSWeights()
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void setNearClippingDistance(const double &dist)
virtual vpColVector getError() const
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setScanLineVisibilityTest(const bool &v)
virtual vpColVector getRobustWeights() const
virtual void setOgreVisibilityTest(const bool &v)
virtual void getCameraParameters(vpCameraParameters &camera) const
Definition: vpMbTracker.h:244
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 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)
virtual void setProjectionErrorDisplayArrowLength(const unsigned int length)
Definition: vpMbTracker.h:590
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 vpMbtPolygon * getPolygon(const unsigned int index)
Definition: vpMbTracker.h:391
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setTrackerType(const int type)
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 setProjectionErrorDisplayArrowThickness(const unsigned int thickness)
Definition: vpMbTracker.h:595
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void setFarClippingDistance(const double &dist)
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:328
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(const bool orderPolygons=true, const bool useVisibility=true, const bool clipPolygon=false)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")=0
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:580
virtual void setLod(const bool useLod, const std::string &name="")
virtual void setNearClippingDistance(const double &dist)