Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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, const unsigned int thickness = 1, const bool displayFullModel = false);
145  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
146  const vpColor &col, const unsigned int thickness = 1, const bool displayFullModel = false);
147  void displayMovingEdges(const vpImage<unsigned char> &I);
148 
154  inline void getCameraParameters(vpCameraParameters &camera) const { camera = this->cam; }
155 
161  inline unsigned int getIndex() const { return index; }
162 
170  inline double getMeanWeight() const { return wmean; }
171 
177  inline std::string getName() const { return name; }
178 
184  inline vpMbtPolygon &getPolygon() { return poly; }
185 
186  void initInteractionMatrixError();
187 
188  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const bool doNotTrack,
189  const vpImage<bool> *mask = NULL);
190 
196  inline bool isTracked() const { return isTrackedLineWithVisibility; }
197 
203  inline bool isVisible() const { return isvisible; }
204 
205  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo,
206  const vpImage<bool> *mask = NULL);
207 
212  inline void setCameraParameters(const vpCameraParameters &camera) { this->cam = camera; }
213 
219  inline void setIndex(const unsigned int i) { index = i; }
220 
226  inline void setMeanWeight(const double w_mean) { this->wmean = w_mean; }
227 
228  void setMovingEdge(vpMe *Me);
229 
235  inline void setName(const std::string &line_name) { this->name = line_name; }
236 
242  inline void setName(const char *line_name) { this->name = std::string(line_name); }
243 
244  void setTracked(const std::string &name, const bool &track);
245 
252  void setVisible(bool _isvisible) { isvisible = _isvisible; }
253 
254  void trackMovingEdge(const vpImage<unsigned char> &I);
255 
256  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
257 
258  void updateTracked();
259 
260 private:
261  void project(const vpHomogeneousMatrix &cMo);
262 };
263 
264 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
void getCameraParameters(vpCameraParameters &camera) 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.
void setName(const char *line_name)
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
std::vector< bool > Lindex_polygon_tracked
vpPoint * p1
The first extremity.
unsigned int getIndex() const
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
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.
bool isVisible() const
Generic class defining intrinsic camera parameters.
Class that defines a 2D line visual feature which is composed by two parameters that are and ...
bool isTracked() const
void setIndex(const unsigned int i)
void setName(const std::string &line_name)
void setCameraParameters(const vpCameraParameters &camera)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
double getMeanWeight() const
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setMeanWeight(const double w_mean)
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.