Visual Servoing Platform  version 3.6.1 under development (2024-03-04)
vpMbGenericTracker.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Generic model-based tracker.
32  */
33 
39 #ifndef _vpMbGenericTracker_h_
40 #define _vpMbGenericTracker_h_
41 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/mbt/vpMbDepthDenseTracker.h>
44 #include <visp3/mbt/vpMbDepthNormalTracker.h>
45 #include <visp3/mbt/vpMbEdgeTracker.h>
46 #include <visp3/mbt/vpMbKltTracker.h>
47 
48 #ifdef VISP_HAVE_NLOHMANN_JSON
49 #include <nlohmann/json_fwd.hpp>
50 #include <visp3/core/vpJsonParsing.h>
51 #endif
52 
199 class VISP_EXPORT vpMbGenericTracker : public vpMbTracker
200 {
201 public:
203  {
204  EDGE_TRACKER = 1 << 0,
205 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO))
206  KLT_TRACKER = 1 << 1,
207 #endif
208  DEPTH_NORMAL_TRACKER = 1 << 2,
209  DEPTH_DENSE_TRACKER = 1 << 3
210  };
211 
213  vpMbGenericTracker(unsigned int nbCameras, int trackerType = EDGE_TRACKER);
214  explicit vpMbGenericTracker(const std::vector<int> &trackerTypes);
215  vpMbGenericTracker(const std::vector<std::string> &cameraNames, const std::vector<int> &trackerTypes);
216 
217  virtual ~vpMbGenericTracker() vp_override;
218 
219  virtual double computeCurrentProjectionError(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &_cMo,
220  const vpCameraParameters &_cam) vp_override;
221  virtual double computeCurrentProjectionError(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &_cMo,
222  const vpCameraParameters &_cam);
223 
224  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
225  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false) vp_override;
226  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
227  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false) vp_override;
228 
229  virtual void display(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
230  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1,
231  const vpCameraParameters &cam2, const vpColor &color, unsigned int thickness = 1,
232  bool displayFullModel = false);
233  virtual void display(const vpImage<vpRGBa> &I1, const vpImage<vpRGBa> &I2, const vpHomogeneousMatrix &c1Mo,
234  const vpHomogeneousMatrix &c2Mo, const vpCameraParameters &cam1, const vpCameraParameters &cam2,
235  const vpColor &color, unsigned int thickness = 1, bool displayFullModel = false);
236 
237  virtual void display(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
238  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
239  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters, const vpColor &col,
240  unsigned int thickness = 1, bool displayFullModel = false);
241  virtual void display(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
242  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
243  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters, const vpColor &col,
244  unsigned int thickness = 1, bool displayFullModel = false);
245 
246  virtual std::vector<std::string> getCameraNames() const;
247 
248  using vpMbTracker::getCameraParameters;
249  virtual void getCameraParameters(vpCameraParameters &camera) const vp_override;
250  virtual void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const;
251  virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const;
252 
253  virtual std::map<std::string, int> getCameraTrackerTypes() const;
254 
255  using vpMbTracker::getClipping;
256  virtual void getClipping(unsigned int &clippingFlag1, unsigned int &clippingFlag2) const;
257  virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags) const;
258 
259  virtual inline vpColVector getError() const vp_override { return m_error; }
260 
261  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces() vp_override;
262  virtual vpMbHiddenFaces<vpMbtPolygon> &getFaces(const std::string &cameraName);
263 
264 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
265  virtual std::list<vpMbtDistanceCircle *> &getFeaturesCircle();
266  virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder();
267  virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt();
268 #endif
269 
270  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
271  virtual void getFeaturesForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfFeatures);
272 
273  virtual double getGoodMovingEdgesRatioThreshold() const;
274 
275 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
276  virtual std::vector<vpImagePoint> getKltImagePoints() const;
277  virtual std::map<int, vpImagePoint> getKltImagePointsWithId() const;
278 
279  virtual unsigned int getKltMaskBorder() const;
280  virtual int getKltNbPoints() const;
281 
282  virtual vpKltOpencv getKltOpencv() const;
283  virtual void getKltOpencv(vpKltOpencv &klt1, vpKltOpencv &klt2) const;
284  virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts) const;
285 
286 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
287  virtual std::vector<cv::Point2f> getKltPoints() const;
288 #endif
289 
290  virtual double getKltThresholdAcceptation() const;
291 #endif
292 
293  virtual void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList, unsigned int level = 0) const;
294  virtual void getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
295  unsigned int level = 0) const;
296  virtual void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList, unsigned int level = 0) const;
297  virtual void getLcylinder(const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
298  unsigned int level = 0) const;
299  virtual void getLline(std::list<vpMbtDistanceLine *> &linesList, unsigned int level = 0) const;
300  virtual void getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
301  unsigned int level = 0) const;
302 
303  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
304  const vpHomogeneousMatrix &cMo,
305  const vpCameraParameters &cam,
306  bool displayFullModel = false) vp_override;
307  virtual void getModelForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfModels,
308  const std::map<std::string, unsigned int> &mapOfwidths,
309  const std::map<std::string, unsigned int> &mapOfheights,
310  const std::map<std::string, vpHomogeneousMatrix> &mapOfcMos,
311  const std::map<std::string, vpCameraParameters> &mapOfCams,
312  bool displayFullModel = false);
313 
314  virtual vpMe getMovingEdge() const;
315  virtual void getMovingEdge(vpMe &me1, vpMe &me2) const;
316  virtual void getMovingEdge(std::map<std::string, vpMe> &mapOfMovingEdges) const;
317 
321  virtual inline unsigned int getNbFeaturesDepthDense() const { return m_nb_feat_depthDense; }
322 
326  virtual inline unsigned int getNbFeaturesDepthNormal() const { return m_nb_feat_depthNormal; }
327 
333  virtual inline unsigned int getNbFeaturesEdge() const { return m_nb_feat_edge; }
334 
338  virtual inline unsigned int getNbFeaturesKlt() const { return m_nb_feat_klt; }
339 
340  virtual unsigned int getNbPoints(unsigned int level = 0) const;
341  virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints, unsigned int level = 0) const;
342 
343  virtual unsigned int getNbPolygon() const vp_override;
344  virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons) const;
345 
346  virtual vpMbtPolygon *getPolygon(unsigned int index) vp_override;
347  virtual vpMbtPolygon *getPolygon(const std::string &cameraName, unsigned int index);
348 
349  virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
350  getPolygonFaces(bool orderPolygons = true, bool useVisibility = true, bool clipPolygon = false) vp_override;
351  virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
352  std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
353  bool orderPolygons = true, bool useVisibility = true, bool clipPolygon = false);
354 
355  using vpMbTracker::getPose;
356  virtual void getPose(vpHomogeneousMatrix &cMo) const vp_override;
357  virtual void getPose(vpHomogeneousMatrix &c1Mo, vpHomogeneousMatrix &c2Mo) const;
358  virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const;
359 
360  virtual std::string getReferenceCameraName() const;
361 
362  virtual inline vpColVector getRobustWeights() const vp_override { return m_w; }
363 
364  virtual int getTrackerType() const;
365 
366  virtual void init(const vpImage<unsigned char> &I) vp_override;
367 
368 #ifdef VISP_HAVE_MODULE_GUI
370  virtual void initClick(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
371  const std::string &initFile1, const std::string &initFile2, bool displayHelp = false,
374  virtual void initClick(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2, const std::string &initFile1,
375  const std::string &initFile2, bool displayHelp = false,
378 
379  virtual void
380  initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
381  const std::map<std::string, std::string> &mapOfInitFiles, bool displayHelp = false,
382  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
383  virtual void
384  initClick(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
385  const std::map<std::string, std::string> &mapOfInitFiles, bool displayHelp = false,
386  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
387 #endif
388 
390  virtual void initFromPoints(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
391  const std::string &initFile1, const std::string &initFile2);
392  virtual void initFromPoints(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
393  const std::string &initFile1, const std::string &initFile2);
394 
395  virtual void initFromPoints(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
396  const std::map<std::string, std::string> &mapOfInitPoints);
397  virtual void initFromPoints(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
398  const std::map<std::string, std::string> &mapOfInitPoints);
399 
401  virtual void initFromPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo) vp_override;
402  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
403  const std::string &initFile1, const std::string &initFile2);
404  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
405  const std::string &initFile1, const std::string &initFile2);
406 
407  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
408  const std::map<std::string, std::string> &mapOfInitPoses);
409  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
410  const std::map<std::string, std::string> &mapOfInitPoses);
411 
412  virtual void initFromPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
413  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
414  virtual void initFromPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
415  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
416 
417  virtual void initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
418  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
419  virtual void initFromPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
420  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
421 
422  virtual void loadConfigFile(const std::string &configFile, bool verbose = true) vp_override;
423  virtual void loadConfigFile(const std::string &configFile1, const std::string &configFile2, bool verbose = true);
424  virtual void loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles, bool verbose = true);
425 
426 #ifdef VISP_HAVE_NLOHMANN_JSON
427  virtual void saveConfigFile(const std::string &settingsFile) const;
428 #endif
429 
430  virtual void loadModel(const std::string &modelFile, bool verbose = false,
431  const vpHomogeneousMatrix &T = vpHomogeneousMatrix()) vp_override;
432  virtual void loadModel(const std::string &modelFile1, const std::string &modelFile2, bool verbose = false,
435 
436  virtual void
437  loadModel(const std::map<std::string, std::string> &mapOfModelFiles, bool verbose = false,
438  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
439 
440  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo,
441  bool verbose = false, const vpHomogeneousMatrix &T = vpHomogeneousMatrix());
442  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name, const vpHomogeneousMatrix &cMo,
443  bool verbose = false, const vpHomogeneousMatrix &T = vpHomogeneousMatrix());
444 
445  virtual void reInitModel(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
446  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
447  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
450  virtual void reInitModel(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
451  const std::string &cad_name1, const std::string &cad_name2, const vpHomogeneousMatrix &c1Mo,
452  const vpHomogeneousMatrix &c2Mo, bool verbose = false,
455 
456  virtual void
457  reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
458  const std::map<std::string, std::string> &mapOfModelFiles,
459  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses, bool verbose = false,
460  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
461  virtual void
462  reInitModel(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
463  const std::map<std::string, std::string> &mapOfModelFiles,
464  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses, bool verbose = false,
465  const std::map<std::string, vpHomogeneousMatrix> &mapOfT = std::map<std::string, vpHomogeneousMatrix>());
466 
467  virtual void resetTracker() vp_override;
468 
469  virtual void setAngleAppear(const double &a) vp_override;
470  virtual void setAngleAppear(const double &a1, const double &a2);
471  virtual void setAngleAppear(const std::map<std::string, double> &mapOfAngles);
472 
473  virtual void setAngleDisappear(const double &a) vp_override;
474  virtual void setAngleDisappear(const double &a1, const double &a2);
475  virtual void setAngleDisappear(const std::map<std::string, double> &mapOfAngles);
476 
477  virtual void setCameraParameters(const vpCameraParameters &camera) vp_override;
478  virtual void setCameraParameters(const vpCameraParameters &camera1, const vpCameraParameters &camera2);
479  virtual void setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
480 
481  virtual void setCameraTransformationMatrix(const std::string &cameraName,
482  const vpHomogeneousMatrix &cameraTransformationMatrix);
483  virtual void
484  setCameraTransformationMatrix(const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
485 
486  virtual void setClipping(const unsigned int &flags) vp_override;
487  virtual void setClipping(const unsigned int &flags1, const unsigned int &flags2);
488  virtual void setClipping(const std::map<std::string, unsigned int> &mapOfClippingFlags);
489 
490  virtual void setDepthDenseFilteringMaxDistance(double maxDistance);
491  virtual void setDepthDenseFilteringMethod(int method);
492  virtual void setDepthDenseFilteringMinDistance(double minDistance);
493  virtual void setDepthDenseFilteringOccupancyRatio(double occupancyRatio);
494  virtual void setDepthDenseSamplingStep(unsigned int stepX, unsigned int stepY);
495 
496  virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method);
497  virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method);
498  virtual void setDepthNormalPclPlaneEstimationMethod(int method);
499  virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter);
500  virtual void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold);
501  virtual void setDepthNormalSamplingStep(unsigned int stepX, unsigned int stepY);
502 
503  virtual void setDisplayFeatures(bool displayF) vp_override;
504 
505  virtual void setFarClippingDistance(const double &dist) vp_override;
506  virtual void setFarClippingDistance(const double &dist1, const double &dist2);
507  virtual void setFarClippingDistance(const std::map<std::string, double> &mapOfClippingDists);
508 
509  virtual void setFeatureFactors(const std::map<vpTrackerType, double> &mapOfFeatureFactors);
510 
511  virtual void setGoodMovingEdgesRatioThreshold(double threshold);
512 
513 #ifdef VISP_HAVE_OGRE
514  virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio);
515  virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts);
516 #endif
517 
518 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
519  virtual void setKltMaskBorder(const unsigned int &e);
520  virtual void setKltMaskBorder(const unsigned int &e1, const unsigned int &e2);
521  virtual void setKltMaskBorder(const std::map<std::string, unsigned int> &mapOfErosions);
522 
523  virtual void setKltOpencv(const vpKltOpencv &t);
524  virtual void setKltOpencv(const vpKltOpencv &t1, const vpKltOpencv &t2);
525  virtual void setKltOpencv(const std::map<std::string, vpKltOpencv> &mapOfKlts);
526 
527  virtual void setKltThresholdAcceptation(double th);
528 #endif
529 
530  virtual void setLod(bool useLod, const std::string &name = "") vp_override;
531 
532  virtual void setMask(const vpImage<bool> &mask) vp_override;
533 
534  virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name = "") vp_override;
535  virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name = "") vp_override;
536 
537  virtual void setMovingEdge(const vpMe &me);
538  virtual void setMovingEdge(const vpMe &me1, const vpMe &me2);
539  virtual void setMovingEdge(const std::map<std::string, vpMe> &mapOfMe);
540 
541  virtual void setNearClippingDistance(const double &dist) vp_override;
542  virtual void setNearClippingDistance(const double &dist1, const double &dist2);
543  virtual void setNearClippingDistance(const std::map<std::string, double> &mapOfDists);
544 
545  virtual void setOgreShowConfigDialog(bool showConfigDialog) vp_override;
546  virtual void setOgreVisibilityTest(const bool &v) vp_override;
547 
548  virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt) vp_override;
549 
550  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo) vp_override;
551  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo) vp_override;
552 
553  virtual void setPose(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2,
554  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
555  virtual void setPose(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2,
556  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo);
557 
558  virtual void setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
559  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
560  virtual void setPose(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
561  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
562 
563  virtual void setProjectionErrorComputation(const bool &flag) vp_override;
564 
565  virtual void setProjectionErrorDisplay(bool display) vp_override;
566  virtual void setProjectionErrorDisplayArrowLength(unsigned int length) vp_override;
567  virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness) vp_override;
568 
569  virtual void setReferenceCameraName(const std::string &referenceCameraName);
570 
571  virtual void setScanLineVisibilityTest(const bool &v) vp_override;
572 
573  virtual void setTrackerType(int type);
574  virtual void setTrackerType(const std::map<std::string, int> &mapOfTrackerTypes);
575 
576  virtual void setUseDepthDenseTracking(const std::string &name, const bool &useDepthDenseTracking);
577  virtual void setUseDepthNormalTracking(const std::string &name, const bool &useDepthNormalTracking);
578  virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking);
579 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
580  virtual void setUseKltTracking(const std::string &name, const bool &useKltTracking);
581 #endif
582 
583  virtual void testTracking() vp_override;
584 
585  virtual void track(const vpImage<unsigned char> &I) vp_override;
586  virtual void track(const vpImage<vpRGBa> &I_color) vp_override;
587 
588  virtual void track(const vpImage<unsigned char> &I1, const vpImage<unsigned char> &I2);
589  virtual void track(const vpImage<vpRGBa> &I_color1, const vpImage<vpRGBa> &I_color2);
590 
591  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
592  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages);
593 
594 #ifdef VISP_HAVE_PCL
595  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
596  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
597  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
598  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
599 #endif
600 
601  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
602  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
603  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
604  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
605  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
606  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
607  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
608  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
609 
610  virtual void track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
611  std::map<std::string, const vpMatrix *> &mapOfPointClouds,
612  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
613  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
614  virtual void track(std::map<std::string, const vpImage<vpRGBa> *> &mapOfColorImages,
615  std::map<std::string, const vpMatrix *> &mapOfPointClouds,
616  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
617  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
618 
619 protected:
620  virtual void computeProjectionError();
621 
622  virtual void computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
623 
624  virtual void computeVVSInit() vp_override;
625  virtual void computeVVSInit(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages);
626  virtual void computeVVSInteractionMatrixAndResidu() vp_override;
627  virtual void computeVVSInteractionMatrixAndResidu(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
628  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
629  using vpMbTracker::computeVVSWeights;
630  virtual void computeVVSWeights();
631 
632  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace = 0,
633  const std::string &name = "") vp_override;
634 
635  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
636  const std::string &name = "") vp_override;
637 
638  virtual void initFaceFromCorners(vpMbtPolygon &polygon) vp_override;
639 
640  virtual void initFaceFromLines(vpMbtPolygon &polygon) vp_override;
641 
642  virtual void loadConfigFileXML(const std::string &configFile, bool verbose = true);
643 #ifdef VISP_HAVE_NLOHMANN_JSON
644  virtual void loadConfigFileJSON(const std::string &configFile, bool verbose = true);
645 #endif
646 
647 #ifdef VISP_HAVE_PCL
648  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
649  std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
650 #endif
651  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
652  std::map<std::string, const std::vector<vpColVector> *> &mapOfPointClouds,
653  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
654  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
655  virtual void preTracking(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
656  std::map<std::string, const vpMatrix *> &mapOfPointClouds,
657  std::map<std::string, unsigned int> &mapOfPointCloudWidths,
658  std::map<std::string, unsigned int> &mapOfPointCloudHeights);
659 
660 private:
661  class TrackerWrapper : public vpMbEdgeTracker,
662 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
663  public vpMbKltTracker,
664 #endif
665  public vpMbDepthNormalTracker,
666  public vpMbDepthDenseTracker
667  {
668  friend class vpMbGenericTracker;
669 #ifdef VISP_HAVE_NLOHMANN_JSON
670  friend void to_json(nlohmann::json &j, const TrackerWrapper &t);
671  friend void from_json(const nlohmann::json &j, TrackerWrapper &t);
672 #endif
673 
674  public:
678  vpMatrix m_L;
680  int m_trackerType;
685 
686  TrackerWrapper();
687  explicit TrackerWrapper(int trackerType);
688 
689  virtual inline vpColVector getError() const vp_override { return m_error; }
690 
691  virtual inline vpColVector getRobustWeights() const vp_override { return m_w; }
692 
693  virtual inline int getTrackerType() const { return m_trackerType; }
694 
695  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
696  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false) vp_override;
697  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
698  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false) vp_override;
699 
700  virtual std::vector<std::vector<double> > getFeaturesForDisplay();
701 
702  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
703  const vpHomogeneousMatrix &cMo,
704  const vpCameraParameters &cam,
705  bool displayFullModel = false) vp_override;
706 
707  virtual void init(const vpImage<unsigned char> &I) vp_override;
708 
709  virtual void loadConfigFile(const std::string &configFile, bool verbose = true) vp_override;
710 
711  virtual void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
712  const vpHomogeneousMatrix &cMo, bool verbose = false,
713  const vpHomogeneousMatrix &T = vpHomogeneousMatrix()) vp_override;
714  virtual void reInitModel(const vpImage<vpRGBa> &I_color, const std::string &cad_name,
715  const vpHomogeneousMatrix &cMo, bool verbose = false,
717 
718  virtual void resetTracker() vp_override;
719 
720  virtual void setCameraParameters(const vpCameraParameters &camera) vp_override;
721 
722  virtual void setClipping(const unsigned int &flags) vp_override;
723 
724  virtual void setFarClippingDistance(const double &dist) vp_override;
725 
726  virtual void setNearClippingDistance(const double &dist) vp_override;
727 
728  virtual void setOgreVisibilityTest(const bool &v) vp_override;
729 
730  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo) vp_override;
731  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo) vp_override;
732 
733  virtual void setProjectionErrorComputation(const bool &flag) vp_override;
734 
735  virtual void setScanLineVisibilityTest(const bool &v) vp_override;
736 
737  virtual void setTrackerType(int type);
738 
739  virtual void testTracking() vp_override;
740 
741  virtual void track(const vpImage<unsigned char> &I) vp_override;
742  virtual void track(const vpImage<vpRGBa> &I_color) vp_override;
743 #ifdef VISP_HAVE_PCL
744  // Fix error: using declaration ‘using vpMbDepthDenseTracker::setPose’ conflicts with a previous
745  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
746 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
748 #endif
751  virtual void track(const vpImage<unsigned char> *const ptr_I,
752  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
753 #endif
754 
755  protected:
756  virtual void computeVVS(const vpImage<unsigned char> *const ptr_I);
757  virtual void computeVVSInit() vp_override;
758  virtual void computeVVSInit(const vpImage<unsigned char> *const ptr_I);
759  virtual void computeVVSInteractionMatrixAndResidu() vp_override;
761  virtual void computeVVSInteractionMatrixAndResidu(const vpImage<unsigned char> *const ptr_I);
763  virtual void computeVVSWeights() vp_override;
764 
765  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace = 0,
766  const std::string &name = "") vp_override;
767 
768  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
769  const std::string &name = "") vp_override;
770 
771  virtual void initFaceFromCorners(vpMbtPolygon &polygon) vp_override;
772  virtual void initFaceFromLines(vpMbtPolygon &polygon) vp_override;
773 
774  virtual void initMbtTracking(const vpImage<unsigned char> *const ptr_I);
775 
776 #ifdef VISP_HAVE_PCL
777  virtual void postTracking(const vpImage<unsigned char> *const ptr_I,
778  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
779  virtual void preTracking(const vpImage<unsigned char> *const ptr_I,
780  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
781 #endif
782  virtual void postTracking(const vpImage<unsigned char> *const ptr_I = nullptr, const unsigned int pointcloud_width = 0,
783  const unsigned int pointcloud_height = 0);
784  virtual void preTracking(const vpImage<unsigned char> *const ptr_I = nullptr,
785  const std::vector<vpColVector> *const point_cloud = nullptr,
786  const unsigned int pointcloud_width = 0, const unsigned int pointcloud_height = 0);
787  virtual void preTracking(const vpImage<unsigned char> *const ptr_I = nullptr,
788  const vpMatrix *const point_cloud = nullptr,
789  const unsigned int pointcloud_width = 0, const unsigned int pointcloud_height = 0);
790 
791  virtual void reInitModel(const vpImage<unsigned char> *const I, const vpImage<vpRGBa> *const I_color,
792  const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose = false,
794 
795 #ifdef VISP_HAVE_PCL
796  // Fix error: using declaration ‘using vpMbDepthDenseTracker::track’ conflicts with a previous
797  // using declaration that occurs with g++ 4.6.3 on Ubuntu 12.04
798 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
800 #endif
802 #endif
803 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
804  virtual void setPose(const vpImage<unsigned char> *I, const vpImage<vpRGBa> *I_color,
805  const vpHomogeneousMatrix &cdMo) vp_override;
806 #else
807  virtual void setPose(const vpImage<unsigned char> *I, const vpImage<vpRGBa> *I_color,
808  const vpHomogeneousMatrix &cdMo);
809 #endif
810  };
811 #ifdef VISP_HAVE_NLOHMANN_JSON
812  friend void to_json(nlohmann::json &j, const TrackerWrapper &t);
813  friend void from_json(const nlohmann::json &j, TrackerWrapper &t);
814 #endif
815 
816 protected:
823  std::map<std::string, vpHomogeneousMatrix> m_mapOfCameraTransformationMatrix;
825  std::map<vpTrackerType, double> m_mapOfFeatureFactors;
828  std::map<std::string, TrackerWrapper *> m_mapOfTrackers;
841 
843  unsigned int m_nb_feat_edge;
845  unsigned int m_nb_feat_klt;
847  unsigned int m_nb_feat_depthNormal;
849  unsigned int m_nb_feat_depthDense;
850 };
851 
852 #ifdef VISP_HAVE_NLOHMANN_JSON
853 
854 #define MBT_JSON_SETTINGS_VERSION "1.0"
855 
856 // Serialize tracker type enumeration
857 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
858 NLOHMANN_JSON_SERIALIZE_ENUM(vpMbGenericTracker::vpTrackerType, {
863  });
864 #else
865 NLOHMANN_JSON_SERIALIZE_ENUM(vpMbGenericTracker::vpTrackerType, {
869  });
870 #endif
871 
878 inline void to_json(nlohmann::json &j, const vpMbGenericTracker::TrackerWrapper &t)
879 {
880  // Common tracker attributes
881  const static std::vector<vpMbGenericTracker::vpTrackerType> trackerTypes = {
883  #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
885  #endif
888  };
889  j = nlohmann::json {
890  {"camera", t.m_cam},
891  {"type", flagsToJSON(t.m_trackerType, trackerTypes)},
892  {"angleAppear", vpMath::deg(t.getAngleAppear())},
893  {"angleDisappear", vpMath::deg(t.getAngleDisappear())},
894  {"lod", {
895  {"useLod", t.useLodGeneral},
896  {"minLineLengthThresholdGeneral", t.minLineLengthThresholdGeneral},
897  {"minPolygonAreaThresholdGeneral", t.minPolygonAreaThresholdGeneral}
898  }},
899  {"display", {
900  {"features", t.displayFeatures},
901  {"projectionError", t.m_projectionErrorDisplay}
902  }},
903  {"visibilityTest", {
904  {"ogre", t.useOgre},
905  {"scanline", t.useScanLine}
906  }},
907  {"clipping", {
908  {"flags", clippingFlagsToJSON(t.getClipping())},
909  {"near", t.getNearClippingDistance()},
910  {"far", t.getFarClippingDistance()},
911  }}
912  };
913  //Check tracker type: for each type, add settings to json if the tracker t does use the features
914  //Edge tracker settings
915  if (t.m_trackerType & vpMbGenericTracker::EDGE_TRACKER) {
916  j["edge"] = t.me;
917  }
918  //KLT tracker settings
919 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
920  if (t.m_trackerType & vpMbGenericTracker::KLT_TRACKER) {
921  nlohmann::json klt = nlohmann::json {
922  {"maxFeatures", t.tracker.getMaxFeatures()},
923  {"windowSize", t.tracker.getWindowSize()},
924  {"quality", t.tracker.getQuality()},
925  {"minDistance", t.tracker.getMinDistance()},
926  {"harris", t.tracker.getHarrisFreeParameter()},
927  {"blockSize", t.tracker.getBlockSize()},
928  {"pyramidLevels", t.tracker.getPyramidLevels()}
929  };
930  klt["maskBorder"] = t.maskBorder;
931  j["klt"] = klt;
932  }
933 #endif
934  //Depth normal settings
935  if (t.m_trackerType & vpMbGenericTracker::DEPTH_NORMAL_TRACKER) {
936  j["normals"] = nlohmann::json {
937  {"featureEstimationMethod", t.m_depthNormalFeatureEstimationMethod},
938  {"pcl", {
939  {"method", t.m_depthNormalPclPlaneEstimationMethod},
940  {"ransacMaxIter", t.m_depthNormalPclPlaneEstimationRansacMaxIter},
941  {"ransacThreshold", t.m_depthNormalPclPlaneEstimationRansacThreshold}
942  }},
943  {"sampling", {
944  {"x", t.m_depthNormalSamplingStepX},
945  {"y", t.m_depthNormalSamplingStepY}
946  }}
947  };
948  }
949  //Depth dense settings
950  if (t.m_trackerType & vpMbGenericTracker::DEPTH_DENSE_TRACKER) {
951  j["dense"] = {
952  {"sampling", {
953  {"x", t.m_depthDenseSamplingStepX},
954  {"y", t.m_depthDenseSamplingStepY}
955  }}
956  };
957  }
958 }
979 inline void from_json(const nlohmann::json &j, vpMbGenericTracker::TrackerWrapper &t)
980 {
981  t.setCameraParameters(j.at("camera"));
982  t.setTrackerType(flagsFromJSON<vpMbGenericTracker::vpTrackerType>(j.at("type")));
983  //Load base settings
984  if (j.contains("angleAppear")) {
985  t.setAngleAppear(vpMath::rad(static_cast<double>(j.at("angleAppear"))));
986  }
987  if (j.contains("angleDisappear")) {
988  t.setAngleDisappear(vpMath::rad(static_cast<double>(j.at("angleDisappear"))));
989  }
990  if (j.contains("clipping")) {
991  const nlohmann::json clipping = j["clipping"];
992  t.setNearClippingDistance(clipping.value("near", t.getNearClippingDistance()));
993  t.setFarClippingDistance(clipping.value("far", t.getFarClippingDistance()));
994  if (clipping.contains("flags")) {
995  t.setClipping(flagsFromJSON<vpPolygon3D::vpPolygon3DClippingType>(clipping.at("flags")));
996  }
997  }
998  if (j.contains("lod")) {
999  const nlohmann::json lod = j["lod"];
1000  t.useLodGeneral = lod.value("useLod", t.useLodGeneral);
1001  t.minLineLengthThresholdGeneral = lod.value("minLineLengthThresholdGeneral", t.minLineLengthThresholdGeneral);
1002  t.minPolygonAreaThresholdGeneral = lod.value("minPolygonAreaThresholdGeneral", t.minPolygonAreaThresholdGeneral);
1003  t.applyLodSettingInConfig = false;
1004  if (t.getNbPolygon() > 0) {
1005  t.applyLodSettingInConfig = true;
1006  t.setLod(t.useLodGeneral);
1007  t.setMinLineLengthThresh(t.minLineLengthThresholdGeneral);
1008  t.setMinPolygonAreaThresh(t.minPolygonAreaThresholdGeneral);
1009  }
1010  }
1011  if (j.contains("display")) {
1012  const nlohmann::json displayJson = j["display"];
1013  t.setDisplayFeatures(displayJson.value("features", t.displayFeatures));
1014  t.setProjectionErrorDisplay(displayJson.value("projectionError", t.m_projectionErrorDisplay));
1015  }
1016  if (j.contains("visibilityTest")) {
1017  const nlohmann::json visJson = j["visibilityTest"];
1018  t.setOgreVisibilityTest(visJson.value("ogre", t.useOgre));
1019  t.setScanLineVisibilityTest(visJson.value("scanline", t.useScanLine));
1020  }
1021 
1022  //Check tracker type: for each type, load settings for this specific tracker type
1023  //Edge tracker settings
1024  if (t.m_trackerType & vpMbGenericTracker::EDGE_TRACKER) {
1025  from_json(j.at("edge"), t.me);
1026  t.setMovingEdge(t.me);
1027  }
1028  //KLT tracker settings
1029 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
1030  if (t.m_trackerType & vpMbGenericTracker::KLT_TRACKER) {
1031  const nlohmann::json klt = j.at("klt");
1032  auto &ktrack = t.tracker;
1033  ktrack.setMaxFeatures(klt.value("maxFeatures", 10000));
1034  ktrack.setWindowSize(klt.value("windowSize", 5));
1035  ktrack.setQuality(klt.value("quality", 0.01));
1036  ktrack.setMinDistance(klt.value("minDistance", 5));
1037  ktrack.setHarrisFreeParameter(klt.value("harris", 0.01));
1038  ktrack.setBlockSize(klt.value("blockSize", 3));
1039  ktrack.setPyramidLevels(klt.value("pyramidLevels", 3));
1040  t.setMaskBorder(klt.value("maskBorder", t.maskBorder));
1041  t.faces.getMbScanLineRenderer().setMaskBorder(t.maskBorder);
1042  }
1043 #else
1044  if (j.contains("klt")) {
1045  std::cerr << "Trying to load a KLT tracker, but the ViSP dependency requirements are not met. Ignoring." << std::endl;
1046  }
1047 #endif
1048  //Depth normal settings
1049  if (t.m_trackerType & vpMbGenericTracker::DEPTH_NORMAL_TRACKER) {
1050  const nlohmann::json n = j.at("normals");
1051  t.setDepthNormalFeatureEstimationMethod(n.at("featureEstimationMethod"));
1052  if (n.contains("pcl")) {
1053  const nlohmann::json pcl = n["pcl"];
1054  t.setDepthNormalPclPlaneEstimationMethod(pcl.at("method"));
1055  t.setDepthNormalPclPlaneEstimationRansacMaxIter(pcl.at("ransacMaxIter"));
1056  t.setDepthNormalPclPlaneEstimationRansacThreshold(pcl.at("ransacThreshold"));
1057  }
1058  if (n.contains("sampling")) {
1059  const nlohmann::json sampling = n.at("sampling");
1060  t.setDepthNormalSamplingStep(sampling.at("x"), sampling.at("y"));
1061  }
1062  }
1063  //Depth Dense settings
1064  if (t.m_trackerType & vpMbGenericTracker::DEPTH_DENSE_TRACKER) {
1065  const nlohmann::json dense = j.at("dense");
1066  if (dense.contains("sampling")) {
1067  const nlohmann::json sampling = dense.at("sampling");
1068  t.setDepthDenseSamplingStep(sampling.at("x"), sampling.at("y"));
1069  }
1070  }
1071 }
1072 
1073 #endif
1074 
1075 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:152
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
Definition: vpImage.h:69
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition: vpKltOpencv.h:73
static double rad(double deg)
Definition: vpMath.h:127
static double deg(double rad)
Definition: vpMath.h:117
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
virtual void track(const vpImage< unsigned char > &) vp_override
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo) vp_override
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo) vp_override
virtual void track(const vpImage< unsigned char > &) vp_override
Make the complete tracking of an object by using its CAD model.
virtual void track(const vpImage< unsigned char > &I) vp_override
Real-time 6D object pose tracking using its CAD model.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo) vp_override
virtual std::vector< std::vector< double > > getFeaturesForDisplay()
virtual int getTrackerType() const
std::map< std::string, TrackerWrapper * > m_mapOfTrackers
virtual void loadConfigFile(const std::string &configFile, bool verbose=true) vp_override
unsigned int m_nb_feat_edge
Number of moving-edges features.
virtual unsigned int getNbFeaturesEdge() const
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false) vp_override
friend void to_json(nlohmann::json &j, const TrackerWrapper &t)
Serialize a tracker wrapper's settings into a JSON representation.
vpColVector m_w
Robust weights.
virtual void initFaceFromLines(vpMbtPolygon &polygon) vp_override
virtual unsigned int getNbFeaturesKlt() const
unsigned int m_nb_feat_depthDense
Number of depth dense features.
virtual void setOgreVisibilityTest(const bool &v) vp_override
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 computeVVSInteractionMatrixAndResidu() vp_override
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false) vp_override
virtual void initFaceFromCorners(vpMbtPolygon &polygon) vp_override
virtual void computeVVSInit() vp_override
vpColVector m_weightedError
Weighted error.
virtual void init(const vpImage< unsigned char > &I) vp_override
vpMatrix m_L
Interaction matrix.
virtual void setFarClippingDistance(const double &dist) vp_override
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="") vp_override
virtual void computeVVSWeights()
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="") vp_override
virtual void testTracking() vp_override
virtual void setNearClippingDistance(const double &dist) vp_override
virtual void setScanLineVisibilityTest(const bool &v) vp_override
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 resetTracker() vp_override
virtual void setCameraParameters(const vpCameraParameters &camera) vp_override
virtual void setTrackerType(int type)
unsigned int m_nb_feat_klt
Number of klt features.
unsigned int m_nb_feat_depthNormal
Number of depth normal features.
virtual void setClipping(const unsigned int &flags) vp_override
virtual void preTracking(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
virtual void setProjectionErrorComputation(const bool &flag) vp_override
virtual vpColVector getError() const vp_override
virtual void track(const vpImage< unsigned char > &I) vp_override
std::string m_referenceCameraName
Name of the reference camera.
friend void from_json(const nlohmann::json &j, TrackerWrapper &t)
Load configuration settings from a JSON object for a tracker wrapper.
virtual vpColVector getRobustWeights() const vp_override
Model based tracker using only KLT.
Main methods for a model-based tracker.
Definition: vpMbTracker.h:105
virtual void track(const vpImage< unsigned char > &I)=0
virtual void init(const vpImage< unsigned char > &I)=0
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
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 setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Definition: vpMbTracker.h:634
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
Definition: vpMbTracker.h:332
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 unsigned int getNbPolygon() const
Definition: vpMbTracker.h:368
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Definition: vpMbTracker.h:624
virtual void computeVVSInit()=0
virtual void testTracking()=0
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:58
Definition: vpMe.h:124
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:77
Defines a generic 2D polygon.
Definition: vpPolygon.h:97
Definition: vpRGBa.h:61