ViSP  2.7.0
vpMbtKltPolygon.h
1 /****************************************************************************
2  *
3  * $Id: vpMbtKltPolygon.h 4084 2013-02-01 14:17:58Z ayol $
4  *
5  * Copyright (C) 2005 - 2013 Inria. All rights reserved.
6  *
7  * This software was developed at:
8  * IRISA/INRIA Rennes
9  * Projet Lagadic
10  * Campus Universitaire de Beaulieu
11  * 35042 Rennes Cedex
12  * http://www.irisa.fr/lagadic
13  *
14  * This file is part of the ViSP toolkit
15  *
16  * This file may be distributed under the terms of the Q Public License
17  * as defined by Trolltech AS of Norway and appearing in the file
18  * LICENSE included in the packaging of this file.
19  *
20  * Licensees holding valid ViSP Professional Edition licenses may
21  * use this file in accordance with the ViSP Commercial License
22  * Agreement provided with the Software.
23  *
24  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26  *
27  * Contact visp@irisa.fr if any conditions of this licensing are
28  * not clear to you.
29  *
30  * Description:
31  * Generic model polygon, containing points of interest.
32  *
33  * Authors:
34  * Romain Tallonneau
35  * Aurelien Yol
36  *
37  *****************************************************************************/
38 
39 #ifndef vpMbtKltHiddenFace_h
40 #define vpMbtKltHiddenFace_h
41 
42 #include <visp/vpConfig.h>
43 
44 #ifdef VISP_HAVE_OPENCV
45 
46 #include <visp/vpMbtPolygon.h>
47 #include <visp/vpKltOpencv.h>
48 #include <visp/vpPlane.h>
49 #include <visp/vpDisplay.h>
50 #include <visp/vpGEMM.h>
51 #include <visp/vpHomography.h>
52 #include <visp/vpPlot.h>
53 
63 class VISP_EXPORT vpMbtKltPolygon: public vpMbtPolygon
64 {
65 private:
67  vpMatrix H;
69  vpColVector N;
71  vpColVector N_cur;
73  double invd0;
75  vpColVector cRc0_0n;
77  std::map<int, vpImagePoint> initPoints;
79  std::map<int, vpImagePoint> curPoints;
81  std::map<int, int> curPointsInd;
83  unsigned int nbPointsCur;
85  unsigned int nbPointsInit;
87  unsigned int minNbPoint;
89  bool enoughPoints;
91  double dt;
93  double d0;
96 
97 private:
98 
99  double compute_1_over_Z(const double x, const double y);
100  void computeP_mu_t(const double x_in, const double y_in, double& x_out, double& y_out, const vpMatrix& cHc0);
101  bool isTrackedFeature(const int id);
102 
103 public:
104  vpMbtKltPolygon();
105  virtual ~vpMbtKltPolygon();
106 
107  unsigned int computeNbDetectedCurrent(const vpKltOpencv& _tracker);
108  void computeHomography(const vpHomogeneousMatrix& _cTc0, vpHomography& cHc0);
109  void computeInteractionMatrixAndResidu(vpColVector& _R, vpMatrix& _J);
110 
111  void displayPrimitive(const vpImage<unsigned char>& _I);
112  void displayPrimitive(const vpImage<vpRGBa>& _I);
113 
119  inline vpCameraParameters& getCameraParameters(){ return cam; }
120 
121  inline vpColVector getCurrentNormal() const {return N_cur; }
122 
123  inline std::map<int, vpImagePoint>& getCurrentPoints() {return curPoints; }
124 
125  inline std::map<int, int>& getCurrentPointsInd() {return curPointsInd; }
126 
127  vpImagePoint& getImagePoint(const unsigned int _index);
133  inline unsigned int getInitialNumberPoint() const { return nbPointsInit;}
134 
143  inline unsigned int getNbPointsCur() const {return nbPointsCur;}
144 
145  inline bool hasEnoughPoints() const {return enoughPoints;}
146 
147  void init(const vpKltOpencv& _tracker);
148 
149  void removeOutliers(const vpColVector& weight, const double &threshold_outlier);
150 
156  virtual inline void setCameraParameters(const vpCameraParameters& _cam){ cam = _cam; }
157 
158  void updateMask(IplImage* _mask, unsigned int _nb = 255, unsigned int _shiftBorder = 0);
159 
160 //###################
161 // Static Functions
162 //###################
163 private:
164  static bool isInside(const std::vector<vpImagePoint>& roi, const double i, const double j);
165  static bool intersect(const vpImagePoint& p1, const vpImagePoint& p2, const double i, const double j, const double i_test, const double j_test);
166 };
167 
168 #endif
169 
170 #endif // VISP_HAVE_OPENCV
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
unsigned int getInitialNumberPoint() const
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
unsigned int getNbPointsCur() const
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:174
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:67
Generic class defining intrinsic camera parameters.
vpColVector getCurrentNormal() const
virtual void setCameraParameters(const vpCameraParameters &_cam)
vpCameraParameters & getCameraParameters()
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented with OpenCV.
Definition: vpKltOpencv.h:141
std::map< int, int > & getCurrentPointsInd()
std::map< int, vpImagePoint > & getCurrentPoints()
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
bool hasEnoughPoints() const