Visual Servoing Platform  version 3.1.0
vpMbDepthDenseTracker.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Model-based tracker using depth dense features.
33  *
34  *****************************************************************************/
35 
36 #ifndef __vpMbDepthDenseTracker_h_
37 #define __vpMbDepthDenseTracker_h_
38 
39 #include <visp3/core/vpPlane.h>
40 #include <visp3/mbt/vpMbTracker.h>
41 #include <visp3/mbt/vpMbtFaceDepthDense.h>
42 #include <visp3/mbt/vpMbtTukeyEstimator.h>
43 
44 #if DEBUG_DISPLAY_DEPTH_DENSE
45 #include <visp3/core/vpDisplay.h>
46 #endif
47 
48 class VISP_EXPORT vpMbDepthDenseTracker : public virtual vpMbTracker
49 {
50 public:
52  virtual ~vpMbDepthDenseTracker();
53 
54  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
55  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
56 
57  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
58  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
59 
60  virtual inline vpColVector getError() const { return m_error_depthDense; }
61 
62  virtual inline vpColVector getRobustWeights() const { return m_w_depthDense; }
63 
64  virtual void init(const vpImage<unsigned char> &I);
65 
66  virtual void loadConfigFile(const std::string &configFile);
67 
68  void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_,
69  const bool verbose = false);
70 #if defined(VISP_HAVE_PCL)
71  void reInitModel(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud, const std::string &cad_name,
72  const vpHomogeneousMatrix &cMo_, const bool verbose = false);
73 #endif
74 
75  virtual void resetTracker();
76 
77  virtual void setCameraParameters(const vpCameraParameters &camera);
78 
79  virtual void setDepthDenseFilteringMaxDistance(const double maxDistance);
80  virtual void setDepthDenseFilteringMethod(const int method);
81  virtual void setDepthDenseFilteringMinDistance(const double minDistance);
82  virtual void setDepthDenseFilteringOccupancyRatio(const double occupancyRatio);
83 
84  inline void setDepthDenseSamplingStep(const unsigned int stepX, const unsigned int stepY)
85  {
86  if (stepX == 0 || stepY == 0) {
87  std::cerr << "stepX and stepY must be greater than zero!" << std::endl;
88  return;
89  }
90 
91  m_depthDenseSamplingStepX = stepX;
92  m_depthDenseSamplingStepY = stepY;
93  }
94 
95  virtual void setOgreVisibilityTest(const bool &v);
96 
97  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
98 #ifdef VISP_HAVE_PCL
99  virtual void setPose(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud, const vpHomogeneousMatrix &cdMo);
100 #endif
101 
102  virtual void setScanLineVisibilityTest(const bool &v);
103 
104  virtual void testTracking();
105 
106  virtual void track(const vpImage<unsigned char> &);
107 #ifdef VISP_HAVE_PCL
108  virtual void track(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
109 #endif
110  virtual void track(const std::vector<vpColVector> &point_cloud, const unsigned int width, const unsigned int height);
111 
112 protected:
118  std::vector<vpMbtFaceDepthDense *> m_depthDenseListOfActiveFaces;
122  std::vector<vpMbtFaceDepthDense *> m_depthDenseNormalFaces;
132  vpMbtTukeyEstimator<double> m_robust_depthDense;
137 #if DEBUG_DISPLAY_DEPTH_DENSE
138  vpDisplay *m_debugDisp_depthDense;
139  vpImage<unsigned char> m_debugImage_depthDense;
140 #endif
141 
142  void addFace(vpMbtPolygon &polygon, const bool alreadyClose);
143 
144  void computeVisibility(const unsigned int width, const unsigned int height);
145 
146  void computeVVS();
147  virtual void computeVVSInit();
149  virtual void computeVVSWeights();
151 
152  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius,
153  const int idFace = 0, const std::string &name = "");
154 
155  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace = 0,
156  const std::string &name = "");
157 
158  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
159 
160  virtual void initFaceFromLines(vpMbtPolygon &polygon);
161 
162 #ifdef VISP_HAVE_PCL
163  void segmentPointCloud(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
164 #endif
165  void segmentPointCloud(const std::vector<vpColVector> &point_cloud, const unsigned int width,
166  const unsigned int height);
167 };
168 #endif
vpMbtTukeyEstimator< double > m_robust_depthDense
Tukey M-Estimator.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
vpMbHiddenFaces< vpMbtPolygon > m_depthDenseHiddenFacesDisplay
Set of faces describing the object used only for display with scan line.
virtual vpColVector getRobustWeights() const
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:171
virtual void track(const vpImage< unsigned char > &I)=0
virtual void computeVVSInteractionMatrixAndResidu()=0
virtual void computeVVSInit()=0
vpColVector m_weightedError_depthDense
Weighted error.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")=0
vpColVector m_error_depthDense
(s - s*)
virtual void resetTracker()=0
Class that defines what is a point.
Definition: vpPoint.h:58
virtual void init(const vpImage< unsigned char > &I)=0
unsigned int m_denseDepthNbFeatures
Nb features.
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)=0
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:66
virtual void setCameraParameters(const vpCameraParameters &camera)
Definition: vpMbTracker.h:440
vpMatrix m_L_depthDense
Interaction matrix.
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
Definition: vpMbTracker.h:106
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
unsigned int m_depthDenseSamplingStepX
Sampling step in x-direction.
vpImage< unsigned char > m_depthDenseI_dummyVisibility
Dummy image used to compute the visibility.
virtual void loadConfigFile(const std::string &configFile)=0
virtual void setOgreVisibilityTest(const bool &v)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
void setDepthDenseSamplingStep(const unsigned int stepX, const unsigned int stepY)
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void testTracking()=0
vpColVector m_w_depthDense
Robust weights.
std::vector< vpMbtFaceDepthDense * > m_depthDenseNormalFaces
List of faces.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:533
virtual vpColVector getError() const
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")=0
unsigned int m_depthDenseSamplingStepY
Sampling step in y-direction.
std::vector< vpMbtFaceDepthDense * > m_depthDenseListOfActiveFaces
List of current active (visible and features extracted) faces.