ViSP  2.10.0
vpMbEdgeKltTracker.h
1 /****************************************************************************
2  *
3  * $Id: vpMbEdgeKltTracker.h 5126 2015-01-05 22:07:11Z 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  * Hybrid tracker based on edges (vpMbt) and points of interests (KLT)
35  *
36  * Authors:
37  * Romain Tallonneau
38  * Aurelien Yol
39  *
40  *****************************************************************************/
41 
47 #ifndef vpMbEdgeKltTracker_HH
48 #define vpMbEdgeKltTracker_HH
49 
50 #include <visp/vpConfig.h>
51 
52 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
53 
54 #include <visp/vpRobust.h>
55 #include <visp/vpSubMatrix.h>
56 #include <visp/vpSubColVector.h>
57 #include <visp/vpExponentialMap.h>
58 #include <visp/vpMbTracker.h>
59 #include <visp/vpKltOpencv.h>
60 #include <visp/vpMbEdgeTracker.h>
61 #include <visp/vpPoseVector.h>
62 #include <visp/vpMbtEdgeKltXmlParser.h>
63 #include <visp/vpMbKltTracker.h>
64 
226 class VISP_EXPORT vpMbEdgeKltTracker: public vpMbKltTracker, public vpMbEdgeTracker
227 {
228 protected:
232  double lambda;
234  double thresholdKLT;
236  double thresholdMBT;
238  unsigned int maxIter;
239 
240 public:
241 
243  virtual ~vpMbEdgeKltTracker();
244 
245  virtual void display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
246  const vpColor& col , const unsigned int thickness=1, const bool displayFullModel = false);
247  virtual void display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
248  const vpColor& col , const unsigned int thickness=1, const bool displayFullModel = false);
249 
255  virtual inline double getLambda() const {return lambda;}
256 
262  virtual inline unsigned int getMaxIter() const {return maxIter;}
263 
269  virtual inline double getNearClippingDistance() const { return vpMbKltTracker::getNearClippingDistance(); }
270 
271  void loadConfigFile(const char* configFile);
272  virtual void loadConfigFile(const std::string& configFile);
273 
274  void reInitModel(const vpImage<unsigned char>& I, const std::string &cad_name, const vpHomogeneousMatrix& cMo_,
275  const bool verbose=false);
276  void reInitModel(const vpImage<unsigned char>& I, const char* cad_name, const vpHomogeneousMatrix& cMo,
277  const bool verbose=false);
278  void resetTracker();
279 
280  virtual void setCameraParameters(const vpCameraParameters& cam);
281 
289  virtual void setClipping(const unsigned int &flags) {vpMbEdgeTracker::setClipping(flags); }
290 
296  virtual void setFarClippingDistance(const double &dist) { vpMbEdgeTracker::setFarClippingDistance(dist); }
297 
303  virtual inline void setLambda(const double gain) {this->lambda = gain; vpMbEdgeTracker::setLambda(lambda); vpMbKltTracker::setLambda(lambda);}
304 
310  virtual inline void setMaxIter(const unsigned int max) {maxIter = max;}
311 
317  virtual void setNearClippingDistance(const double &dist) { vpMbEdgeTracker::setNearClippingDistance(dist); }
318 
326  virtual void setOgreVisibilityTest(const bool &v){
328 #ifdef VISP_HAVE_OGRE
329  faces.getOgreContext()->setWindowName("MBT Hybrid");
330 #endif
331  }
332 
333  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix& cdMo);
334 
335  virtual void testTracking(){};
336  virtual void track(const vpImage<unsigned char>& I);
337 
338 protected:
339  void computeVVS(const vpImage<unsigned char>& I, const unsigned int &nbInfos, vpColVector &w_mbt,
340  vpColVector &w_klt, const unsigned int lvl=0);
341 
342  virtual void init(const vpImage<unsigned char>& I);
343  virtual void initCircle(const vpPoint&, const vpPoint &, const vpPoint &, const double r, const int idFace=0,
344  const std::string &name="");
345  virtual void initCylinder(const vpPoint&, const vpPoint &, const double r, const int idFace,
346  const std::string &name="");
347  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
348  virtual void initFaceFromLines(vpMbtPolygon &polygon);
349  unsigned int initMbtTracking(const unsigned int level=0);
350 
351  bool postTracking(const vpImage<unsigned char>& I, vpColVector &w_mbt, vpColVector &w_klt,
352  const unsigned int lvl=0);
353  void postTrackingMbt(vpColVector &w, const unsigned int level=0);
354 
355  unsigned int trackFirstLoop(const vpImage<unsigned char>& I, vpColVector &factor, const unsigned int lvl = 0);
356  void trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix &L, vpColVector &_error,
357  vpHomogeneousMatrix& cMo, const unsigned int lvl=0);
358 };
359 
360 #endif
361 
362 #endif //VISP_HAVE_OPENCV
double lambda
The gain of the virtual visual servoing stage.
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void setLambda(const double gain)
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:125
virtual void setMaxIter(const unsigned int max)
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
double thresholdKLT
The threshold used in the robust estimation of KLT.
virtual void setLambda(const double gain)
virtual void setClipping(const unsigned int &flags)
Make the complete tracking of an object by using its CAD model.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void setCameraParameters(const vpCameraParameters &camera)
void loadConfigFile(const std::string &configFile)
virtual void setFarClippingDistance(const double &dist)
Class that defines what is a point.
Definition: vpPoint.h:65
virtual void setNearClippingDistance(const double &dist)
virtual void setOgreVisibilityTest(const bool &v)
void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:67
Generic class defining intrinsic camera parameters.
bool compute_interaction
If true, compute the interaction matrix at each iteration of the minimization. Otherwise, compute it only on the first iteration.
virtual double getNearClippingDistance() const
virtual void setFarClippingDistance(const double &dist)
Model based tracker using only KLT.
virtual void initFaceFromLines(vpMbtPolygon &polygon)
Hybrid tracker based on moving-edges and keypoints tracked using KLT tracker.
unsigned int maxIter
The maximum iteration of the virtual visual servoing stage.
virtual void testTracking()
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
virtual double getNearClippingDistance() const
Definition: vpMbTracker.h:299
virtual void setOgreVisibilityTest(const bool &v)
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 initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")
virtual unsigned int getMaxIter() const
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 setClipping(const unsigned int &flags)
virtual double getLambda() const
virtual void setLambda(const double gain)
double thresholdMBT
The threshold used in the robust estimation of MBT.
virtual void setNearClippingDistance(const double &dist)