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