ViSP  2.10.0
vpMbtDistanceKltPoints.h
1 /****************************************************************************
2  *
3  * $Id: vpMbtDistanceKltPoints.h 4661 2014-02-10 19:34:58Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  * Description:
34  * Klt polygon, containing points of interest.
35  *
36  * Authors:
37  * Romain Tallonneau
38  * Aurelien Yol
39  *
40  *****************************************************************************/
41 
42 #ifndef vpMbtDistanceKltPoints_h
43 #define vpMbtDistanceKltPoints_h
44 
45 #include <visp/vpConfig.h>
46 
47 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
48 
49 #include <map>
50 
51 #include <visp/vpMbtPolygon.h>
52 #include <visp/vpKltOpencv.h>
53 #include <visp/vpPlane.h>
54 #include <visp/vpDisplay.h>
55 #include <visp/vpGEMM.h>
56 #include <visp/vpHomography.h>
57 #include <visp/vpPlot.h>
58 #include <visp/vpMbHiddenFaces.h>
59 
69 class VISP_EXPORT vpMbtDistanceKltPoints
70 {
71 private:
73  vpMatrix H;
75  vpColVector N;
77  vpColVector N_cur;
79  double invd0;
81  vpColVector cRc0_0n;
83  std::map<int, vpImagePoint> initPoints;
85  std::map<int, vpImagePoint> curPoints;
87  std::map<int, int> curPointsInd;
89  unsigned int nbPointsCur;
91  unsigned int nbPointsInit;
93  unsigned int minNbPoint;
95  bool enoughPoints;
97  double dt;
99  double d0;
101  vpCameraParameters cam;
102 
103 public:
106 
107 private:
108 
109  double compute_1_over_Z(const double x, const double y);
110  void computeP_mu_t(const double x_in, const double y_in, double& x_out, double& y_out, const vpMatrix& cHc0);
111  bool isTrackedFeature(const int id);
112 
113 public:
115  virtual ~vpMbtDistanceKltPoints();
116 
117  unsigned int computeNbDetectedCurrent(const vpKltOpencv& _tracker);
118  void computeHomography(const vpHomogeneousMatrix& _cTc0, vpHomography& cHc0);
119  void computeInteractionMatrixAndResidu(vpColVector& _R, vpMatrix& _J);
120 
121  void displayPrimitive(const vpImage<unsigned char>& _I);
122  void displayPrimitive(const vpImage<vpRGBa>& _I);
123 
129  inline vpCameraParameters& getCameraParameters(){ return cam; }
130 
131  inline vpColVector getCurrentNormal() const {return N_cur; }
132 
133  inline std::map<int, vpImagePoint>& getCurrentPoints() {return curPoints; }
134 
135  inline std::map<int, int>& getCurrentPointsInd() {return curPointsInd; }
136 
144  inline unsigned int getInitialNumberPoint() const { return nbPointsInit;}
155  inline unsigned int getCurrentNumberPoints() const {return nbPointsCur;}
156 
157  inline bool hasEnoughPoints() const {return enoughPoints;}
158 
159  void init(const vpKltOpencv& _tracker);
160 
161  void removeOutliers(const vpColVector& weight, const double &threshold_outlier);
162 
168  virtual inline void setCameraParameters(const vpCameraParameters& _cam){ cam = _cam; }
169 
170 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
171  void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
172 #else
173  void updateMask(IplImage* mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
174 #endif
175 
176  //###################
177  // Deprecated Functions
178  //###################
179 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
180 public:
191  vp_deprecated inline unsigned int getNbPointsCur() const {return nbPointsCur;}
192 #endif
193 
194  //###################
195  // Static Functions
196  //###################
197 private:
198  static bool isInside(const std::vector<vpImagePoint>& roi, const double i, const double j);
199  static bool intersect(const vpImagePoint& p1, const vpImagePoint& p2, const double i, const double j, const double i_test, const double j_test);
200 };
201 
202 #endif
203 
204 #endif // VISP_HAVE_OPENCV
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
std::map< int, int > & getCurrentPointsInd()
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:178
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:67
Generic class defining intrinsic camera parameters.
unsigned int getInitialNumberPoint() const
vp_deprecated unsigned int getNbPointsCur() const
std::map< int, vpImagePoint > & getCurrentPoints()
virtual void setCameraParameters(const vpCameraParameters &_cam)
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 in OpenCV.
Definition: vpKltOpencv.h:79
vpMbtPolygon * polygon
Pointer to the polygon that define a face.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:93
unsigned int getCurrentNumberPoints() const
vpColVector getCurrentNormal() const
vpCameraParameters & getCameraParameters()