Visual Servoing Platform  version 3.0.0
vpMbtDistanceLine.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Manage the line of a polygon used in the model-based tracker.
32  *
33  * Authors:
34  * Nicolas Melchior
35  * Romain Tallonneau
36  * Eric Marchand
37  *
38  *****************************************************************************/
39 
45 #ifndef vpMbtDistanceLine_HH
46 #define vpMbtDistanceLine_HH
47 
48 #include <visp3/core/vpPoint.h>
49 #include <visp3/mbt/vpMbtMeLine.h>
50 #include <visp3/core/vpLine.h>
51 #include <visp3/core/vpHomogeneousMatrix.h>
52 #include <visp3/visual_features/vpFeatureLine.h>
53 #include <visp3/mbt/vpMbHiddenFaces.h>
54 
55 #include <list>
56 
65 class VISP_EXPORT vpMbtDistanceLine
66 {
67  private :
68  std::string name;
69  unsigned int index;
71  vpMe *me;
72  bool isTrackedLine;
73  bool isTrackedLineWithVisibility;
74  double wmean;
75  vpFeatureLine featureline ;
77  vpMbtPolygon poly;
78 
79  public:
83  //vpMbtMeLine *meline;
84  std::vector<vpMbtMeLine*> meline;
96  //unsigned int nbFeature;
97  std::vector<unsigned int> nbFeature;
99  unsigned int nbFeatureTotal;
101  bool Reinit;
105  std::list<int> Lindex_polygon;
107  std::vector<bool> Lindex_polygon_tracked;
109  bool isvisible;
110 
111 //private:
112 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
113 // vpMbtDistanceLine(const vpMbtDistanceLine &)
114 // : name(), index(0), cam(), me(NULL), isTrackedLine(true), isTrackedLineWithVisibility(true),
115 // wmean(1), featureline(), poly(), useScanLine(false), meline(), line(NULL), p1(NULL), p2(NULL), L(),
116 // error(), nbFeature(), nbFeatureTotal(0), Reinit(false), hiddenface(NULL), Lindex_polygon(),
117 // Lindex_polygon_tracked(), isvisible(false)
118 // {
119 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
120 // }
121 // vpMbtDistanceLine &operator=(const vpMbtDistanceLine &){
122 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
123 // return *this;
124 // }
125 //#endif
126 
127  public:
129  ~vpMbtDistanceLine() ;
130 
131  void addPolygon(const int &index);
132 
133  void buildFrom(vpPoint &_p1, vpPoint &_p2);
134 
135  bool closeToImageBorder(const vpImage<unsigned char>& I, const unsigned int threshold);
136  void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo);
137 
138  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);
139  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor col, const unsigned int thickness = 1, const bool displayFullModel = false);
140  void displayMovingEdges(const vpImage<unsigned char> &I);
141 
147  inline void getCameraParameters(vpCameraParameters& camera) const {camera = this->cam;}
148 
154  inline unsigned int getIndex() const {return index ;}
155 
162  inline double getMeanWeight() const {return wmean;}
163 
169  inline std::string getName() const {return name;}
170 
176  inline vpMbtPolygon& getPolygon() {return poly;}
177 
178  void initInteractionMatrixError();
179 
180  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
181 
187  inline bool isTracked() const {return isTrackedLineWithVisibility;}
188 
194  inline bool isVisible() const {return isvisible; }
195 
196  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
197 
202  inline void setCameraParameters(const vpCameraParameters& camera) {this->cam = camera;}
203 
209  inline void setIndex(const unsigned int i) {index = i;}
210 
216  inline void setMeanWeight(const double w_mean) {this->wmean = w_mean;}
217 
218  void setMovingEdge(vpMe *Me);
219 
225  inline void setName(const std::string line_name) {this->name = line_name;}
226 
232  inline void setName(const char* line_name) {this->name = std::string(line_name);}
233 
234  void setTracked(const std::string &name, const bool &track);
235 
241  void setVisible(bool _isvisible) {isvisible = _isvisible ; }
242 
243  void trackMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
244 
245  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
246 
247  void updateTracked();
248 
249  private:
250  void project(const vpHomogeneousMatrix &cMo);
251 } ;
252 
253 #endif
254 
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
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:121
std::vector< bool > Lindex_polygon_tracked
Vector of bool associated with Lindex_polygon to know if Lindex_polygon[i] is tracked.
vpPoint * p1
The first extremity.
unsigned int getIndex() const
Definition: vpMe.h:59
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:59
std::vector< vpMbtMeLine * > meline
The moving edge container.
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:120
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:64
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 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)
void setName(const std::string line_name)
vpMatrix L
The interaction matrix.
std::vector< unsigned int > nbFeature
The number of moving edges.
bool useScanLine
Use scanline rendering.