Visual Servoing Platform  version 3.5.0
vpMbtDistanceLine.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  * Manage the line of a polygon used in the model-based tracker.
33  *
34  * Authors:
35  * Nicolas Melchior
36  * Romain Tallonneau
37  * Eric Marchand
38  *
39  *****************************************************************************/
40 
46 #ifndef vpMbtDistanceLine_HH
47 #define vpMbtDistanceLine_HH
48 
49 #include <visp3/core/vpHomogeneousMatrix.h>
50 #include <visp3/core/vpLine.h>
51 #include <visp3/core/vpPoint.h>
52 #include <visp3/core/vpUniRand.h>
53 #include <visp3/mbt/vpMbHiddenFaces.h>
54 #include <visp3/mbt/vpMbtMeLine.h>
55 #include <visp3/visual_features/vpFeatureLine.h>
56 
57 #include <list>
58 
67 class VISP_EXPORT vpMbtDistanceLine
68 {
69 private:
70  std::string name;
71  unsigned int index;
73  vpMe *me;
74  bool isTrackedLine;
75  bool isTrackedLineWithVisibility;
76  double wmean;
77  vpFeatureLine featureline;
79  vpMbtPolygon poly;
80 
81 public:
85  // vpMbtMeLine *meline;
86  std::vector<vpMbtMeLine *> meline;
98  // unsigned int nbFeature;
99  std::vector<unsigned int> nbFeature;
101  unsigned int nbFeatureTotal;
103  bool Reinit;
107  std::list<int> Lindex_polygon;
110  std::vector<bool> Lindex_polygon_tracked;
112  bool isvisible;
113 
114  // private:
115  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
116  // vpMbtDistanceLine(const vpMbtDistanceLine &)
117  // : name(), index(0), cam(), me(NULL), isTrackedLine(true),
118  // isTrackedLineWithVisibility(true),
119  // wmean(1), featureline(), poly(), useScanLine(false), meline(),
120  // line(NULL), p1(NULL), p2(NULL), L(), error(), nbFeature(),
121  // nbFeatureTotal(0), Reinit(false), hiddenface(NULL),
122  // Lindex_polygon(), Lindex_polygon_tracked(), isvisible(false)
123  // {
124  // throw vpException(vpException::functionNotImplementedError, "Not
125  // implemented!");
126  // }
127  // vpMbtDistanceLine &operator=(const vpMbtDistanceLine &){
128  // throw vpException(vpException::functionNotImplementedError, "Not
129  // implemented!"); return *this;
130  // }
131  //#endif
132 
133 public:
135  virtual ~vpMbtDistanceLine();
136 
137  void addPolygon(const int &index);
138 
139  void buildFrom(vpPoint &_p1, vpPoint &_p2, vpUniRand& rand_gen);
140 
141  bool closeToImageBorder(const vpImage<unsigned char> &I, const unsigned int threshold);
142  void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo);
143 
144  void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
145  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
146  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
147  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
148  void displayMovingEdges(const vpImage<unsigned char> &I);
149  void displayMovingEdges(const vpImage<vpRGBa> &I);
150 
156  inline void getCameraParameters(vpCameraParameters &camera) const { camera = this->cam; }
157 
163  inline unsigned int getIndex() const { return index; }
164 
172  inline double getMeanWeight() const { return wmean; }
173 
174  std::vector<std::vector<double> > getFeaturesForDisplay();
175 
176  std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
177  const vpHomogeneousMatrix &cMo,
178  const vpCameraParameters &cam,
179  bool displayFullModel = false);
180 
186  inline std::string getName() const { return name; }
187 
193  inline vpMbtPolygon &getPolygon() { return poly; }
194 
195  void initInteractionMatrixError();
196 
197  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, bool doNotTrack,
198  const vpImage<bool> *mask = NULL);
199 
205  inline bool isTracked() const { return isTrackedLineWithVisibility; }
206 
212  inline bool isVisible() const { return isvisible; }
213 
214  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo,
215  const vpImage<bool> *mask = NULL);
216 
221  inline void setCameraParameters(const vpCameraParameters &camera) { this->cam = camera; }
222 
228  inline void setIndex(unsigned int i) { index = i; }
229 
235  inline void setMeanWeight(double w_mean) { this->wmean = w_mean; }
236 
237  void setMovingEdge(vpMe *Me);
238 
244  inline void setName(const std::string &line_name) { this->name = line_name; }
245 
251  inline void setName(const char *line_name) { this->name = std::string(line_name); }
252 
253  void setTracked(const std::string &name, const bool &track);
254 
261  void setVisible(bool _isvisible) { isvisible = _isvisible; }
262 
263  void trackMovingEdge(const vpImage<unsigned char> &I);
264 
265  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
266 
267  void updateTracked();
268 
269 private:
270  void project(const vpHomogeneousMatrix &cMo);
271 };
272 
273 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
Class to define RGB colors available for display functionnalities.
Definition: vpColor.h:158
Class that defines a 2D line visual feature which is composed by two parameters that are and ,...
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 3D line in the object frame and allows forward projection of the line in the cam...
Definition: vpLine.h:105
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
Manage the line of a polygon used in the model-based tracker.
std::vector< unsigned int > nbFeature
The number of moving edges.
std::vector< bool > Lindex_polygon_tracked
bool isvisible
Indicates if the line is visible or not.
void setIndex(unsigned int i)
vpPoint * p2
The second extremity.
double getMeanWeight() const
vpLine * line
The 3D line.
void getCameraParameters(vpCameraParameters &camera) const
std::list< int > Lindex_polygon
Index of the faces which contain the line.
bool isVisible() const
unsigned int nbFeatureTotal
The number of moving edges.
bool Reinit
Indicates if the line has to be reinitialized.
std::string getName() const
vpColVector error
The error vector.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
bool isTracked() const
bool useScanLine
Use scanline rendering.
vpPoint * p1
The first extremity.
unsigned int getIndex() const
void setName(const char *line_name)
std::vector< vpMbtMeLine * > meline
The moving edge container.
vpMatrix L
The interaction matrix.
void setCameraParameters(const vpCameraParameters &camera)
void setName(const std::string &line_name)
void setMeanWeight(double w_mean)
void setVisible(bool _isvisible)
vpMbtPolygon & getPolygon()
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:67
Definition: vpMe.h:61
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:82
Class for generating random numbers with uniform probability density.
Definition: vpUniRand.h:101