ViSP  2.10.0
vpMbKltTracker.cpp
1 /****************************************************************************
2  *
3  * $Id: vpMbKltTracker.cpp 5189 2015-01-21 16:42:18Z ayol $
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  * Model based tracker using only KLT
35  *
36  * Authors:
37  * Romain Tallonneau
38  * Aurelien Yol
39  *
40  *****************************************************************************/
41 
42 #include <visp/vpImageConvert.h>
43 #include <visp/vpMbKltTracker.h>
44 #include <visp/vpVelocityTwistMatrix.h>
45 #include <visp/vpTrackingException.h>
46 
47 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
48 
50  :
51 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
52  cur(),
53 #else
54  cur(NULL),
55 #endif
56  c0Mo(), compute_interaction(true),
57  firstInitialisation(true), maskBorder(5), lambda(0.8), maxIter(200), threshold_outlier(0.5),
58  percentGood(0.6), ctTc0(), tracker(), firstTrack(false), kltPolygons(), cylinders_disp(), circles_disp()
59 {
62  tracker.setMaxFeatures(10000);
64  tracker.setQuality(0.01);
69 
72 
73 #ifdef VISP_HAVE_OGRE
74  faces.getOgreContext()->setWindowName("MBT Klt");
75 #endif
76 }
77 
83 {
84 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
85  if(cur != NULL){
86  cvReleaseImage(&cur);
87  cur = NULL;
88  }
89 #endif
90 
91  // delete the Klt Polygon features
92  vpMbtDistanceKltPoints *kltpoly;
93  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
94  kltpoly = *it;
95  if (kltpoly!=NULL){
96  delete kltpoly ;
97  }
98  kltpoly = NULL ;
99  }
100  kltPolygons.clear();
101 
102  // delete the structures used to display cylinders and circles
105  for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders_disp.begin(); it!=cylinders_disp.end(); ++it){
106  cy = *it;
107  if (cy!=NULL){
108  delete cy ;
109  }
110  cy = NULL ;
111  }
112 
113  for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles_disp.begin(); it!=circles_disp.end(); ++it){
114  ci = *it;
115  if (ci!=NULL){
116  delete ci ;
117  }
118  ci = NULL ;
119  }
120 
121  cylinders_disp.clear();
122  circles_disp.clear();
123 }
124 
125 void
127 {
128  if(!modelInitialised){
129  throw vpException(vpException::fatalError, "model not initialized");
130  }
131 
132  bool reInitialisation = false;
133  if(!useOgre)
134  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
135  else{
136 #ifdef VISP_HAVE_OGRE
137  if(!faces.isOgreInitialised()){
139  faces.initOgre(cam);
140  }
141 
142  faces.setVisibleOgre(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
143 
144 #else
145  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
146 #endif
147  }
148  reinit(I);
149 }
150 
151 void
153 {
154  c0Mo = cMo;
155  ctTc0.setIdentity();
156  firstTrack = false;
157 
159 
160  cam.computeFov(I.getWidth(), I.getHeight());
161 
162  // mask
163 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
164  cv::Mat mask((int)I.getRows(), (int)I.getCols(), CV_8UC1, cv::Scalar(0));
165 #else
166  IplImage* mask = cvCreateImage(cvSize((int)I.getWidth(), (int)I.getHeight()), IPL_DEPTH_8U, 1);
167  cvZero(mask);
168 #endif
169  unsigned char val = 255/* - i*15*/;
170 
171  vpMbtDistanceKltPoints *kltpoly;
172  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
173  kltpoly = *it;
174  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2){
175  kltpoly->polygon->computeRoiClipped(cam);
176  kltpoly->updateMask(mask, val, maskBorder);
177  }
178  }
179 
180  tracker.initTracking(cur, mask);
181 // tracker.track(cur); // AY: Not sure to be usefull but makes sure that the points are valid for tracking and avoid too fast reinitialisations.
182 // vpCTRACE << "init klt. detected " << tracker.getNbFeatures() << " points" << std::endl;
183 
184  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
185  kltpoly = *it;
186  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2){
187  kltpoly->init(tracker);
188  }
189  }
190 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
191  cvReleaseImage(&mask);
192 #endif
193 }
194 
199 void
201 {
202  cMo.setIdentity();
203 
204 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
205  if(cur != NULL){
206  cvReleaseImage(&cur);
207  cur = NULL;
208  }
209 #endif
210 
211  // delete the Klt Polygon features
212  vpMbtDistanceKltPoints *kltpoly;
213  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
214  kltpoly = *it;
215  if (kltpoly!=NULL){
216  delete kltpoly ;
217  }
218  kltpoly = NULL ;
219  }
220  kltPolygons.clear();
221 
222  // delete the structures used to display cylinders and circles
225  for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders_disp.begin(); it!=cylinders_disp.end(); ++it){
226  cy = *it;
227  if (cy!=NULL){
228  delete cy ;
229  }
230  cy = NULL ;
231  }
232 
233  for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles_disp.begin(); it!=circles_disp.end(); ++it){
234  ci = *it;
235  if (ci!=NULL){
236  delete ci ;
237  }
238  ci = NULL ;
239  }
240 
241  cylinders_disp.clear();
242  circles_disp.clear();
243 
244  compute_interaction = true;
245  firstInitialisation = true;
246  computeCovariance = false;
247  firstTrack = false;
248 
251 
252  tracker.setMaxFeatures(10000);
254  tracker.setQuality(0.01);
259 
262 
264 
265  maskBorder = 5;
266  threshold_outlier = 0.5;
267  percentGood = 0.7;
268 
269  lambda = 0.8;
270  maxIter = 200;
271 
272  faces.reset();
273 
274 #ifdef VISP_HAVE_OGRE
275  useOgre = false;
276 #endif
277 }
278 
286 std::vector<vpImagePoint>
288 {
289  std::vector<vpImagePoint> kltPoints;
290  for (unsigned int i = 0; i < static_cast<unsigned int>(tracker.getNbFeatures()); i ++){
291  int id;
292  float x_tmp, y_tmp;
293  tracker.getFeature((int)i, id, x_tmp, y_tmp);
294  kltPoints.push_back(vpImagePoint(y_tmp, x_tmp));
295  }
296 
297  return kltPoints;
298 }
299 
307 std::map<int, vpImagePoint>
309 {
310  std::map<int, vpImagePoint> kltPoints;
311  for (unsigned int i = 0; i < static_cast<unsigned int>(tracker.getNbFeatures()); i ++){
312  int id;
313  float x_tmp, y_tmp;
314  tracker.getFeature((int)i, id, x_tmp, y_tmp);
315  kltPoints[id] = vpImagePoint(y_tmp, x_tmp);
316  }
317 
318  return kltPoints;
319 }
320 
326 void
335 }
336 
342 void
344 {
345 // for (unsigned int i = 0; i < faces.size(); i += 1){
346 // faces[i]->setCameraParameters(camera);
347 // }
348 
349  vpMbtDistanceKltPoints *kltpoly;
350  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
351  kltpoly = *it;
352  kltpoly->setCameraParameters(camera);
353  }
354 
355  this->cam = camera;
356 }
357 
367 void
369 {
370  if(firstTrack)
371  {
372  bool reInitialisation = false;
373  if(!useOgre)
374  faces.setVisible(I, cam, cdMo, angleAppears, angleDisappears, reInitialisation);
375  else{
376 #ifdef VISP_HAVE_OGRE
377  faces.setVisibleOgre(I, cam, cdMo, angleAppears, angleDisappears, reInitialisation);
378 #else
379  faces.setVisible(I, cam, cdMo, angleAppears, angleDisappears, reInitialisation);
380 #endif
381  }
382  if(reInitialisation){
383  std::cout << "WARNING: Visibility changed, must reinitialize to update pose" << std::endl;
384  cMo = cdMo;
385  reinit(I);
386  }
387  else{
388  vpMbtDistanceKltPoints *kltpoly;
389 
390 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
391  std::vector<cv::Point2f> initial_pts;
392  std::vector<long> initial_ids;
393 #else
394  unsigned int nbp = 0;
395  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it) {
396  kltpoly = *it;
397  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2 && kltpoly->hasEnoughPoints() )
398  nbp += (*it)->getCurrentNumberPoints();
399  }
400 
401  CvPoint2D32f* initial_pts = NULL;
402  initial_pts = (CvPoint2D32f*)cvAlloc(nbp*sizeof(initial_pts[0]));
403  long *initial_ids = new long [nbp];
404  unsigned int iter_points = 0;
405 #endif
406  vpHomogeneousMatrix cdMc = cdMo * cMo.inverse();
407  vpHomogeneousMatrix cMcd = cdMc.inverse();
408 
409  vpRotationMatrix cdRc;
410  vpTranslationVector cdtc;
411 
412  cdMc.extract(cdRc);
413  cdMc.extract(cdtc);
414 
415  unsigned int nbCur = 0;
416 
417  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it) {
418  kltpoly = *it;
419 
420  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2 && kltpoly->hasEnoughPoints() ) {
421 
422  //Get the normal to the face at the current state cMo
423  vpPlane plan(kltpoly->polygon->p[0], kltpoly->polygon->p[1], kltpoly->polygon->p[2]);
424  plan.changeFrame(cMcd);
425 
426  vpColVector Nc = plan.getNormal();
427  Nc.normalize();
428 
429  double invDc = 1.0 / plan.getD();
430 
431  //Create the homography
432  vpMatrix cdHc;
433  vpGEMM(cdtc, Nc, -invDc, cdRc, 1.0, cdHc, VP_GEMM_B_T);
434  cdHc /= cdHc[2][2];
435 
436  //Create the 2D homography
437  vpMatrix cdGc = cam.get_K() * cdHc * cam.get_K_inverse();
438 
439  //Points displacement
440  std::map<int, vpImagePoint>::const_iterator iter = kltpoly->getCurrentPoints().begin();
441  nbCur+= (unsigned int)kltpoly->getCurrentPoints().size();
442  for( ; iter != kltpoly->getCurrentPoints().end(); iter++){
443  vpColVector cdp(3);
444  cdp[0] = iter->second.get_j(); cdp[1] = iter->second.get_i(); cdp[2] = 1.0;
445 
446  double p_mu_t_2 = cdp[0] * cdGc[2][0] + cdp[1] * cdGc[2][1] + cdGc[2][2];
447 
448  if( fabs(p_mu_t_2) < std::numeric_limits<double>::epsilon()){
449  cdp[0] = 0.0;
450  cdp[1] = 0.0;
451  throw vpException(vpException::divideByZeroError, "the depth of the point is calculated to zero");
452  }
453 
454  cdp[0] = (cdp[0] * cdGc[0][0] + cdp[1] * cdGc[0][1] + cdGc[0][2]) / p_mu_t_2;
455  cdp[1] = (cdp[0] * cdGc[1][0] + cdp[1] * cdGc[1][1] + cdGc[1][2]) / p_mu_t_2;
456 
457  //Set value to the KLT tracker
458 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
459  cv::Point2f p((float)cdp[0], (float)cdp[1]);
460  initial_pts.push_back(p);
461  initial_ids.push_back((size_t)(kltpoly->getCurrentPointsInd())[(size_t)iter->first]);
462 #else
463  initial_pts[iter_points].x = (float)cdp[0];
464  initial_pts[iter_points].y = (float)cdp[1];
465  initial_ids[iter_points++] = (kltpoly->getCurrentPointsInd())[(size_t)iter->first];
466 #endif
467  }
468  }
469  }
470 
472 
473 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
474  tracker.initTracking(cur,initial_pts,initial_ids); // false to keep the id of the points
475 #else
476  tracker.initTracking(cur, initial_pts, initial_ids, iter_points);
477 
478  if(initial_pts) cvFree(&initial_pts);
479  initial_pts = NULL;
480  delete [] initial_ids;
481 #endif
482 
483  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
484  kltpoly = *it;
485  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2){
486  kltpoly->polygon->computeRoiClipped(cam);
487  kltpoly->init(tracker);
488  }
489  }
490 
491  cMo = cdMo;
492  c0Mo = cMo;
493  ctTc0.setIdentity();
494  firstTrack = false;
495  }
496  }
497  else{
498  cMo = cdMo;
499  init(I);
500  }
501 }
502 
508 void
510 {
512  kltPoly->setCameraParameters(cam) ;
513  kltPoly->polygon = &polygon;
514  kltPolygons.push_back(kltPoly);
515 }
521 void
523 {
525  kltPoly->setCameraParameters(cam) ;
526  kltPoly->polygon = &polygon;
527  kltPolygons.push_back(kltPoly);
528 }
529 
537 void
538 vpMbKltTracker::preTracking(const vpImage<unsigned char>& I, unsigned int &nbInfos, unsigned int &nbFaceUsed)
539 {
541  tracker.track(cur);
542 
543  if(!firstTrack)
544  firstTrack = true;
545 
546  nbInfos = 0;
547  nbFaceUsed = 0;
548  vpMbtDistanceKltPoints *kltpoly;
549 // for (unsigned int i = 0; i < faces.size(); i += 1){
550  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
551  kltpoly = *it;
552  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2){
554 // faces[i]->ransac();
555  if(kltpoly->hasEnoughPoints()){
556  nbInfos += kltpoly->getCurrentNumberPoints();
557  nbFaceUsed++;
558  }
559  }
560  }
561 }
562 
566 bool
568 {
569  // # For a better Post Tracking, tracker should reinitialize if so faces don't have enough points but are visible.
570  // # Here we are not doing it for more speed performance.
571  bool reInitialisation = false;
572 
573  unsigned int initialNumber = 0;
574  unsigned int currentNumber = 0;
575  unsigned int shift = 0;
576  vpMbtDistanceKltPoints *kltpoly;
577 // for (unsigned int i = 0; i < faces.size(); i += 1){
578  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
579  kltpoly = *it;
580  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2){
581  initialNumber += kltpoly->getInitialNumberPoint();
582  if(kltpoly->hasEnoughPoints()){
583  vpSubColVector sub_w(w, shift, 2*kltpoly->getCurrentNumberPoints());
584  kltpoly->removeOutliers(sub_w, threshold_outlier);
585  shift += 2*kltpoly->getCurrentNumberPoints();
586 
587  currentNumber += kltpoly->getCurrentNumberPoints();
588  }
589 // else{
590 // reInitialisation = true;
591 // break;
592 // }
593  }
594  }
595 
596 // if(!reInitialisation){
597  double value = percentGood * (double)initialNumber;
598  if((double)currentNumber < value){
599 // std::cout << "Too many point disappear : " << initialNumber << "/" << currentNumber << std::endl;
600  reInitialisation = true;
601  }
602  else{
603  if(!useOgre)
604  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
605  else{
606 #ifdef VISP_HAVE_OGRE
607  faces.setVisibleOgre(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
608 #else
609  faces.setVisible(I, cam, cMo, angleAppears, angleDisappears, reInitialisation);
610 #endif
611  }
612  }
613 // }
614 
615  if(reInitialisation)
616  return true;
617 
618  return false;
619 }
620 
627 void
628 vpMbKltTracker::computeVVS(const unsigned int &nbInfos, vpColVector &w)
629 {
630  vpMatrix L; // interaction matrix
631  vpColVector R; // residu
632  vpMatrix L_true; // interaction matrix
633  vpMatrix LVJ_true;
634  //vpColVector R_true; // residu
635  vpColVector v; // "speed" for VVS
636  vpHomography H;
637  vpColVector w_true;
638  vpRobust robust(2*nbInfos);
639 
640  vpMatrix LTL, LTR;
641  vpHomogeneousMatrix cMoPrev;
642 
643  double normRes = 0;
644  double normRes_1 = -1;
645  unsigned int iter = 0;
646 
647  R.resize(2*nbInfos);
648  L.resize(2*nbInfos, 6, 0);
649 
650  while( ((int)((normRes - normRes_1)*1e8) != 0 ) && (iter<maxIter) ){
651 
652  unsigned int shift = 0;
653  vpMbtDistanceKltPoints *kltpoly;
654  // for (unsigned int i = 0; i < faces.size(); i += 1){
655  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
656  kltpoly = *it;
657  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2 &&
658  kltpoly->hasEnoughPoints()){
659  vpSubColVector subR(R, shift, 2*kltpoly->getCurrentNumberPoints());
660  vpSubMatrix subL(L, shift, 0, 2*kltpoly->getCurrentNumberPoints(), 6);
661  try{
662  kltpoly->computeHomography(ctTc0, H);
663  kltpoly->computeInteractionMatrixAndResidu(subR, subL);
664  }catch(...){
665  throw vpTrackingException(vpTrackingException::fatalError, "Cannot compute interaction matrix");
666  }
667 
668  shift += 2*kltpoly->getCurrentNumberPoints();
669  }
670  }
671 
672  /* robust */
673  if(iter == 0){
674  w_true.resize(2*nbInfos);
675  w.resize(2*nbInfos);
676  w = 1;
677  w_true = 1;
678  }
679  robust.setIteration(iter);
680  robust.setThreshold(2/cam.get_px());
681  robust.MEstimator( vpRobust::TUKEY, R, w);
682 
683  m_error = R;
684  if(computeCovariance){
685  L_true = L;
686  if(!isoJoIdentity){
688  cVo.buildFrom(cMo);
689  LVJ_true = (L*cVo*oJo);
690  }
691  }
692 
693  normRes_1 = normRes;
694  normRes = 0;
695  for (unsigned int i = 0; i < static_cast<unsigned int>(R.getRows()); i += 1){
696  w_true[i] = w[i];
697  R[i] = R[i] * w[i];
698  normRes += R[i];
699  }
700 
701  if((iter == 0) || compute_interaction){
702  for(unsigned int i=0; i<static_cast<unsigned int>(R.getRows()); i++){
703  for(unsigned int j=0; j<6; j++){
704  L[i][j] *= w[i];
705  }
706  }
707  }
708 
709  if(isoJoIdentity){
710  LTL = L.AtA();
711  computeJTR(L, R, LTR);
712  v = -lambda * LTL.pseudoInverse(1e-16) * LTR;
713  }
714  else{
716  cVo.buildFrom(cMo);
717  vpMatrix LVJ = (L*cVo*oJo);
718  vpMatrix LVJTLVJ = (LVJ).AtA();
719  vpMatrix LVJTR;
720  computeJTR(LVJ, R, LVJTR);
721  v = -lambda*LVJTLVJ.pseudoInverse(1e-16)*LVJTR;
722  v = cVo * v;
723  }
724 
726  cMoPrev = cMo;
727  cMo = ctTc0 * c0Mo;
728 
729  iter++;
730  }
731 
732  if(computeCovariance){
733  vpMatrix D;
734  D.diag(w_true);
735 
736  // Note that here the covariance is computed on cMoPrev for time computation efficiency
737  if(isoJoIdentity){
738  computeCovarianceMatrix(cMoPrev,m_error,L_true,D);
739  }
740  else{
741  computeCovarianceMatrix(cMoPrev,m_error,LVJ_true,D);
742  }
743  }
744 }
745 
753 void
755 {
756  unsigned int nbInfos = 0;
757  unsigned int nbFaceUsed = 0;
758 
759  try{
760  preTracking(I, nbInfos, nbFaceUsed);
761  }
762  catch(vpException &e){
763  throw e;
764  }
765 
766  if(nbInfos < 4 || nbFaceUsed == 0){
767  vpERROR_TRACE("\n\t\t Error-> not enough data") ;
768  throw vpTrackingException(vpTrackingException::notEnoughPointError, "\n\t\t Error-> not enough data");
769  }
770 
771  //vpColVector w;
772  computeVVS(nbInfos, m_w);
773 
774  if(postTracking(I, m_w))
775  reinit(I);
776 }
777 
789 void
790 vpMbKltTracker::loadConfigFile(const std::string& configFile)
791 {
792  vpMbKltTracker::loadConfigFile(configFile.c_str());
793 }
794 
841 void
842 vpMbKltTracker::loadConfigFile(const char* configFile)
843 {
844 #ifdef VISP_HAVE_XML2
845  vpMbtKltXmlParser xmlp;
846 
847  xmlp.setMaxFeatures(10000);
848  xmlp.setWindowSize(5);
849  xmlp.setQuality(0.01);
850  xmlp.setMinDistance(5);
851  xmlp.setHarrisParam(0.01);
852  xmlp.setBlockSize(3);
853  xmlp.setPyramidLevels(3);
857 
858  try{
859  std::cout << " *********** Parsing XML for MBT KLT Tracker ************ " << std::endl;
860  xmlp.parse(configFile);
861  }
862  catch(...){
863  vpERROR_TRACE("Can't open XML file \"%s\"\n ", configFile);
864  throw vpException(vpException::ioError, "problem to parse configuration file.");
865  }
866 
867  vpCameraParameters camera;
868  xmlp.getCameraParameters(camera);
869  setCameraParameters(camera);
870 
872  tracker.setWindowSize((int)xmlp.getWindowSize());
873  tracker.setQuality(xmlp.getQuality());
876  tracker.setBlockSize((int)xmlp.getBlockSize());
878  maskBorder = xmlp.getMaskBorder();
881 
882  if(xmlp.hasNearClippingDistance())
884 
885  if(xmlp.hasFarClippingDistance())
887 
888  if(xmlp.getFovClipping())
890 
891 #else
892  vpTRACE("You need the libXML2 to read the config file %s", configFile);
893 #endif
894 }
895 
906 void
908  const vpColor& col, const unsigned int thickness, const bool displayFullModel)
909 {
910  vpCameraParameters c = camera;
911 
912  if(clippingFlag > 3) // Contains at least one FOV constraint
913  c.computeFov(I.getWidth(), I.getHeight());
914 
915  vpMbtDistanceKltPoints *kltpoly;
916 // for (unsigned int i = 0; i < faces.size(); i += 1){
917  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
918  kltpoly = *it;
919  if(displayFullModel || kltpoly->polygon->isVisible())
920  {
921  kltpoly->polygon->changeFrame(cMo_);
922  kltpoly->polygon->computeRoiClipped(c);
923  std::vector<std::pair<vpImagePoint,unsigned int> > roi;
924  kltpoly->polygon->getRoiClipped(c, roi);
925 
926  for (unsigned int j = 0; j < roi.size(); j += 1){
927  if(((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::NEAR_CLIPPING) == 0) &&
928  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::FAR_CLIPPING) == 0) &&
929  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::DOWN_CLIPPING) == 0) &&
930  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::UP_CLIPPING) == 0) &&
931  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::LEFT_CLIPPING) == 0) &&
932  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::RIGHT_CLIPPING) == 0)){
933  vpImagePoint ip1, ip2;
934  ip1 = roi[j].first;
935  ip2 = roi[(j+1)%roi.size()].first;
936 
937  vpDisplay::displayLine (I, ip1, ip2, col, thickness);
938  }
939  }
940  }
941  if(displayFeatures && kltpoly->hasEnoughPoints() && kltpoly->polygon->isVisible()) {
942  kltpoly->displayPrimitive(I);
943 // faces[i]->displayNormal(I);
944  }
945  }
946 
947  for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders_disp.begin(); it!=cylinders_disp.end(); ++it){
948  (*it)->display(I, cMo_, camera, col, thickness);
949  }
950 
951  for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles_disp.begin(); it!=circles_disp.end(); ++it){
952  (*it)->display(I, cMo_, camera, col, thickness);
953  }
954 
955 #ifdef VISP_HAVE_OGRE
956  if(useOgre)
957  faces.displayOgre(cMo_);
958 #endif
959 }
960 
971 void
973  const vpColor& col , const unsigned int thickness, const bool displayFullModel)
974 {
975  vpCameraParameters c = camera;
976 
977  if(clippingFlag > 3) // Contains at least one FOV constraint
978  c.computeFov(I.getWidth(), I.getHeight());
979 
980  vpMbtDistanceKltPoints *kltpoly;
981 // for (unsigned int i = 0; i < faces.size(); i += 1){
982  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
983  kltpoly = *it;
984  if(displayFullModel || kltpoly->polygon->isVisible())
985  {
986  kltpoly->polygon->changeFrame(cMo_);
987  kltpoly->polygon->computeRoiClipped(c);
988  std::vector<std::pair<vpImagePoint,unsigned int> > roi;
989  kltpoly->polygon->getRoiClipped(c, roi);
990 
991  for (unsigned int j = 0; j < roi.size(); j += 1){
992  if(((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::NEAR_CLIPPING) == 0) &&
993  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::FAR_CLIPPING) == 0) &&
994  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::DOWN_CLIPPING) == 0) &&
995  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::UP_CLIPPING) == 0) &&
996  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::LEFT_CLIPPING) == 0) &&
997  ((roi[(j+1)%roi.size()].second & roi[j].second & vpMbtPolygon::RIGHT_CLIPPING) == 0)){
998  vpImagePoint ip1, ip2;
999  ip1 = roi[j].first;
1000  ip2 = roi[(j+1)%roi.size()].first;
1001 
1002  vpDisplay::displayLine (I, ip1, ip2, col, thickness);
1003  }
1004  }
1005  }
1006  if(displayFeatures && kltpoly->hasEnoughPoints() && kltpoly->polygon->isVisible()) {
1007  kltpoly->displayPrimitive(I);
1008 // faces[i]->displayNormal(I);
1009  }
1010  }
1011 
1012  for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders_disp.begin(); it!=cylinders_disp.end(); ++it){
1013  (*it)->display(I, cMo_, camera, col, thickness);
1014  }
1015 
1016  for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles_disp.begin(); it!=circles_disp.end(); ++it){
1017  (*it)->display(I, cMo_, camera, col, thickness);
1018  }
1019 
1020 #ifdef VISP_HAVE_OGRE
1021  if(useOgre)
1022  faces.displayOgre(cMo_);
1023 #endif
1024 }
1025 
1034 void
1036 {
1037  unsigned int nbTotalPoints = 0;
1038  vpMbtDistanceKltPoints *kltpoly;
1039 // for (unsigned int i = 0; i < faces.size(); i += 1){
1040  for(std::list<vpMbtDistanceKltPoints*>::const_iterator it=kltPolygons.begin(); it!=kltPolygons.end(); ++it){
1041  kltpoly = *it;
1042  if(kltpoly->polygon->isVisible() && kltpoly->polygon->getNbPoint() > 2){
1043  nbTotalPoints += kltpoly->getCurrentNumberPoints();
1044  }
1045  }
1046 
1047  if(nbTotalPoints < 10){
1048  std::cerr << "test tracking failed (too few points to realize a good tracking)." << std::endl;
1050  "test tracking failed (too few points to realize a good tracking).");
1051  }
1052 }
1053 
1063 void
1064 vpMbKltTracker::initCylinder(const vpPoint& p1, const vpPoint &p2, const double radius, const int /*idFace*/,
1065  const std::string &name)
1066 {
1067  addCylinder(p1, p2, radius, name);
1068 }
1069 
1078 void
1079 vpMbKltTracker::addCylinder(const vpPoint &P1, const vpPoint &P2, const double r, const std::string &name)
1080 {
1081  bool already_here = false ;
1082  vpMbtDistanceCylinder *cy ;
1083 
1084 // for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders_disp.begin(); it!=cylinders_disp.end(); ++it){
1085 // cy = *it;
1086 // if((samePoint(*(cy->p1),P1) && samePoint(*(cy->p2),P2)) ||
1087 // (samePoint(*(cy->p1),P2) && samePoint(*(cy->p2),P1)) ){
1088 // already_here = (std::fabs(cy->radius - r) < std::numeric_limits<double>::epsilon() * vpMath::maximum(cy->radius, r));
1089 // }
1090 // }
1091 
1092  if (!already_here){
1093  cy = new vpMbtDistanceCylinder ;
1094 
1095  cy->setCameraParameters(cam);
1096  cy->setName(name);
1097  cy->buildFrom(P1, P2, r);
1098  cylinders_disp.push_back(cy);
1099  }
1100 }
1101 
1112 void
1113 vpMbKltTracker::initCircle(const vpPoint& p1, const vpPoint &p2, const vpPoint &p3, const double radius,
1114  const int /*idFace*/, const std::string &name)
1115 {
1116  addCircle(p1, p2, p3, radius, name);
1117 }
1118 
1128 void
1129 vpMbKltTracker::addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, const double r, const std::string &name)
1130 {
1131  bool already_here = false ;
1132  vpMbtDistanceCircle *ci ;
1133 
1134 // for(std::list<vpMbtDistanceCircle*>::const_iterator it=circles_disp.begin(); it!=circles_disp[i].end(); ++it){
1135 // ci = *it;
1136 // if((samePoint(*(ci->p1),P1) && samePoint(*(ci->p2),P2) && samePoint(*(ci->p3),P3)) ||
1137 // (samePoint(*(ci->p1),P1) && samePoint(*(ci->p2),P3) && samePoint(*(ci->p3),P2)) ){
1138 // already_here = (std::fabs(ci->radius - r) < std::numeric_limits<double>::epsilon() * vpMath::maximum(ci->radius, r));
1139 // }
1140 // }
1141 
1142  if (!already_here){
1143  ci = new vpMbtDistanceCircle ;
1144 
1145  ci->setCameraParameters(cam);
1146  ci->setName(name);
1147  ci->buildFrom(P1, P2, P3, r);
1148  circles_disp.push_back(ci);
1149  }
1150 }
1151 
1161 void
1162 vpMbKltTracker::reInitModel(const vpImage<unsigned char>& I, const std::string &cad_name,
1163  const vpHomogeneousMatrix& cMo_, const bool verbose)
1164 {
1165  reInitModel(I, cad_name.c_str(), cMo_, verbose);
1166 }
1167 
1177 void
1179  const vpHomogeneousMatrix& cMo_, const bool verbose)
1180 {
1181  this->cMo.setIdentity();
1182 
1183 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1184  if(cur != NULL){
1185  cvReleaseImage(&cur);
1186  cur = NULL;
1187  }
1188 #endif
1189 
1190  firstInitialisation = true;
1191  firstTrack = false;
1192 
1193  faces.reset();
1194 
1195  loadModel(cad_name, verbose);
1196  initFromPose(I, cMo_);
1197 }
1198 
1199 #endif //VISP_HAVE_OPENCV
void setKltOpencv(const vpKltOpencv &t)
bool compute_interaction
If true, compute the interaction matrix at each iteration of the minimization. Otherwise, compute it only on the first iteration.
void addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, const double r, const std::string &name="")
virtual void track(const vpImage< unsigned char > &I)
unsigned int getCols() const
Definition: vpImage.h:180
vpMatrix get_K_inverse() const
void setWindowName(const Ogre::String &n)
Definition: vpAROgre.h:268
std::list< vpMbtDistanceKltPoints * > kltPolygons
Vector of the cylinders used here only to display the full model.
int getPyramidLevels() const
Get the list of features id.
Definition: vpKltOpencv.h:131
unsigned int getMaskBorder() const
void setQuality(const double &q)
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
virtual ~vpMbKltTracker()
double getHarrisParam() const
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:199
void changeFrame(const vpHomogeneousMatrix &cMo)
void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
void setCameraParameters(const vpCameraParameters &camera)
void init(const vpKltOpencv &_tracker)
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
Definition: vpRobust.cpp:136
void setHarrisFreeParameter(double harris_k)
int getMaxFeatures() const
Get the list of lost feature.
Definition: vpKltOpencv.h:117
void parse(const char *filename)
unsigned int getWidth() const
Definition: vpImage.h:161
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
void getCameraParameters(vpCameraParameters &_cam) const
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
Definition: vpMbTracker.h:135
unsigned int maxIter
The maximum iteration of the virtual visual servoing stage.
void removeOutliers(const vpColVector &weight, const double &threshold_outlier)
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:395
#define vpTRACE
Definition: vpDebug.h:418
double getHarrisFreeParameter() const
Get the free parameter of the Harris detector.
Definition: vpKltOpencv.h:113
void setCameraParameters(const vpCameraParameters &camera)
void setIdentity()
Basic initialisation (identity)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
void setMaxFeatures(const int maxCount)
double percentGood
Percentage of good points, according to the initial number, that must have the tracker.
void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w)
virtual void initCylinder(const vpPoint &, const vpPoint &, const double, const int, const std::string &name="")
vpHomogeneousMatrix cMo
The current pose.
Definition: vpMbTracker.h:112
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
unsigned int getBlockSize() const
void getRoiClipped(std::vector< vpPoint > &points)
double getNearClippingDistance() const
bool modelInitialised
Flag used to ensure that the CAD model is loaded before the initialisation.
Definition: vpMbTracker.h:120
void setMinDistance(double minDistance)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const vpPoint &_p3, const double r)
error that can be emited by ViSP classes.
Definition: vpException.h:76
void computeJTR(const vpMatrix &J, const vpColVector &R, vpMatrix &JTR)
Manage a cylinder used in the model-based tracker.
unsigned int getMaxFeatures() const
bool useOgre
Use Ogre3d for visibility tests.
Definition: vpMbTracker.h:147
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
Definition of the vpSubMatrix vpSubMatrix class provides a mask on a vpMatrix all properties of vpMat...
Definition: vpSubMatrix.h:66
unsigned int setVisibleOgre(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
Definition: vpMbTracker.h:124
bool firstInitialisation
Flag to specify whether the init method is called the first or not (specific calls to realize in this...
virtual void reinit(const vpImage< unsigned char > &I)
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
virtual void testTracking()
bool hasNearClippingDistance() const
Class that defines what is a point.
Definition: vpPoint.h:65
virtual void loadConfigFile(const std::string &configFile)
vpCameraParameters cam
The camera parameters.
Definition: vpMbTracker.h:110
unsigned int setVisible(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed)
The vpRotationMatrix considers the particular case of a rotation matrix.
void setQuality(double qualityLevel)
vpHomogeneousMatrix ctTc0
The estimated displacement of the pose between the current instant and the initial position...
std::map< int, int > & getCurrentPointsInd()
double getFarClippingDistance() const
void initOgre(const vpCameraParameters &cam=vpCameraParameters())
bool hasFarClippingDistance() const
unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker)
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:178
vpAROgre * getOgreContext()
unsigned int getRows() const
Definition: vpImage.h:171
std::vector< vpImagePoint > getKltImagePoints() const
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...
Manage a circle used in the model-based tracker.
vpMatrix oJo
The Degrees of Freedom to estimate.
Definition: vpMbTracker.h:114
unsigned int getWindowSize() const
Error that can be emited by the vpTracker class and its derivates.
double getAngleDisappear() const
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:67
void setName(const std::string &circle_name)
vpMatrix AtA() const
Definition: vpMatrix.cpp:1479
double getQuality() const
Get the parameter characterizing the minimal accepted quality of image corners.
Definition: vpKltOpencv.h:133
void changeFrame(const vpHomogeneousMatrix &cMo)
Definition: vpPlane.cpp:376
void displayPrimitive(const vpImage< unsigned char > &_I)
void setWindowSize(const unsigned int &w)
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
void setAngleDisappear(const double &adisappear)
vpColVector m_error
Error s-s*.
Definition: vpMbTracker.h:132
void setTrackerId(int tid)
Does nothing. Just here for compat with previous releases that use OpenCV C api to do the tracking...
Definition: vpKltOpencv.h:152
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 size of the averaging block used to track the features.
Definition: vpKltOpencv.h:104
void getFeature(const int &index, int &id, float &x, float &y) const
std::map< int, vpImagePoint > getKltImagePointsWithId() const
unsigned int getInitialNumberPoint() const
void extract(vpRotationMatrix &R) const
void setHarrisParam(const double &hp)
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
bool firstTrack
First track() called.
void computeRoiClipped(const vpCameraParameters &cam=vpCameraParameters())
void setMinDistance(const double &mD)
void initTracking(const cv::Mat &I, const cv::Mat &mask=cv::Mat())
double angleAppears
Angle used to detect a face appearance.
Definition: vpMbTracker.h:137
vpKltOpencv tracker
Points tracker.
virtual bool isVisible(const vpHomogeneousMatrix &cMo, const double alpha, const bool &modulo=false, const vpCameraParameters &cam=vpCameraParameters(), const vpImage< unsigned char > &I=vpImage< unsigned char >())
vpColVector getNormal() const
Definition: vpPlane.cpp:250
void setPyramidLevels(const int pyrMaxLevel)
double get_px() const
std::map< int, vpImagePoint > & getCurrentPoints()
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:2841
void preTracking(const vpImage< unsigned char > &I, unsigned int &nbInfos, unsigned int &nbFaceUsed)
void computeCovarianceMatrix(const vpHomogeneousMatrix &cMoPrev, const vpColVector &deltaS, const vpMatrix &Ls, const vpMatrix &W)
cv::Mat cur
Temporary OpenCV image for fast conversion.
double lambda
The gain of the virtual visual servoing stage.
void setMaxFeatures(const unsigned int &mF)
void computeHomography(const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0)
virtual void initCircle(const vpPoint &, const vpPoint &, const vpPoint &, const double, const int, const std::string &name="")
void setWindowSize(const int winSize)
double getQuality() const
std::list< vpMbtDistanceCircle * > circles_disp
Vector of the circles used here only to display the full model.
vpMatrix get_K() const
static double deg(double rad)
Definition: vpMath.h:93
virtual void setCameraParameters(const vpCameraParameters &_cam)
bool displayFeatures
If true, the features are displayed.
Definition: vpMbTracker.h:128
virtual void loadModel(const char *modelFile, const bool verbose=false)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const double r)
void setCameraParameters(const vpCameraParameters &cam)
std::list< vpMbtDistanceCylinder * > cylinders_disp
Vector of the cylinders used here only to display the full model.
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
void setAngleAppear(const double &aappear)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV.
Definition: vpKltOpencv.h:79
vpHomogeneousMatrix inverse() const
void setBlockSize(const int blockSize)
static vpHomogeneousMatrix direct(const vpColVector &v)
int getNbFeatures() const
Get the number of current features.
Definition: vpKltOpencv.h:121
Contains an M-Estimator and various influence function.
Definition: vpRobust.h:63
double angleDisappears
Angle used to detect a face disappearance.
Definition: vpMbTracker.h:139
virtual void initFaceFromLines(vpMbtPolygon &polygon)
vpMbtPolygon * polygon
Pointer to the polygon that define a face.
unsigned int getHeight() const
Definition: vpImage.h:152
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
Definition: vpMatrix.cpp:1932
virtual void setClipping(const unsigned int &flags)
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:93
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void setUseHarris(const int useHarrisDetector)
void setBlockSize(const unsigned int &bs)
This class defines the container for a plane geometrical structure.
Definition: vpPlane.h:67
unsigned int clippingFlag
Flags specifying which clipping to used.
Definition: vpMbTracker.h:145
unsigned int getNbPoint() const
Definition: vpMbtPolygon.h:171
double getMinDistance() const
Get the minimal Euclidean distance between detected corners during initialization.
Definition: vpKltOpencv.h:119
void displayOgre(const vpHomogeneousMatrix &cMo)
double getAngleAppear() const
void addCylinder(const vpPoint &P1, const vpPoint &P2, const double r, const std::string &name="")
unsigned int getCurrentNumberPoints() const
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:161
virtual void setFarClippingDistance(const double &dist)
double getMinDistance() const
void setName(const std::string &cyl_name)
vpColVector & normalize()
Normalise the vector.
bool getFovClipping() const
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.
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
Definition: vpMbTracker.h:116
void setMaskBorder(const unsigned int &mb)
void computeInteractionMatrixAndResidu(vpColVector &_R, vpMatrix &_J)
vpHomogeneousMatrix c0Mo
Initial pose.
int getWindowSize() const
Get the window size used to refine the corner locations.
Definition: vpKltOpencv.h:135
double getD() const
Definition: vpPlane.h:121
void track(const cv::Mat &I)
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)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
void updateMask(cv::Mat &mask, unsigned char _nb=255, unsigned int _shiftBorder=0)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:98
vpColVector m_w
Weights used in the robust scheme.
Definition: vpMbTracker.h:130
virtual void setNearClippingDistance(const double &dist)
void computeFov(const unsigned int &w, const unsigned int &h)
vpPoint * p
corners in the object frame
Definition: vpMbtPolygon.h:95