ViSP  2.7.0
vpMbKltTracker.cpp
1 /****************************************************************************
2  *
3  * $Id: vpMbKltTracker.cpp 4122 2013-02-08 10:45:54Z ayol $
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  *****************************************************************************/
38 
39 #include <visp/vpMbKltTracker.h>
40 
41 #ifdef VISP_HAVE_OPENCV
42 
44 {
45  cur = NULL;
46  compute_interaction = true;
47  firstInitialisation = true;
48  computeCovariance = false;
49  firstTrack = false;
50 
53 
54  tracker.setMaxFeatures(10000);
56  tracker.setQuality(0.01);
61 
64 
65  maskBorder = 5;
66  threshold_outlier = 0.5;
67  percentGood = 0.6;
68 
69  lambda = 0.8;
70  maxIter = 200;
71 
72 #ifdef VISP_HAVE_OGRE
73  faces.getOgreContext()->setWindowName("MBT KLT");
74 #endif
75 
76  useOgre = false;
77 }
78 
84 {
85  if(cur != NULL){
86  cvReleaseImage(&cur);
87  cur = NULL;
88  }
89 }
90 
91 void
93 {
94  if(!modelInitialised){
95  throw vpException(vpException::fatalError, "model not initialised");
96  }
97 
98  bool reInitialisation = false;
99  if(!useOgre)
100  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
101  else{
102 #ifdef VISP_HAVE_OGRE
103  if(!faces.isOgreInitialised())
104  faces.initOgre(cam);
105 
106  faces.setVisibleOgre(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
107 
108 #else
109  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
110 #endif
111  }
112 
113  reinit(I);
114 }
115 
116 void
118 {
119  c0Mo = cMo;
120  ctTc0.setIdentity();
121  firstTrack = false;
122 
124 
125  // mask
126  IplImage* mask = cvCreateImage(cvSize((int)I.getWidth(), (int)I.getHeight()), IPL_DEPTH_8U, 1);
127  cvZero(mask);
128 
129  for (unsigned int i = 0; i < faces.size(); i += 1){
130  if(faces[i]->isVisible())
131  faces[i]->updateMask(mask, 255 - i*15, maskBorder);
132  }
133 
134  tracker.initTracking(cur, mask);
135 
136  for (unsigned int i = 0; i < faces.size(); i += 1){
137  if(faces[i]->isVisible()){
138  faces[i]->init(tracker);
139  }
140  }
141 
142  cvReleaseImage(&mask);
143 }
144 
149 void
151 {
152  cMo.setIdentity();
153 
154  if(cur != NULL){
155  cvReleaseImage(&cur);
156  cur = NULL;
157  }
158 
159  compute_interaction = true;
160  firstInitialisation = true;
161  computeCovariance = false;
162  firstTrack = false;
163 
166 
167  tracker.setMaxFeatures(10000);
169  tracker.setQuality(0.01);
174 
177 
178  maskBorder = 5;
179  threshold_outlier = 0.5;
180  percentGood = 0.7;
181 
182  lambda = 0.8;
183  maxIter = 200;
184 
185  faces.reset();
186 
187 #ifdef VISP_HAVE_OGRE
188  useOgre = false;
189 #endif
190 }
191 
199 std::vector<vpImagePoint>
201 {
202  std::vector<vpImagePoint> kltPoints;
203  for (unsigned int i = 0; i < static_cast<unsigned int>(tracker.getNbFeatures()); i ++){
204  int id;
205  float x_tmp, y_tmp;
206  tracker.getFeature((int)i, id, x_tmp, y_tmp);
207  kltPoints.push_back(vpImagePoint(y_tmp, x_tmp));
208  }
209 
210  return kltPoints;
211 }
212 
220 std::map<int, vpImagePoint>
222 {
223  std::map<int, vpImagePoint> kltPoints;
224  for (unsigned int i = 0; i < static_cast<unsigned int>(tracker.getNbFeatures()); i ++){
225  int id;
226  float x_tmp, y_tmp;
227  tracker.getFeature((int)i, id, x_tmp, y_tmp);
228  kltPoints[id] = vpImagePoint(y_tmp, x_tmp);
229  }
230 
231  return kltPoints;
232 }
233 
239 void
248 }
249 
255 void
257 {
258  for (unsigned int i = 0; i < faces.size(); i += 1){
259  faces[i]->setCameraParameters(cam);
260  }
261  this->cam = cam;
262 }
263 
271 void
273 {
274  useOgre = v;
275  if(useOgre){
276 #ifndef VISP_HAVE_OGRE
277  useOgre = false;
278  std::cout << "WARNING: ViSP dosen't have Ogre3D, basic visibility test will be used. setOgreVisibilityTest() set to false." << std::endl;
279 #endif
280  }
281 }
282 
292 void
294 {
295  if(firstTrack){
296  bool reInitialisation = false;
297  if(!useOgre)
298  faces.setVisible(I, cam, cdMo, angleAppears, angleDisappears, reInitialisation);
299  else{
300  #ifdef VISP_HAVE_OGRE
301  faces.setVisibleOgre(I, cam, cdMo, angleAppears, angleDisappears, reInitialisation);
302  #else
303  faces.setVisible(I, cam, cdMo, angleAppears, angleDisappears, reInitialisation);
304  #endif
305  }
306 
307  if(reInitialisation){
308  std::cout << "WARNING: Visibility changed, must reinitialise to update pose" << std::endl;
309  cMo = cdMo;
310  reinit(I);
311  }
312  else{
313  vpHomogeneousMatrix cdMc = cdMo * cMo.inverse();
314  vpHomogeneousMatrix cMcd = cdMc.inverse();
315 
316  vpRotationMatrix cdRc;
317  vpTranslationVector cdtc;
318 
319  cdMc.extract(cdRc);
320  cdMc.extract(cdtc);
321 
322  CvPoint2D32f* initial_guess = NULL;
323  initial_guess = (CvPoint2D32f*)cvAlloc((unsigned int)tracker.getMaxFeatures()*sizeof(initial_guess[0]));
324 
325  for (unsigned int i = 0; i < faces.size(); i += 1){
326  if(faces[i]->isVisible() && faces[i]->hasEnoughPoints()){
327  //Get the normal to the face at the current state cMo
328  vpPlane plan(faces[i]->p[0], faces[i]->p[1], faces[i]->p[2]);
329  plan.changeFrame(cMcd);
330 
331  vpColVector Nc = plan.getNormal();
332  Nc.normalize();
333 
334  float invDc = 1.0f / plan.getD();
335 
336  //Create the homography
337  vpHomography cdHc;
338  vpGEMM(cdtc, Nc, -invDc, cdRc, 1.0, cdHc, VP_GEMM_B_T);
339  cdHc /= cdHc[2][2];
340 
341  //Create the 2D homography
342  vpMatrix cdGc = cam.get_K() * cdHc * cam.get_K_inverse();
343 
344  //Points displacement
345  std::map<int, vpImagePoint>::const_iterator iter = faces[i]->getCurrentPoints().begin();
346  for( ; iter != faces[i]->getCurrentPoints().end(); iter++){
347  vpColVector cdp(3);
348  cdp[0] = iter->second.get_j(); cdp[1] = iter->second.get_i(); cdp[2] = 1.0;
349 
350  double p_mu_t_2 = cdp[0] * cdGc[2][0] + cdp[1] * cdGc[2][1] + cdGc[2][2];
351 
352  if( fabs(p_mu_t_2) < std::numeric_limits<double>::epsilon()){
353  cdp[0] = 0.0;
354  cdp[1] = 0.0;
355  throw vpException(vpException::divideByZeroError, "the depth of the point is calculated to zero");
356  }
357 
358  cdp[0] = (cdp[0] * cdGc[0][0] + cdp[1] * cdGc[0][1] + cdGc[0][2]) / p_mu_t_2;
359  cdp[1] = (cdp[0] * cdGc[1][0] + cdp[1] * cdGc[1][1] + cdGc[1][2]) / p_mu_t_2;
360 
361  //Set value to the KLT tracker
362  initial_guess[(faces[i]->getCurrentPointsInd())[iter->first]].x = (float)cdp[0];
363  initial_guess[(faces[i]->getCurrentPointsInd())[iter->first]].y = (float)cdp[1];
364  }
365  }
366  }
367 
368  tracker.setInitialGuess(&initial_guess);
369 
370  if(initial_guess) cvFree(&initial_guess);
371  initial_guess = NULL;
372 
373  cMo = cdMo;
374  }
375  }
376 }
377 
384 void
385 vpMbKltTracker::initFaceFromCorners(const std::vector<vpPoint>& corners, const unsigned int indexFace)
386 {
387  if( corners.size() > 2){ // This tracker can't handle lignes
388  vpMbtKltPolygon *polygon = new vpMbtKltPolygon;
389  // polygon->setCameraParameters(cam);
390  polygon->setNbPoint(corners.size());
391  polygon->setIndex((int)indexFace);
392  for(unsigned int j = 0; j < corners.size(); j++) {
393  polygon->addPoint(j, corners[j]);
394  }
395  faces.addPolygon(polygon);
396  faces.getPolygon().back()->setCameraParameters(cam);
397 
398  delete polygon;
399  polygon = NULL;
400  }
401 }
402 
410 void
411 vpMbKltTracker::preTracking(const vpImage<unsigned char>& I, unsigned int &nbInfos, unsigned int &nbFaceUsed)
412 {
414  tracker.track(cur);
415 
416  if(!firstTrack)
417  firstTrack = true;
418 
419  nbInfos = 0;
420  nbFaceUsed = 0;
421  for (unsigned int i = 0; i < faces.size(); i += 1){
422  if(faces[i]->isVisible()){
423  faces[i]->computeNbDetectedCurrent(tracker);
424 // faces[i]->ransac();
425  if(faces[i]->hasEnoughPoints()){
426  nbInfos += faces[i]->getNbPointsCur();
427  nbFaceUsed++;
428  }
429  }
430  }
431 }
432 
436 bool
438 {
439  // # For a better Post Tracking, tracker should reinitialise if so faces don't have enough points but are visible.
440  // # Here we are not doing it for more spee performance.
441  bool reInitialisation = false;
442 
443  unsigned int initialNumber = 0;
444  unsigned int currentNumber = 0;
445  unsigned int shift = 0;
446  for (unsigned int i = 0; i < faces.size(); i += 1){
447  if(faces[i]->isVisible()){
448  initialNumber += faces[i]->getInitialNumberPoint();
449  if(faces[i]->hasEnoughPoints()){
450  vpSubColVector sub_w(w, shift, 2*faces[i]->getNbPointsCur());
451  faces[i]->removeOutliers(sub_w, threshold_outlier);
452  shift += 2*faces[i]->getNbPointsCur();
453 
454  currentNumber += faces[i]->getNbPointsCur();
455  }
456 // else{
457 // reInitialisation = true;
458 // break;
459 // }
460  }
461  }
462 
463 // if(!reInitialisation){
464  double value = percentGood * (double)initialNumber;
465  if((double)currentNumber < value){
466 // std::cout << "Too many point disappear : " << initialNumber << "/" << currentNumber << std::endl;
467  reInitialisation = true;
468  }
469  else{
470  if(!useOgre)
471  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
472  else{
473 #ifdef VISP_HAVE_OGRE
474  faces.setVisibleOgre(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
475 #else
476  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
477 #endif
478  }
479  }
480 // }
481 
482  if(reInitialisation)
483  return true;
484 
485  return false;
486 }
487 
494 void
495 vpMbKltTracker::computeVVS(const unsigned int &nbInfos, vpColVector &w)
496 {
497  vpMatrix J; // interaction matrix
498  vpColVector R; // residu
499  vpMatrix J_true; // interaction matrix
500  vpColVector R_true; // residu
501  vpColVector v; // "speed" for VVS
502  vpHomography H;
503  vpColVector w_true;
504  vpRobust robust(2*nbInfos);
505 
506  vpMatrix JTJ, JTR;
507 
508  double normRes = 0;
509  double normRes_1 = -1;
510  unsigned int iter = 0;
511 
512  R.resize(2*nbInfos);
513  J.resize(2*nbInfos, 6, 0);
514 
515  while( ((int)((normRes - normRes_1)*1e8) != 0 ) && (iter<maxIter) ){
516 
517  unsigned int shift = 0;
518  for (unsigned int i = 0; i < faces.size(); i += 1){
519  if(faces[i]->isVisible() && faces[i]->hasEnoughPoints()){
520  vpSubColVector subR(R, shift, 2*faces[i]->getNbPointsCur());
521  vpSubMatrix subJ(J, shift, 0, 2*faces[i]->getNbPointsCur(), 6);
522  try{
523  faces[i]->computeHomography(ctTc0, H);
524  faces[i]->computeInteractionMatrixAndResidu(subR, subJ);
525  }catch(...){
526  std::cerr << "exception while tracking face " << i << std::endl;
527  throw ;
528  }
529 
530  shift += 2*faces[i]->getNbPointsCur();
531  }
532  }
533 
534  /* robust */
535  if(iter == 0){
536  w_true.resize(2*nbInfos);
537  w.resize(2*nbInfos);
538  w = 1;
539  }
540  robust.setIteration(iter);
541  robust.setThreshold(2/cam.get_px());
542  robust.MEstimator( vpRobust::TUKEY, R, w);
543 
544  if(computeCovariance){
545  R_true = R;
546  J_true = J;
547  }
548 
549  normRes_1 = normRes;
550  normRes = 0;
551  for (unsigned int i = 0; i < static_cast<unsigned int>(R.getRows()); i += 1){
552  w_true = w[i] * w[i];
553  R[i] = R[i] * w[i];
554  normRes += R[i];
555  }
556 
557  if((iter == 0) || compute_interaction){
558  for(unsigned int i=0; i<static_cast<unsigned int>(R.getRows()); i++){
559  for(unsigned int j=0; j<6; j++){
560  J[i][j] *= w[i];
561  }
562  }
563  }
564 
565  JTJ = J.AtA();
566  computeJTR(J, R, JTR);
567  v = -lambda * JTJ.pseudoInverse(1e-16) * JTR;
568 
570 
571  iter++;
572  }
573 
574  if(computeCovariance){
575  vpMatrix D;
576  D.diag(w_true);
578  }
579 
580  cMo = ctTc0 * c0Mo;
581 }
582 
590 void
592 {
593  unsigned int nbInfos;
594  unsigned int nbFaceUsed;
595  preTracking(I, nbInfos, nbFaceUsed);
596 
597  if(nbInfos < 4 || nbFaceUsed == 0){
598  vpERROR_TRACE("\n\t\t Error-> not enough data") ;
599  throw vpTrackingException(vpTrackingException::notEnoughPointError, "\n\t\t Error-> not enough data");
600  }
601 
602  vpColVector w;
603  computeVVS(nbInfos, w);
604 
605  if(postTracking(I, w))
606  reinit(I);
607 }
608 
620 void
621 vpMbKltTracker::loadConfigFile(const std::string& configFile)
622 {
623  vpMbKltTracker::loadConfigFile(configFile.c_str());
624 }
625 
669 void
670 vpMbKltTracker::loadConfigFile(const char* configFile)
671 {
672 #ifdef VISP_HAVE_XML2
673  vpMbtKltXmlParser xmlp;
674 
675  xmlp.setMaxFeatures(10000);
676  xmlp.setWindowSize(5);
677  xmlp.setQuality(0.01);
678  xmlp.setMinDistance(5);
679  xmlp.setHarrisParam(0.01);
680  xmlp.setBlockSize(3);
681  xmlp.setPyramidLevels(3);
685 
686  try{
687  std::cout << " *********** Parsing XML for MBT KLT Tracker ************ " << std::endl;
688 
689  xmlp.parse(configFile);
690  }
691  catch(...){
692  vpERROR_TRACE("Can't open XML file \"%s\"\n ", configFile);
693  throw vpException(vpException::ioError, "problem to parse configuration file.");
694  }
695 
696  vpCameraParameters camera;
697  xmlp.getCameraParameters(camera);
698  setCameraParameters(camera);
699 
701  tracker.setWindowSize((int)xmlp.getWindowSize());
702  tracker.setQuality(xmlp.getQuality());
705  tracker.setBlockSize((int)xmlp.getBlockSize());
707  maskBorder = xmlp.getMaskBorder();
710 #else
711  vpTRACE("You need the libXML2 to read the config file %s", configFile);
712 #endif
713 }
714 
725 void
727  const vpColor& col , const unsigned int thickness, const bool displayFullModel)
728 {
729  for (unsigned int i = 0; i < faces.size(); i += 1){
730  if(displayFullModel || faces[i]->isVisible())
731  {
732  faces[i]->changeFrame(cMo);
733  std::vector<vpImagePoint> roi = faces[i]->getRoi(cam);
734  for (unsigned int j = 0; j < faces[i]->getNbPoint(); j += 1){
735  vpImagePoint ip1, ip2;
736  ip1 = roi[j];
737  ip2 = roi[(j+1)%faces[i]->getNbPoint()];
738  vpDisplay::displayLine (I, ip1, ip2, col, thickness);
739  }
740 
741  if(displayFeatures && faces[i]->hasEnoughPoints())
742  faces[i]->displayPrimitive(I);
743 
744 // if(facesTracker[i].hasEnoughPoints())
745 // faces[i]->displayNormal(I);
746  }
747  }
748 
749 #ifdef VISP_HAVE_OGRE
750  if(useOgre)
751  faces.displayOgre(cMo);
752 #endif
753 }
754 
765 void
767  const vpColor& col , const unsigned int thickness, const bool displayFullModel)
768 {
769  for (unsigned int i = 0; i < faces.size(); i += 1){
770  if(displayFullModel || faces[i]->isVisible())
771  {
772  faces[i]->changeFrame(cMo);
773  std::vector<vpImagePoint> roi = faces[i]->getRoi(cam);
774  for (unsigned int j = 0; j < faces[i]->getNbPoint(); j += 1){
775  vpImagePoint ip1, ip2;
776  ip1 = roi[j];
777  ip2 = roi[(j+1)%faces[i]->getNbPoint()];
778  vpDisplay::displayLine (I, ip1, ip2, col, thickness);
779  }
780 
781  if(displayFeatures && faces[i]->hasEnoughPoints())
782  faces[i]->displayPrimitive(I);
783 
784 // if(facesTracker[i].hasEnoughPoints())
785 // faces[i]->displayNormal(I);
786  }
787  }
788 
789 #ifdef VISP_HAVE_OGRE
790  if(useOgre)
791  faces.displayOgre(cMo);
792 #endif
793 }
794 
803 void
805 {
806  unsigned int nbTotalPoints = 0;
807  for (unsigned int i = 0; i < faces.size(); i += 1){
808  if(faces[i]->isVisible()){
809  nbTotalPoints += faces[i]->getNbPointsCur();
810  }
811  }
812 
813  if(nbTotalPoints < 10){
814  std::cerr << "test tracking failed (too few points to realise a good tracking)." << std::endl;
816  "test tracking failed (too few points to realise a good tracking).");
817  }
818 }
819 
820 #endif //VISP_HAVE_OPENCV
void setKltOpencv(const vpKltOpencv &t)
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 track(const vpImage< unsigned char > &I)
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
vpMatrix get_K_inverse() const
void setWindowName(const Ogre::String &n)
Definition: vpAROgre.h:234
int getPyramidLevels() const
Get the number of pyramid levels.
Definition: vpKltOpencv.h:305
unsigned int getMaskBorder() const
void setQuality(const double &q)
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
vpMatrix covarianceMatrix
Covariance matrix.
Definition: vpMbTracker.h:120
virtual ~vpMbKltTracker()
void setQuality(double input)
Definition: vpKltOpencv.h:227
double getHarrisParam() const
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:174
void track(const IplImage *I)
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
Definition: vpRobust.cpp:138
int getMaxFeatures() const
Get Max number of features.
Definition: vpKltOpencv.h:293
void parse(const char *filename)
unsigned int getWidth() const
Definition: vpImage.h:154
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
unsigned int maxIter
The maximum iteration of the virtual visual servoing stage.
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
#define vpERROR_TRACE
Definition: vpDebug.h:379
#define vpTRACE
Definition: vpDebug.h:401
IplImage * cur
Temporary OpenCV image for fast conversion.
double getHarrisFreeParameter() const
Get Harris free parameter.
Definition: vpKltOpencv.h:289
void setIdentity()
Basic initialisation (identity)
Class to define colors available for display functionnalities.
Definition: vpColor.h:123
double percentGood
Percentage of good points, according to the initial number, that must have the tracker.
vpHomogeneousMatrix cMo
The current pose.
Definition: vpMbTracker.h:108
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
unsigned int getBlockSize() const
void setUseHarris(const int input)
Definition: vpKltOpencv.h:256
bool modelInitialised
Flag used to ensure that the CAD model is loaded before the initialisation.
Definition: vpMbTracker.h:112
void getCameraParameters(vpCameraParameters &_cam) const
void initOgre(vpCameraParameters _cam=vpCameraParameters())
error that can be emited by ViSP classes.
Definition: vpException.h:75
void computeJTR(const vpMatrix &J, const vpColVector &R, vpMatrix &JTR)
double getAngleAppear() const
double getAngleDisappear() const
unsigned int getMaxFeatures() const
void setInitialGuess(CvPoint2D32f **guess_pts)
void setPyramidLevels(const int input)
Definition: vpKltOpencv.h:266
void setBlockSize(const int input)
Definition: vpKltOpencv.h:255
Definition of the vpSubMatrix vpSubMatrix class provides a mask on a vpMatrix all properties of vpMat...
Definition: vpSubMatrix.h:66
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
Definition: vpMbTracker.h:118
bool firstInitialisation
Flag to specify whether the init method is called the first or not (specific calls to realise in this...
static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b)
virtual void reinit(const vpImage< unsigned char > &I)
virtual void testTracking()
virtual void loadConfigFile(const std::string &configFile)
vpCameraParameters cam
The camera parameters.
Definition: vpMbTracker.h:106
The vpRotationMatrix considers the particular case of a rotation matrix.
vpHomogeneousMatrix ctTc0
The estimated displacement of the pose between the current instant and the initial position...
unsigned int setVisibleOgre(const vpImage< unsigned char > &_I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:174
void addPoint(const unsigned int n, const vpPoint &P)
vpAROgre * getOgreContext()
void setPyramidLevels(const unsigned int &pL)
Parse an Xml file to extract configuration parameters of a Mbt Klt object.Data parser for the KLT mod...
unsigned int getWindowSize() const
Error that can be emited by the vpTracker class and its derivates.
void getFeature(int index, int &id, float &x, float &y) const
void setWindowSize(const int input)
Definition: vpKltOpencv.h:226
vpMatrix AtA() const
Definition: vpMatrix.cpp:1357
double getQuality() const
Get the quality of the tracker.
Definition: vpKltOpencv.h:307
void changeFrame(const vpHomogeneousMatrix &cMo)
Definition: vpPlane.cpp:352
void setWindowSize(const unsigned int &w)
void setTrackerId(int tid)
Definition: vpKltOpencv.h:267
Definition of the vpSubColVector vpSubColVector class provides a mask on a vpColVector all properties...
unsigned int maskBorder
Erosion of the mask.
Generic class defining intrinsic camera parameters.
int getBlockSize() const
Get the block size.
Definition: vpKltOpencv.h:283
bool useOgre
Use Ogre3d for visibility tests.
vpMbHiddenFaces< vpMbtKltPolygon > faces
Set of faces describing the object.
void extract(vpRotationMatrix &R) const
void setAngleDisappear(const double &adisappear)
void setHarrisParam(const double &hp)
bool firstTrack
First track() called.
void setMinDistance(const double &mD)
void addPolygon(PolygonType *p)
unsigned int setVisible(const vpHomogeneousMatrix &_cMo)
vpKltOpencv tracker
Points tracker.
vpColVector getNormal() const
Definition: vpPlane.cpp:226
unsigned int size()
double get_px() const
static double rad(double deg)
Definition: vpMath.h:100
double threshold_outlier
Threshold below which the weight associated to a point to consider this one as an outlier...
void diag(const vpColVector &A)
Definition: vpMatrix.cpp:2521
void preTracking(const vpImage< unsigned char > &I, unsigned int &nbInfos, unsigned int &nbFaceUsed)
void setAngleAppear(const double &aappear)
double lambda
The gain of the virtual visual servoing stage.
void setMaxFeatures(const unsigned int &mF)
void initTracking(const IplImage *I, const IplImage *mask=NULL)
double getQuality() const
vpMatrix get_K() const
static double deg(double rad)
Definition: vpMath.h:93
bool displayFeatures
If true, the features are displayed.
Definition: vpMbTracker.h:122
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
virtual void setOgreVisibilityTest(const bool &v)
std::map< int, vpImagePoint > getKltImagePointsWithId()
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented with OpenCV.
Definition: vpKltOpencv.h:141
vpHomogeneousMatrix inverse() const
static vpHomogeneousMatrix direct(const vpColVector &v)
int getNbFeatures() const
Get the current number of features.
Definition: vpKltOpencv.h:297
Contains an M-Estimator and various influence function.
Definition: vpRobust.h:63
virtual void initFaceFromCorners(const std::vector< vpPoint > &corners, const unsigned int indexFace=-1)
double angleAppears
Angle used to detect a face apparition.
void displayOgre(const vpHomogeneousMatrix &_cMo)
unsigned int getHeight() const
Definition: vpImage.h:145
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
Definition: vpMatrix.cpp:1810
virtual void init(const vpImage< unsigned char > &I)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
std::vector< vpImagePoint > getKltImagePoints()
void setBlockSize(const unsigned int &bs)
This class defines the container for a plane geometrical structure.
Definition: vpPlane.h:67
double getMinDistance() const
Get Min Distance.
Definition: vpKltOpencv.h:295
void setMaxFeatures(const int input)
double angleDisappears
Angle used to detect a face disparition.
void setThreshold(const double noise_threshold)
Definition: vpRobust.h:128
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:157
double getMinDistance() const
virtual void setNbPoint(const unsigned int nb)
vpColVector & normalize()
normalise the vector
void setMinDistance(double input)
Definition: vpKltOpencv.h:236
void setIteration(const unsigned int iter)
Set iteration.
Definition: vpRobust.h:122
void computeVVS(const unsigned int &nbInfos, vpColVector &w)
Class that consider the case of a translation vector.
void setMaskBorder(const unsigned int &mb)
vpHomogeneousMatrix c0Mo
Initial pose.
int getWindowSize() const
Get Max number of features.
Definition: vpKltOpencv.h:309
double getD() const
Definition: vpPlane.h:118
unsigned int getPyramidLevels() const
virtual 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)
void setHarrisFreeParameter(double input)
Definition: vpKltOpencv.h:245
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:94
std::vector< PolygonType * > & getPolygon()
virtual void setIndex(const int i)
Definition: vpMbtPolygon.h:117