ViSP
 All Classes Functions Variables Enumerations Enumerator Friends Groups Pages
vpMbKltTracker.h
1 /****************************************************************************
2  *
3  * $Id: vpMbKltTracker.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  * Model based tracker using only KLT
32  *
33  * Authors:
34  * Romain Tallonneau
35  * Aurelien Yol
36  *
37  *****************************************************************************/
43 #ifndef vpMbKltTracker_h
44 #define vpMbKltTracker_h
45 
46 #include <visp/vpConfig.h>
47 
48 #ifdef VISP_HAVE_OPENCV
49 
50 #include <visp/vpMbTracker.h>
51 #include <visp/vpKltOpencv.h>
52 #include <visp/vpMbtKltPolygon.h>
53 #include <visp/vpMeterPixelConversion.h>
54 #include <visp/vpPixelMeterConversion.h>
55 #include <visp/vpDisplayX.h>
56 #include <visp/vpMbtKltXmlParser.h>
57 #include <visp/vpHomography.h>
58 #include <visp/vpRobust.h>
59 #include <visp/vpSubColVector.h>
60 #include <visp/vpSubMatrix.h>
61 #include <visp/vpExponentialMap.h>
62 #include <visp/vpMbtKltPolygon.h>
63 
212 class VISP_EXPORT vpMbKltTracker: virtual public vpMbTracker
213 {
214 protected:
216  IplImage* cur;
220  double angleAppears;
228  unsigned int maskBorder;
230  double lambda;
232  unsigned int maxIter;
236  double percentGood;
238  bool useOgre;
247 
248 public:
249 
250  vpMbKltTracker();
251  virtual ~vpMbKltTracker();
252 
253  virtual void display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo,
254  const vpCameraParameters &cam, const vpColor& col, const unsigned int thickness=1,
255  const bool displayFullModel = false);
256  virtual void display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
257  const vpColor& col, const unsigned int thickness=1, const bool displayFullModel = false);
258 
259 protected:
260  virtual void init(const vpImage<unsigned char>& I);
261  virtual void reinit(const vpImage<unsigned char>& I);
262 
263 public:
264  virtual void loadConfigFile(const std::string& configFile);
265  void loadConfigFile(const char* configFile);
266 
268  virtual inline double getAngleAppear() { return angleAppears; }
269 
271  virtual inline double getAngleDisappear() { return angleDisappears; }
272 
275 
281  inline CvPoint2D32f* getKltPoints() {return tracker.getFeatures();}
282 
283  std::vector<vpImagePoint> getKltImagePoints();
284 
285  std::map<int, vpImagePoint> getKltImagePointsWithId();
286 
292  inline vpKltOpencv getKltOpencv() { return tracker; }
293 
299  inline double getLambda() {return lambda;}
300 
306  inline unsigned int getMaskBorder() { return maskBorder; }
307 
313  inline unsigned int getMaxIter() {return maxIter;}
314 
320  inline int getNbKltPoints() {return tracker.getNbFeatures();}
321 
327  inline double getThresholdAcceptation() { return threshold_outlier;}
328 
329  void resetTracker();
330 
340  virtual inline void setAngleAppear(const double &a) { angleAppears = a; }
341 
351  virtual inline void setAngleDisappear(const double &a) { angleDisappears = a; }
352 
353  void setCameraParameters(const vpCameraParameters& cam);
354 
355  void setKltOpencv(const vpKltOpencv& t);
356 
362  inline void setLambda(const double lambda) {this->lambda = lambda;}
363 
369  void setMaskBorder(const unsigned int &e){ maskBorder = e; }
370 
376  inline void setMaxIter(const unsigned int max) {maxIter = max;}
377 
378  virtual void setOgreVisibilityTest(const bool &v);
379 
380  virtual void setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatrix& cdMo);
381 
387  inline void setThresholdAcceptation(const double th) {threshold_outlier = th;}
388 
389  virtual void testTracking();
390  virtual void track(const vpImage<unsigned char>& I);
391 
392 protected:
393  void computeVVS(const unsigned int &nbInfos, vpColVector &w);
394 
395  virtual void initFaceFromCorners(const std::vector<vpPoint>& corners, const unsigned int indexFace = -1);
396  virtual void initCylinder(const vpPoint& , const vpPoint , const double , const unsigned int ){};
397 
398  void preTracking(const vpImage<unsigned char>& I, unsigned int &nbInfos, unsigned int &nbFaceUsed);
399  bool postTracking(const vpImage<unsigned char>& I, vpColVector &w);
400 };
401 
402 #endif
403 #endif // VISP_HAVE_OPENCV