Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMbtDistanceKltCylinder.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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  * Klt cylinder, containing points of interest.
32  *
33  * Authors:
34  * Aurelien Yol
35  *
36  *****************************************************************************/
37 
38 #ifndef vpMbtDistanceKltCylinder_h
39 #define vpMbtDistanceKltCylinder_h
40 
41 #include <visp3/core/vpConfig.h>
42 
43 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
44 
45 #include <map>
46 
47 #include <visp3/core/vpPolygon3D.h>
48 #include <visp3/klt/vpKltOpencv.h>
49 #include <visp3/core/vpPlane.h>
50 #include <visp3/core/vpDisplay.h>
51 #include <visp3/core/vpGEMM.h>
52 #include <visp3/vision/vpHomography.h>
53 #include <visp3/mbt/vpMbHiddenFaces.h>
54 #include <visp3/core/vpCylinder.h>
55 #include <visp3/core/vpCircle.h>
56 
66 class VISP_EXPORT vpMbtDistanceKltCylinder
67 {
68 private:
72  vpPoint p1Ext;
74  vpPoint p2Ext;
76  vpCylinder cylinder;
78  vpCircle circle1;
80  vpCircle circle2;
82  std::map<int, vpImagePoint> initPoints;
84  std::map<int, vpPoint> initPoints3D;
86  std::map<int, vpImagePoint> curPoints;
88  std::map<int, int> curPointsInd;
90  unsigned int nbPointsCur;
92  unsigned int nbPointsInit;
94  unsigned int minNbPoint;
96  bool enoughPoints;
100  bool isTrackedKltCylinder;
101 
102 public:
104  std::vector<int> listIndicesCylinderBBox;
109 
110 private:
111  double computeZ(const double &x, const double &y);
112  bool isTrackedFeature(const int id);
113 
114 //private:
115 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
116 // vpMbtDistanceKltCylinder(const vpMbtDistanceKltCylinder &)
117 // : c0Mo(), p1Ext(), p2Ext(), cylinder(), circle1(), circle2(),
118 // initPoints(), initPoints3D(), curPoints(), curPointsInd(),
119 // nbPointsCur(0), nbPointsInit(0), minNbPoint(4), enoughPoints(false),
120 // cam(), isTrackedKltCylinder(true), listIndicesCylinderBBox(), hiddenface(NULL), useScanLine(false)
121 // {
122 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
123 // }
124 // vpMbtDistanceKltCylinder &operator=(const vpMbtDistanceKltCylinder &){
125 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
126 // return *this;
127 // }
128 //#endif
129 
130 public:
132  virtual ~vpMbtDistanceKltCylinder();
133 
134  void buildFrom(const vpPoint &p1, const vpPoint &p2, const double &r);
135 
136  unsigned int computeNbDetectedCurrent(const vpKltOpencv& _tracker);
137  void computeInteractionMatrixAndResidu(const vpHomogeneousMatrix &cMc0, vpColVector& _R, vpMatrix& _J);
138 
139  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);
140  void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor col, const unsigned int thickness = 1, const bool displayFullModel = false);
141 
142  void displayPrimitive(const vpImage<unsigned char>& _I);
143  void displayPrimitive(const vpImage<vpRGBa>& _I);
144 
150  inline vpCameraParameters& getCameraParameters(){ return cam; }
151 
152  inline std::map<int, vpImagePoint>& getCurrentPoints() {return curPoints; }
153 
154  inline std::map<int, int>& getCurrentPointsInd() {return curPointsInd; }
155 
156  inline vpCylinder getCylinder() const {
157  return cylinder;
158  }
159 
167  inline unsigned int getInitialNumberPoint() const { return nbPointsInit;}
178  inline unsigned int getCurrentNumberPoints() const {return nbPointsCur;}
179 
180  inline bool hasEnoughPoints() const {return enoughPoints;}
181 
187  inline bool isTracked() const {return isTrackedKltCylinder;}
188 
189  void init(const vpKltOpencv& _tracker, const vpHomogeneousMatrix &cMo);
190 
191  void removeOutliers(const vpColVector& weight, const double &threshold_outlier);
192 
198  virtual inline void setCameraParameters(const vpCameraParameters& _cam){ cam = _cam; }
199 
205  inline void setTracked(const bool& track) {this->isTrackedKltCylinder = track;}
206 
207 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
208  void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
209 #else
210  void updateMask(IplImage* mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
211 #endif
212 };
213 
214 #endif
215 
216 #endif // VISP_HAVE_OPENCV
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
void setTracked(const bool &track)
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::vector< int > listIndicesCylinderBBox
Pointer to the polygon that define a face.
std::map< int, int > & getCurrentPointsInd()
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
Class that defines what is a point.
Definition: vpPoint.h:59
unsigned int getInitialNumberPoint() const
virtual void setCameraParameters(const vpCameraParameters &_cam)
Generic class defining intrinsic camera parameters.
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
bool useScanLine
Use scanline rendering.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
std::map< int, vpImagePoint > & getCurrentPoints()
Class that defines what is a cylinder.
Definition: vpCylinder.h:93
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
vpCameraParameters & getCameraParameters()
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition: vpKltOpencv.h:76
unsigned int getCurrentNumberPoints() const
Class that defines what is a circle.
Definition: vpCircle.h:57