Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
vpMbtDistanceLine.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://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  * Romain Tallonneau
36  *
37 *****************************************************************************/
38 
44 #ifndef vpMbtDistanceLine_HH
45 #define vpMbtDistanceLine_HH
46 
47 #include <visp3/core/vpConfig.h>
48 #include <visp3/core/vpHomogeneousMatrix.h>
49 #include <visp3/core/vpLine.h>
50 #include <visp3/core/vpPoint.h>
51 #include <visp3/core/vpUniRand.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 
58 BEGIN_VISP_NAMESPACE
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(nullptr), isTrackedLine(true),
118  // isTrackedLineWithVisibility(true),
119  // wmean(1), featureline(), poly(), useScanLine(false), meline(),
120  // line(nullptr), p1(nullptr), p2(nullptr), L(), error(), nbFeature(),
121  // nbFeatureTotal(0), Reinit(false), hiddenface(nullptr),
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, 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 = nullptr);
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 = nullptr);
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 END_VISP_NAMESPACE
272 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:157
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:103
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
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:60
Definition: vpMe.h:134
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:79
Class for generating random numbers with uniform probability density.
Definition: vpUniRand.h:127