ViSP  2.7.0
vpMbEdgeKltTracker.h
1 /****************************************************************************
2  *
3  * $Id: vpMbEdgeKltTracker.h 4119 2013-02-08 10:30:53Z fspindle $
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  * Hybrid tracker based on edges (vpMbt) and points of interests (KLT)
32  *
33  * Authors:
34  * Romain Tallonneau
35  * Aurelien Yol
36  *
37  *****************************************************************************/
38 
44 #ifndef vpMbEdgeKltTracker_HH
45 #define vpMbEdgeKltTracker_HH
46 
47 #include <visp/vpConfig.h>
48 
49 #ifdef VISP_HAVE_OPENCV
50 
51 #include <visp/vpRobust.h>
52 #include <visp/vpSubMatrix.h>
53 #include <visp/vpSubColVector.h>
54 #include <visp/vpExponentialMap.h>
55 #include <visp/vpMbtXmlParser.h>
56 #include <visp/vpMbTracker.h>
57 #include <visp/vpKltOpencv.h>
58 #include <visp/vpMbEdgeTracker.h>
59 #include <visp/vpPoseVector.h>
60 #include <visp/vpMbKltTracker.h>
61 
210 class VISP_EXPORT vpMbEdgeKltTracker: public vpMbKltTracker, public vpMbEdgeTracker
211 {
212 protected:
216  double lambda;
218  double thresholdKLT;
220  double thresholdMBT;
222  unsigned int maxIter;
223 
224 public:
225 
227  virtual ~vpMbEdgeKltTracker();
228 
229  virtual void display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
230  const vpColor& col , const unsigned int thickness=1, const bool displayFullModel = false);
231  virtual void display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
232  const vpColor& col , const unsigned int thickness=1, const bool displayFullModel = false);
233 
235  virtual inline double getAngleAppear() { return vpMbKltTracker::getAngleAppear(); }
236 
238  virtual inline double getAngleDisappear() { return vpMbKltTracker::getAngleDisappear(); }
239 
242 
248  inline double getLambda() {return lambda;}
249 
255  inline unsigned int getMaxIter() {return maxIter;}
256 
257  void loadConfigFile(const char* configFile);
258  virtual void loadConfigFile(const std::string& configFile);
259  virtual void loadModel(const std::string& modelFile);
260 
261  void resetTracker();
262 
272  virtual inline void setAngleAppear(const double &a) { vpMbKltTracker::setAngleAppear(a); }
273 
283  virtual inline void setAngleDisappear(const double &a) { vpMbKltTracker::setAngleDisappear(a); }
284 
285  virtual void setCameraParameters(const vpCameraParameters& cam);
286 
292  inline void setLambda(const double lambda) {this->lambda = lambda; vpMbEdgeTracker::setLambda(lambda); vpMbKltTracker::setLambda(lambda);}
293 
299  inline void setMaxIter(const unsigned int max) {maxIter = max;}
300 
308  virtual inline void setOgreVisibilityTest(const bool &v) { vpMbKltTracker::setOgreVisibilityTest(v); }
309 
310  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix& cdMo);
311 
312  virtual void testTracking(){};
313  virtual void track(const vpImage<unsigned char>& I);
314 
315 protected:
316  void computeVVS(const vpImage<unsigned char>& I, const unsigned int &nbInfos, vpColVector &w_mbt,
317  vpColVector &w_klt, const unsigned int lvl=0);
318 
319  virtual void init(const vpImage<unsigned char>& I);
320  virtual void initCylinder(const vpPoint& , const vpPoint , const double , const unsigned int );
321  virtual void initFaceFromCorners(const std::vector<vpPoint>& corners, const unsigned int indexFace = -1);
322  unsigned int initMbtTracking(const unsigned int level=0);
323 
324  bool postTracking(const vpImage<unsigned char>& I, vpColVector &w_mbt, vpColVector &w_klt,
325  const unsigned int lvl=0);
326  void postTrackingMbt(vpColVector &w, const unsigned int level=0);
327 
328  unsigned int trackFirstLoop(const vpImage<unsigned char>& I, vpColVector &factor, const unsigned int lvl = 0);
329  void trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix &L, vpColVector &_error,
330  vpHomogeneousMatrix& cMo, const unsigned int lvl=0);
331 };
332 
333 #endif
334 
335 #endif //VISP_HAVE_OPENCV
double lambda
The gain of the virtual visual servoing stage.
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
unsigned int maxIter
The maximum iteration of the virtual visual servoing stage.
void computeVVS(const vpImage< unsigned char > &_I)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void init(const vpImage< unsigned char > &I)
void track(const vpImage< unsigned char > &I)
double lambda
The gain of the virtual visual servoing stage.
Class to define colors available for display functionnalities.
Definition: vpColor.h:123
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
double thresholdKLT
The threshold used in the robust estimation of KLT.
Make the complete tracking of an object by using its CAD model.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
void loadConfigFile(const std::string &configFile)
void setMaxIter(const unsigned int max)
void setLambda(const double lambda)
Class that defines what is a point.
Definition: vpPoint.h:65
virtual void setAngleAppear(const double &a)
virtual void setOgreVisibilityTest(const bool &v)
virtual double getAngleAppear()
virtual void initCylinder(const vpPoint &_p1, const vpPoint _p2, const double _radius, const unsigned int _indexCylinder=0)
Generic class defining intrinsic camera parameters.
virtual void setAngleAppear(const double &a)
vpMbHiddenFaces< vpMbtKltPolygon > faces
Set of faces describing the object.
bool compute_interaction
If true, compute the interaction matrix at each iteration of the minimisation. Otherwise, compute it only on the first iteration.
virtual void setAngleDisappear(const double &a)
Model based tracker using only KLT.
virtual void initFaceFromCorners(const std::vector< vpPoint > &_corners, const unsigned int _indexFace=-1)
void setLambda(const double lambda)
virtual double getAngleAppear()
vpMbHiddenFaces< vpMbtKltPolygon > & getFaces()
virtual double getAngleDisappear()
virtual void setAngleDisappear(const double &a)
unsigned int getMaxIter()
Hybrid tracker based on edges (vpMbt) and points of interests (KLT)
unsigned int maxIter
The maximum iteration of the virtual visual servoing stage.
virtual void testTracking()
void setLambda(const double lambda)
virtual double getAngleDisappear()
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
virtual void setOgreVisibilityTest(const bool &v)
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)
virtual void setCameraParameters(const vpCameraParameters &cam)
void loadModel(const std::string &cad_name)
double thresholdMBT
The threshold used in the robust estimation of MBT.