Visual Servoing Platform  version 3.3.1 under development (2020-09-18)
vpMbDepthNormalTracker.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Model-based tracker using depth normal features.
33  *
34  *****************************************************************************/
35 
36 #ifndef _vpMbDepthNormalTracker_h_
37 #define _vpMbDepthNormalTracker_h_
38 
39 #include <visp3/core/vpConfig.h>
40 #include <visp3/core/vpPlane.h>
41 #include <visp3/mbt/vpMbTracker.h>
42 #include <visp3/mbt/vpMbtFaceDepthNormal.h>
43 
44 #if DEBUG_DISPLAY_DEPTH_NORMAL
45 #include <visp3/core/vpDisplay.h>
46 #endif
47 
48 class VISP_EXPORT vpMbDepthNormalTracker : public virtual vpMbTracker
49 {
50 public:
52  virtual ~vpMbDepthNormalTracker();
53 
54  virtual void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
55  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
56 
57  virtual void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
58  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
59 
61  {
62  return m_depthNormalFeatureEstimationMethod;
63  }
64 
65  virtual inline vpColVector getError() const { return m_error_depthNormal; }
66 
67  virtual std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
68  const vpHomogeneousMatrix &cMo,
69  const vpCameraParameters &cam,
70  bool displayFullModel=false);
71 
72  virtual inline vpColVector getRobustWeights() const { return m_w_depthNormal; }
73 
74  virtual void init(const vpImage<unsigned char> &I);
75 
76  virtual void loadConfigFile(const std::string &configFile);
77 
78  void reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo,
79  bool verbose = false);
80 #if defined(VISP_HAVE_PCL)
81  void reInitModel(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud, const std::string &cad_name,
82  const vpHomogeneousMatrix &cMo, bool verbose = false);
83 #endif
84 
85  virtual void resetTracker();
86 
87  virtual void setCameraParameters(const vpCameraParameters &camera);
88 
89  virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method);
90 
91  virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method);
92 
93  virtual void setDepthNormalPclPlaneEstimationMethod(int method);
94 
95  virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter);
96 
97  virtual void setDepthNormalPclPlaneEstimationRansacThreshold(double thresold);
98 
99  virtual void setDepthNormalSamplingStep(unsigned int stepX, unsigned int stepY);
100 
101  // virtual void setDepthNormalUseRobust(bool use);
102 
103  virtual void setOgreVisibilityTest(const bool &v);
104 
105  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cdMo);
106  virtual void setPose(const vpImage<vpRGBa> &I_color, const vpHomogeneousMatrix &cdMo);
107 #if defined(VISP_HAVE_PCL)
108  virtual void setPose(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud, const vpHomogeneousMatrix &cdMo);
109 #endif
110 
111  virtual void setScanLineVisibilityTest(const bool &v);
112 
113  void setUseDepthNormalTracking(const std::string &name, const bool &useDepthNormalTracking);
114 
115  virtual void testTracking();
116 
117  virtual void track(const vpImage<unsigned char> &);
118  virtual void track(const vpImage<vpRGBa> &I_color);
119 #if defined(VISP_HAVE_PCL)
120  virtual void track(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
121 #endif
122  virtual void track(const std::vector<vpColVector> &point_cloud, unsigned int width, unsigned int height);
123 
124 protected:
130  std::vector<vpMbtFaceDepthNormal *> m_depthNormalListOfActiveFaces;
132  std::vector<vpColVector> m_depthNormalListOfDesiredFeatures;
134  std::vector<vpMbtFaceDepthNormal *> m_depthNormalFaces;
150  std::vector<std::vector<double> > m_featuresToBeDisplayedDepthNormal;
159 #if DEBUG_DISPLAY_DEPTH_NORMAL
160  vpDisplay *m_debugDisp_depthNormal;
161  vpImage<unsigned char> m_debugImage_depthNormal;
162 #endif
163 
164  void addFace(vpMbtPolygon &polygon, bool alreadyClose);
165 
166  void computeVisibility(unsigned int width, unsigned int height);
167 
168  void computeVVS();
169  virtual void computeVVSInit();
171 
172  virtual std::vector<std::vector<double> > getFeaturesForDisplayDepthNormal();
173 
174  virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius,
175  int idFace = 0, const std::string &name = "");
176 
177  virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace = 0,
178  const std::string &name = "");
179 
180  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
181 
182  virtual void initFaceFromLines(vpMbtPolygon &polygon);
183 
184 #ifdef VISP_HAVE_PCL
185  void segmentPointCloud(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
186 #endif
187  void segmentPointCloud(const std::vector<vpColVector> &point_cloud, unsigned int width,
188  unsigned int height);
189 };
190 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:156
vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod
Method to estimate the desired features.
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:177
virtual void track(const vpImage< unsigned char > &I)=0
virtual void computeVVSInteractionMatrixAndResidu()=0
bool m_depthNormalUseRobust
If true, use Tukey robust M-Estimator.
virtual void computeVVSInit()=0
vpColVector m_w_depthNormal
Robust weights.
Implementation of an homogeneous matrix and operations on such kind of matrices.
int m_depthNormalPclPlaneEstimationRansacMaxIter
PCL RANSAC maximum number of iterations.
virtual void loadConfigFile(const std::string &configFile)
vpColVector m_error_depthNormal
(s - s*)
Class to define RGB colors available for display functionnalities.
Definition: vpColor.h:157
std::vector< vpColVector > m_depthNormalListOfDesiredFeatures
List of desired features.
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")=0
virtual void resetTracker()=0
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)=0
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:81
virtual void init(const vpImage< unsigned char > &I)=0
vpColVector m_weightedError_depthNormal
Weighted error.
virtual void setCameraParameters(const vpCameraParameters &cam)
Definition: vpMbTracker.h:483
unsigned int m_depthNormalSamplingStepX
Sampling step in x-direction.
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:66
double m_depthNormalPclPlaneEstimationRansacThreshold
PCL RANSAC threshold.
std::vector< std::vector< double > > m_featuresToBeDisplayedDepthNormal
Display features.
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
Definition: vpMbTracker.h:104
unsigned int m_depthNormalSamplingStepY
Sampling step in y-direction.
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)=0
vpMatrix m_L_depthNormal
Interaction matrix.
vpRobust m_robust_depthNormal
Robust.
virtual void setOgreVisibilityTest(const bool &v)
std::vector< vpMbtFaceDepthNormal * > m_depthNormalFaces
List of faces.
virtual vpColVector getRobustWeights() const
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")=0
int m_depthNormalPclPlaneEstimationMethod
PCL plane estimation method.
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void testTracking()=0
std::vector< vpMbtFaceDepthNormal * > m_depthNormalListOfActiveFaces
List of current active (visible and with features extracted) faces.
Contains an M-Estimator and various influence function.
Definition: vpRobust.h:58
virtual vpColVector getError() const
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:597
vpMbHiddenFaces< vpMbtPolygon > m_depthNormalHiddenFacesDisplay
Set of faces describing the object used only for display with scan line.
virtual vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthFeatureEstimationMethod() const