Visual Servoing Platform  version 3.0.0
vpMbEdgeKltTracker.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  * 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 <visp3/core/vpConfig.h>
48 
49 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
50 
51 #include <visp3/core/vpRobust.h>
52 #include <visp3/core/vpSubMatrix.h>
53 #include <visp3/core/vpSubColVector.h>
54 #include <visp3/core/vpExponentialMap.h>
55 #include <visp3/mbt/vpMbTracker.h>
56 #include <visp3/klt/vpKltOpencv.h>
57 #include <visp3/mbt/vpMbEdgeTracker.h>
58 #include <visp3/core/vpPoseVector.h>
59 #include <visp3/mbt/vpMbtEdgeKltXmlParser.h>
60 #include <visp3/mbt/vpMbKltTracker.h>
61 
223 class VISP_EXPORT vpMbEdgeKltTracker: public vpMbKltTracker, public vpMbEdgeTracker
224 {
225 protected:
229  double lambda;
231  double thresholdKLT;
233  double thresholdMBT;
235  unsigned int maxIter;
236 
237 public:
238 
240  virtual ~vpMbEdgeKltTracker();
241 
242  virtual void display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
243  const vpColor& col , const unsigned int thickness=1, const bool displayFullModel = false);
244  virtual void display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
245  const vpColor& col , const unsigned int thickness=1, const bool displayFullModel = false);
246 
252  virtual inline double getLambda() const {return lambda;}
253 
259  virtual inline unsigned int getMaxIter() const {return maxIter;}
260 
266  virtual inline double getNearClippingDistance() const { return vpMbKltTracker::getNearClippingDistance(); }
267 
268  void loadConfigFile(const char* configFile);
269  virtual void loadConfigFile(const std::string& configFile);
270 
271  void reInitModel(const vpImage<unsigned char>& I, const std::string &cad_name, const vpHomogeneousMatrix& cMo_,
272  const bool verbose=false);
273  void reInitModel(const vpImage<unsigned char>& I, const char* cad_name, const vpHomogeneousMatrix& cMo,
274  const bool verbose=false);
275  void resetTracker();
276 
277  virtual void setCameraParameters(const vpCameraParameters& cam);
278 
286  virtual void setClipping(const unsigned int &flags) {vpMbEdgeTracker::setClipping(flags); }
287 
293  virtual void setFarClippingDistance(const double &dist) { vpMbEdgeTracker::setFarClippingDistance(dist); }
294 
300  virtual inline void setLambda(const double gain) {this->lambda = gain; vpMbEdgeTracker::setLambda(lambda); vpMbKltTracker::setLambda(lambda);}
301 
307  virtual inline void setMaxIter(const unsigned int max) {maxIter = max;}
308 
314  virtual void setNearClippingDistance(const double &dist) { vpMbEdgeTracker::setNearClippingDistance(dist); }
315 
323  virtual void setOgreVisibilityTest(const bool &v){
325 #ifdef VISP_HAVE_OGRE
326  faces.getOgreContext()->setWindowName("MBT Hybrid");
327 #endif
328  }
329 
335  virtual void setScanLineVisibilityTest(const bool &v){
338  }
339 
340  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix& cdMo);
346  virtual void setProjectionErrorComputation(const bool &flag) {
348  }
349 
350 
351  virtual void testTracking(){};
352  virtual void track(const vpImage<unsigned char>& I);
353 
354 protected:
355  void computeVVS(const vpImage<unsigned char>& I, const unsigned int &nbInfos, vpColVector &w_mbt,
356  vpColVector &w_klt, const unsigned int lvl=0);
357 
358  virtual void init(const vpImage<unsigned char>& I);
359  virtual void initCircle(const vpPoint&, const vpPoint &, const vpPoint &, const double r, const int idFace=0,
360  const std::string &name="");
361  virtual void initCylinder(const vpPoint&, const vpPoint &, const double r, const int idFace,
362  const std::string &name="");
363  virtual void initFaceFromCorners(vpMbtPolygon &polygon);
364  virtual void initFaceFromLines(vpMbtPolygon &polygon);
365  unsigned int initMbtTracking(const unsigned int level=0);
366 
367  bool postTracking(const vpImage<unsigned char>& I, vpColVector &w_mbt, vpColVector &w_klt,
368  const unsigned int lvl=0);
369  void postTrackingMbt(vpColVector &w, const unsigned int level=0);
370 
371  unsigned int trackFirstLoop(const vpImage<unsigned char>& I, vpColVector &factor, const unsigned int lvl = 0);
372  void trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix &L, vpColVector &_error,
373  vpHomogeneousMatrix& cMo, const unsigned int lvl=0);
374 };
375 
376 #endif
377 
378 #endif //VISP_HAVE_OPENCV
double lambda
The gain of the virtual visual servoing stage.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
virtual void setScanLineVisibilityTest(const bool &v)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void setScanLineVisibilityTest(const bool &v)
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)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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:121
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:59
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)
virtual void setScanLineVisibilityTest(const bool &v)
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:64
virtual void setProjectionErrorComputation(const bool &flag)
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:318
virtual void setOgreVisibilityTest(const bool &v)
Implementation of column vector and the associated operations.
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)
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:509