Visual Servoing Platform  version 3.6.1 under development (2024-03-04)
vpMbtDistanceCylinder.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 a cylinder used in the model-based tracker.
33  *
34  * Authors:
35  * Romain Tallonneau
36  * Bertrand Delabarre
37  *
38 *****************************************************************************/
39 
45 #ifndef vpMbtDistanceCylinder_HH
46 #define vpMbtDistanceCylinder_HH
47 
48 #include <visp3/core/vpCircle.h>
49 #include <visp3/core/vpCylinder.h>
50 #include <visp3/core/vpHomogeneousMatrix.h>
51 #include <visp3/core/vpLine.h>
52 #include <visp3/core/vpPoint.h>
53 #include <visp3/mbt/vpMbHiddenFaces.h>
54 #include <visp3/mbt/vpMbtMeLine.h>
55 #include <visp3/visual_features/vpFeatureLine.h>
56 
64 class VISP_EXPORT vpMbtDistanceCylinder
65 {
66 private:
67  std::string name;
68  unsigned int index;
70  vpMe *me;
71  double wmean1;
72  double wmean2;
73  vpFeatureLine featureline1;
74  vpFeatureLine featureline2;
75  bool isTrackedCylinder;
76 
77 public:
79  vpMbtMeLine *meline1;
81  vpMbtMeLine *meline2;
82 
87 
89  double radius;
90 
95 
101  unsigned int nbFeature;
103  unsigned int nbFeaturel1;
105  unsigned int nbFeaturel2;
107  bool Reinit;
110 
116  bool isvisible;
117 
118  // private:
119  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
120  // vpMbtDistanceCylinder(const vpMbtDistanceCylinder &)
121  // : name(), index(0), cam(), me(nullptr), wmean1(1), wmean2(1),
122  // featureline1(), featureline2(), isTrackedCylinder(true),
123  // meline1(nullptr), meline2(nullptr), cercle1(nullptr), cercle2(nullptr),
124  // radius(0), p1(nullptr), p2(nullptr), L(), error(), nbFeature(0),
125  // nbFeaturel1(0), nbFeaturel2(0), Reinit(false), c(nullptr),
126  // hiddenface(nullptr), index_polygon(-1), isvisible(false)
127  // {
128  // throw vpException(vpException::functionNotImplementedError, "Not
129  // implemented!");
130  // }
131  // vpMbtDistanceCylinder &operator=(const vpMbtDistanceCylinder &){
132  // throw vpException(vpException::functionNotImplementedError, "Not
133  // implemented!"); return *this;
134  // }
135  //#endif
136 
137 public:
139  virtual ~vpMbtDistanceCylinder();
140 
141  void buildFrom(const vpPoint &_p1, const vpPoint &_p2, double r);
142 
143  void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage<unsigned char> &I);
144 
145  void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
146  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
147  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
148  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
149  void displayMovingEdges(const vpImage<unsigned char> &I);
150  void displayMovingEdges(const vpImage<vpRGBa> &I);
151 
157  inline void getCameraParameters(vpCameraParameters &camera) { camera = this->cam; }
158 
164  inline unsigned int getIndex() { return index; }
165 
173  inline double getMeanWeight1() const { return wmean1; }
174 
182  inline double getMeanWeight2() const { return wmean2; }
183 
184  std::vector<std::vector<double> > getFeaturesForDisplay();
185 
186  std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
187  const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
188  bool displayFullModel = false);
189 
195  inline std::string getName() const { return name; }
196 
197  void initInteractionMatrixError();
198 
199  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, bool doNotTrack,
200  const vpImage<bool> *mask = nullptr);
201 
207  inline bool isTracked() const { return isTrackedCylinder; }
208 
214  inline bool isVisible() const { return isvisible; }
215 
216  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo,
217  const vpImage<bool> *mask = nullptr);
218 
223  inline void setCameraParameters(const vpCameraParameters &camera) { this->cam = camera; }
224 
230  inline void setTracked(const bool &track) { this->isTrackedCylinder = track; }
231 
237  inline void setIndex(unsigned int i) { index = i; }
238 
244  inline void setMeanWeight1(double wmean) { this->wmean1 = wmean; }
245 
251  inline void setMeanWeight2(double wmean) { this->wmean2 = wmean; }
252 
253  void setMovingEdge(vpMe *Me);
254 
260  inline void setName(const std::string &cyl_name) { this->name = cyl_name; }
261 
267  inline void setName(const char *cyl_name) { this->name = std::string(cyl_name); }
268 
275  inline void setVisible(bool _isvisible) { isvisible = _isvisible; }
276 
277  void trackMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
278 
279  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
280 
281 private:
282  void project(const vpHomogeneousMatrix &cMo);
283 };
284 
285 #endif
Generic class defining intrinsic camera parameters.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
Definition: vpCircle.h:86
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:152
Class that defines a 3D cylinder in the object frame and allows forward projection of a 3D cylinder i...
Definition: vpCylinder.h:99
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.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
Manage a cylinder used in the model-based tracker.
void setMeanWeight1(double wmean)
void setCameraParameters(const vpCameraParameters &camera)
void setName(const std::string &cyl_name)
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
void setVisible(bool _isvisible)
void getCameraParameters(vpCameraParameters &camera)
vpCylinder * c
The cylinder.
vpMatrix L
The interaction matrix.
unsigned int nbFeaturel2
The number of moving edges on line 2.
bool Reinit
Indicates if the line has to be reinitialized.
vpPoint * p2
The second extremity on the axe.
vpCircle * cercle1
The upper circle limiting the cylinder.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setMeanWeight2(double wmean)
double radius
The radius of the cylinder.
unsigned int nbFeaturel1
The number of moving edges on line 1.
vpColVector error
The error vector.
void setTracked(const bool &track)
std::string getName() const
void setName(const char *cyl_name)
unsigned int nbFeature
The number of moving edges.
int index_polygon
Index of the face which contains the cylinder.
vpCircle * cercle2
The lower circle limiting the cylinder.
bool isvisible
Indicates if the cylinder is visible or not.
void setIndex(unsigned int i)
vpPoint * p1
The first extremity on the axe.
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
Definition: vpMe.h:124
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:77