Visual Servoing Platform  version 3.0.0
vpMbtDistanceKltCylinder.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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 
163  inline unsigned int getInitialNumberPoint() const { return nbPointsInit;}
174  inline unsigned int getCurrentNumberPoints() const {return nbPointsCur;}
175 
176  inline bool hasEnoughPoints() const {return enoughPoints;}
177 
183  inline bool isTracked() const {return isTrackedKltCylinder;}
184 
185  void init(const vpKltOpencv& _tracker, const vpHomogeneousMatrix &cMo);
186 
187  void removeOutliers(const vpColVector& weight, const double &threshold_outlier);
188 
194  virtual inline void setCameraParameters(const vpCameraParameters& _cam){ cam = _cam; }
195 
201  inline void setTracked(const bool& track) {this->isTrackedKltCylinder = track;}
202 
203 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
204  void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
205 #else
206  void updateMask(IplImage* mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
207 #endif
208 };
209 
210 #endif
211 
212 #endif // VISP_HAVE_OPENCV
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
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.
Definition: vpKltOpencv.h:75
unsigned int getCurrentNumberPoints() const
Class that defines what is a circle.
Definition: vpCircle.h:57