Visual Servoing Platform  version 3.6.1 under development (2025-02-18)
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 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
134  vpMbtDistanceLine(const vpMbtDistanceLine &) = delete; // non construction-copyable
135  vpMbtDistanceLine &operator=(const vpMbtDistanceLine &) = delete; // non copyable
136 #endif
137 
138 public:
140  virtual ~vpMbtDistanceLine();
141 
142  void addPolygon(const int &index);
143 
144  void buildFrom(vpPoint &_p1, vpPoint &_p2, vpUniRand &rand_gen);
145 
146  bool closeToImageBorder(const vpImage<unsigned char> &I, const unsigned int threshold);
147  void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo);
148 
149  void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
150  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
151  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
152  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
153  void displayMovingEdges(const vpImage<unsigned char> &I);
154  void displayMovingEdges(const vpImage<vpRGBa> &I);
155 
161  inline void getCameraParameters(vpCameraParameters &camera) const { camera = this->cam; }
162 
168  inline unsigned int getIndex() const { return index; }
169 
177  inline double getMeanWeight() const { return wmean; }
178 
179  std::vector<std::vector<double> > getFeaturesForDisplay();
180 
181  std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
182  const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
183  bool displayFullModel = false);
184 
190  inline std::string getName() const { return name; }
191 
197  inline vpMbtPolygon &getPolygon() { return poly; }
198 
199  void initInteractionMatrixError();
200 
201  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, bool doNotTrack,
202  const vpImage<bool> *mask = nullptr);
203 
209  inline bool isTracked() const { return isTrackedLineWithVisibility; }
210 
216  inline bool isVisible() const { return isvisible; }
217 
218  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo,
219  const vpImage<bool> *mask = nullptr);
220 
225  inline void setCameraParameters(const vpCameraParameters &camera) { this->cam = camera; }
226 
232  inline void setIndex(unsigned int i) { index = i; }
233 
239  inline void setMeanWeight(double w_mean) { this->wmean = w_mean; }
240 
241  void setMovingEdge(vpMe *Me);
242 
248  inline void setName(const std::string &line_name) { this->name = line_name; }
249 
255  inline void setName(const char *line_name) { this->name = std::string(line_name); }
256 
257  void setTracked(const std::string &name, const bool &track);
258 
265  void setVisible(bool _isvisible) { isvisible = _isvisible; }
266 
267  void trackMovingEdge(const vpImage<unsigned char> &I);
268 
269  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
270 
271  void updateTracked();
272 
273 private:
274  void project(const vpHomogeneousMatrix &cMo);
275 };
276 END_VISP_NAMESPACE
277 #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.
vpMbtDistanceLine(const vpMbtDistanceLine &)=delete
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.
vpMbtDistanceLine & operator=(const vpMbtDistanceLine &)=delete
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