Visual Servoing Platform  version 3.3.0
vpMbtDistanceCylinder.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 a cylinder used in the model-based tracker.
33  *
34  * Authors:
35  * Nicolas Melchior
36  * Romain Tallonneau
37  * Eric Marchand
38  * Bertrand Delabarre
39  *
40  *****************************************************************************/
41 
47 #ifndef vpMbtDistanceCylinder_HH
48 #define vpMbtDistanceCylinder_HH
49 
50 #include <visp3/core/vpCircle.h>
51 #include <visp3/core/vpCylinder.h>
52 #include <visp3/core/vpHomogeneousMatrix.h>
53 #include <visp3/core/vpLine.h>
54 #include <visp3/core/vpPoint.h>
55 #include <visp3/mbt/vpMbHiddenFaces.h>
56 #include <visp3/mbt/vpMbtMeLine.h>
57 #include <visp3/visual_features/vpFeatureLine.h>
58 
66 class VISP_EXPORT vpMbtDistanceCylinder
67 {
68 private:
69  std::string name;
70  unsigned int index;
72  vpMe *me;
73  double wmean1;
74  double wmean2;
75  vpFeatureLine featureline1;
76  vpFeatureLine featureline2;
77  bool isTrackedCylinder;
78 
79 public:
81  vpMbtMeLine *meline1;
83  vpMbtMeLine *meline2;
84 
89 
91  double radius;
92 
97 
103  unsigned int nbFeature;
105  unsigned int nbFeaturel1;
107  unsigned int nbFeaturel2;
109  bool Reinit;
112 
118  bool isvisible;
119 
120  // private:
121  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
122  // vpMbtDistanceCylinder(const vpMbtDistanceCylinder &)
123  // : name(), index(0), cam(), me(NULL), wmean1(1), wmean2(1),
124  // featureline1(), featureline2(), isTrackedCylinder(true),
125  // meline1(NULL), meline2(NULL), cercle1(NULL), cercle2(NULL),
126  // radius(0), p1(NULL), p2(NULL), L(), error(), nbFeature(0),
127  // nbFeaturel1(0), nbFeaturel2(0), Reinit(false), c(NULL),
128  // hiddenface(NULL), index_polygon(-1), isvisible(false)
129  // {
130  // throw vpException(vpException::functionNotImplementedError, "Not
131  // implemented!");
132  // }
133  // vpMbtDistanceCylinder &operator=(const vpMbtDistanceCylinder &){
134  // throw vpException(vpException::functionNotImplementedError, "Not
135  // implemented!"); return *this;
136  // }
137  //#endif
138 
139 public:
141  virtual ~vpMbtDistanceCylinder();
142 
143  void buildFrom(const vpPoint &_p1, const vpPoint &_p2, double r);
144 
145  void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage<unsigned char> &I);
146 
147  void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
148  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
149  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
150  const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
151  void displayMovingEdges(const vpImage<unsigned char> &I);
152  void displayMovingEdges(const vpImage<vpRGBa> &I);
153 
159  inline void getCameraParameters(vpCameraParameters &camera) { camera = this->cam; }
160 
166  inline unsigned int getIndex() { return index; }
167 
175  inline double getMeanWeight1() const { return wmean1; }
176 
184  inline double getMeanWeight2() const { return wmean2; }
185 
186  std::vector<std::vector<double> > getFeaturesForDisplay();
187 
188  std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
189  const vpHomogeneousMatrix &cMo,
190  const vpCameraParameters &cam,
191  bool displayFullModel = false);
192 
198  inline std::string getName() const { return name; }
199 
200  void initInteractionMatrixError();
201 
202  bool initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, bool doNotTrack,
203  const vpImage<bool> *mask = NULL);
204 
210  inline bool isTracked() const { return isTrackedCylinder; }
211 
217  inline bool isVisible() const { return isvisible; }
218 
219  void reinitMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo,
220  const vpImage<bool> *mask = NULL);
221 
226  inline void setCameraParameters(const vpCameraParameters &camera) { this->cam = camera; }
227 
233  inline void setTracked(const bool &track) { this->isTrackedCylinder = track; }
234 
240  inline void setIndex(unsigned int i) { index = i; }
241 
247  inline void setMeanWeight1(double wmean) { this->wmean1 = wmean; }
248 
254  inline void setMeanWeight2(double wmean) { this->wmean2 = wmean; }
255 
256  void setMovingEdge(vpMe *Me);
257 
263  inline void setName(const std::string &cyl_name) { this->name = cyl_name; }
264 
270  inline void setName(const char *cyl_name) { this->name = std::string(cyl_name); }
271 
278  inline void setVisible(bool _isvisible) { isvisible = _isvisible; }
279 
280  void trackMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
281 
282  void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo);
283 
284 private:
285  void project(const vpHomogeneousMatrix &cMo);
286 };
287 
288 #endif
vpMbtDistanceCylinder::meline1
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
Definition: vpMbtDistanceCylinder.h:81
vpMbtDistanceCylinder::Reinit
bool Reinit
Indicates if the line has to be reinitialized.
Definition: vpMbtDistanceCylinder.h:109
vpMbtDistanceCylinder
Manage a cylinder used in the model-based tracker.
Definition: vpMbtDistanceCylinder.h:67
vpMbtDistanceCylinder::nbFeature
unsigned int nbFeature
The number of moving edges.
Definition: vpMbtDistanceCylinder.h:103
vpMbtDistanceCylinder::setMeanWeight2
void setMeanWeight2(double wmean)
Definition: vpMbtDistanceCylinder.h:254
vpMbtDistanceCylinder::radius
double radius
The radius of the cylinder.
Definition: vpMbtDistanceCylinder.h:91
vpMbtDistanceCylinder::cercle2
vpCircle * cercle2
The lower circle limiting the cylinder.
Definition: vpMbtDistanceCylinder.h:88
vpMbtDistanceCylinder::setMeanWeight1
void setMeanWeight1(double wmean)
Definition: vpMbtDistanceCylinder.h:247
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition: vpCameraParameters.h:234
vpMbtDistanceCylinder::L
vpMatrix L
The interaction matrix.
Definition: vpMbtDistanceCylinder.h:99
vpMbtDistanceCylinder::hiddenface
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
Definition: vpMbtDistanceCylinder.h:114
vpMbtDistanceCylinder::setName
void setName(const char *cyl_name)
Definition: vpMbtDistanceCylinder.h:270
vpMbtDistanceCylinder::error
vpColVector error
The error vector.
Definition: vpMbtDistanceCylinder.h:101
vpMbHiddenFaces< vpMbtPolygon >
vpMbtDistanceCylinder::meline2
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
Definition: vpMbtDistanceCylinder.h:83
vpMbtDistanceCylinder::getCameraParameters
void getCameraParameters(vpCameraParameters &camera)
Definition: vpMbtDistanceCylinder.h:159
vpMbtDistanceCylinder::p2
vpPoint * p2
The second extremity on the axe.
Definition: vpMbtDistanceCylinder.h:96
vpCircle
Class that defines what is a circle.
Definition: vpCircle.h:59
vpMbtDistanceCylinder::isVisible
bool isVisible() const
Definition: vpMbtDistanceCylinder.h:217
vpMbtDistanceCylinder::getName
std::string getName() const
Definition: vpMbtDistanceCylinder.h:198
vpMbtDistanceCylinder::getMeanWeight1
double getMeanWeight1() const
Definition: vpMbtDistanceCylinder.h:175
vpMe
Definition: vpMe.h:61
vpColVector
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
vpMbtDistanceCylinder::nbFeaturel1
unsigned int nbFeaturel1
The number of moving edges on line 1.
Definition: vpMbtDistanceCylinder.h:105
vpMatrix
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:165
vpCylinder
Class that defines what is a cylinder.
Definition: vpCylinder.h:97
vpMbtDistanceCylinder::c
vpCylinder * c
The cylinder.
Definition: vpMbtDistanceCylinder.h:111
vpMbtDistanceCylinder::isTracked
bool isTracked() const
Definition: vpMbtDistanceCylinder.h:210
vpMbtDistanceCylinder::p1
vpPoint * p1
The first extremity on the axe.
Definition: vpMbtDistanceCylinder.h:94
vpMbtDistanceCylinder::cercle1
vpCircle * cercle1
The upper circle limiting the cylinder.
Definition: vpMbtDistanceCylinder.h:86
vpMbtDistanceCylinder::setVisible
void setVisible(bool _isvisible)
Definition: vpMbtDistanceCylinder.h:278
vpMbtDistanceCylinder::index_polygon
int index_polygon
Index of the face which contains the cylinder.
Definition: vpMbtDistanceCylinder.h:116
vpMbtDistanceCylinder::getIndex
unsigned int getIndex()
Definition: vpMbtDistanceCylinder.h:166
vpFeatureLine
Class that defines a 2D line visual feature which is composed by two parameters that are and ,...
Definition: vpFeatureLine.h:196
vpMbtDistanceCylinder::setName
void setName(const std::string &cyl_name)
Definition: vpMbtDistanceCylinder.h:263
vpMbtDistanceCylinder::getMeanWeight2
double getMeanWeight2() const
Definition: vpMbtDistanceCylinder.h:184
vpMbtDistanceCylinder::setCameraParameters
void setCameraParameters(const vpCameraParameters &camera)
Definition: vpMbtDistanceCylinder.h:226
vpMbtDistanceCylinder::isvisible
bool isvisible
Indicates if the cylinder is visible or not.
Definition: vpMbtDistanceCylinder.h:118
vpMbtDistanceCylinder::nbFeaturel2
unsigned int nbFeaturel2
The number of moving edges on line 2.
Definition: vpMbtDistanceCylinder.h:107
vpImage< unsigned char >
vpPoint
Class that defines what is a point.
Definition: vpPoint.h:59
vpColor
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition: vpHomogeneousMatrix.h:150
vpMbtDistanceCylinder::setTracked
void setTracked(const bool &track)
Definition: vpMbtDistanceCylinder.h:233
vpMbtDistanceCylinder::setIndex
void setIndex(unsigned int i)
Definition: vpMbtDistanceCylinder.h:240