Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
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/mbt/vpMbHiddenFaces.h>
53 #include <visp3/mbt/vpMbtMeLine.h>
54 #include <visp3/visual_features/vpFeatureLine.h>
55 
56 #include <list>
57 
66 class VISP_EXPORT vpMbtDistanceLine
67 {
68 private:
69  std::string name;
70  unsigned int index;
72  vpMe *me;
73  bool isTrackedLine;
74  bool isTrackedLineWithVisibility;
75  double wmean;
76  vpFeatureLine featureline;
78  vpMbtPolygon poly;
79 
80 public:
84  // vpMbtMeLine *meline;
85  std::vector<vpMbtMeLine *> meline;
97  // unsigned int nbFeature;
98  std::vector<unsigned int> nbFeature;
100  unsigned int nbFeatureTotal;
102  bool Reinit;
106  std::list<int> Lindex_polygon;
109  std::vector<bool> Lindex_polygon_tracked;
111  bool isvisible;
112 
113  // private:
114  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
115  // vpMbtDistanceLine(const vpMbtDistanceLine &)
116  // : name(), index(0), cam(), me(NULL), isTrackedLine(true),
117  // isTrackedLineWithVisibility(true),
118  // wmean(1), featureline(), poly(), useScanLine(false), meline(),
119  // line(NULL), p1(NULL), p2(NULL), L(), error(), nbFeature(),
120  // nbFeatureTotal(0), Reinit(false), hiddenface(NULL),
121  // Lindex_polygon(), Lindex_polygon_tracked(), isvisible(false)
122  // {
123  // throw vpException(vpException::functionNotImplementedError, "Not
124  // implemented!");
125  // }
126  // vpMbtDistanceLine &operator=(const vpMbtDistanceLine &){
127  // throw vpException(vpException::functionNotImplementedError, "Not
128  // implemented!"); return *this;
129  // }
130  //#endif
131 
132 public:
134  virtual ~vpMbtDistanceLine();
135 
136  void addPolygon(const int &index);
137 
138  void buildFrom(vpPoint &_p1, vpPoint &_p2);
139 
140  bool closeToImageBorder(const vpImage<unsigned char> &I, const unsigned int threshold);
141  void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo);
142 
143  void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
144  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
145  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
146  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
147  void displayMovingEdges(const vpImage<unsigned char> &I);
148  void displayMovingEdges(const vpImage<vpRGBa> &I);
149 
155  inline void getCameraParameters(vpCameraParameters &camera) const { camera = this->cam; }
156 
162  inline unsigned int getIndex() const { return index; }
163 
171  inline double getMeanWeight() const { return wmean; }
172 
173  std::vector<std::vector<double> > getFeaturesForDisplay();
174 
175  std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
176  const vpHomogeneousMatrix &cMo,
177  const vpCameraParameters &cam,
178  bool displayFullModel = false);
179 
185  inline std::string getName() const { return name; }
186 
192  inline vpMbtPolygon &getPolygon() { return poly; }
193 
194  void initInteractionMatrixError();
195 
196  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, bool doNotTrack,
197  const vpImage<bool> *mask = NULL);
198 
204  inline bool isTracked() const { return isTrackedLineWithVisibility; }
205 
211  inline bool isVisible() const { return isvisible; }
212 
213  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo,
214  const vpImage<bool> *mask = NULL);
215 
220  inline void setCameraParameters(const vpCameraParameters &camera) { this->cam = camera; }
221 
227  inline void setIndex(unsigned int i) { index = i; }
228 
234  inline void setMeanWeight(double w_mean) { this->wmean = w_mean; }
235 
236  void setMovingEdge(vpMe *Me);
237 
243  inline void setName(const std::string &line_name) { this->name = line_name; }
244 
250  inline void setName(const char *line_name) { this->name = std::string(line_name); }
251 
252  void setTracked(const std::string &name, const bool &track);
253 
260  void setVisible(bool _isvisible) { isvisible = _isvisible; }
261 
262  void trackMovingEdge(const vpImage<unsigned char> &I);
263 
264  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
265 
266  void updateTracked();
267 
268 private:
269  void project(const vpHomogeneousMatrix &cMo);
270 };
271 
272 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
double getMeanWeight() const
unsigned int nbFeatureTotal
The number of moving edges.
void setVisible(bool _isvisible)
vpLine * line
The 3D line.
std::string getName() const
bool Reinit
Indicates if the line has to be reinitialized.
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::list< int > Lindex_polygon
Index of the faces which contain the line.
bool isTracked() const
void setName(const char *line_name)
Class to define colors available for display functionnalities.
Definition: vpColor.h:119
std::vector< bool > Lindex_polygon_tracked
vpPoint * p1
The first extremity.
Definition: vpMe.h:60
Manage the line of a polygon used in the model-based tracker.
vpMbtPolygon & getPolygon()
bool isvisible
Indicates if the line is visible or not.
Class that defines what is a point.
Definition: vpPoint.h:58
Class that defines a line in the object frame, the camera frame and the image plane. All the parameters must be set in meter.
Definition: vpLine.h:105
void setMeanWeight(double w_mean)
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:66
vpPoint * p2
The second extremity.
vpColVector error
The error vector.
Generic class defining intrinsic camera parameters.
Class that defines a 2D line visual feature which is composed by two parameters that are and ...
unsigned int getIndex() const
void setName(const std::string &line_name)
void setCameraParameters(const vpCameraParameters &camera)
bool isVisible() const
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
void getCameraParameters(vpCameraParameters &camera) const
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
std::vector< vpMbtMeLine * > meline
The moving edge container.
vpMatrix L
The interaction matrix.
std::vector< unsigned int > nbFeature
The number of moving edges.
bool useScanLine
Use scanline rendering.
void setIndex(unsigned int i)