Visual Servoing Platform  version 3.1.0
vpMbEdgeKltTracker.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Hybrid tracker based on edges (vpMbt) and points of interests (KLT)
33  *
34  * Authors:
35  * Romain Tallonneau
36  * Aurelien Yol
37  *
38  *****************************************************************************/
39 
40 //#define VP_DEBUG_MODE 1 // Activate debug level 1
41 
42 #include <visp3/core/vpDebug.h>
43 #include <visp3/core/vpTrackingException.h>
44 #include <visp3/core/vpVelocityTwistMatrix.h>
45 #include <visp3/mbt/vpMbEdgeKltTracker.h>
46 
47 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
48 
50  : thresholdKLT(2.), thresholdMBT(2.), m_maxIterKlt(30), w_mbt(), w_klt(), m_error_hybrid(), m_w_hybrid()
51 {
52  computeCovariance = false;
53 
56 
57 #ifdef VISP_HAVE_OGRE
58  faces.getOgreContext()->setWindowName("MBT Hybrid");
59 #endif
60 
61  m_lambda = 0.8;
62  m_maxIter = 200;
63 }
64 
70 
78 {
80 
82 
84 
85  unsigned int i = (unsigned int)scales.size();
86  do {
87  i--;
88  if (scales[i]) {
89  downScale(i);
91  upScale(i);
92  }
93  } while (i != 0);
94 
96 }
97 
108 {
109  vpMbKltTracker::setPose(I, cdMo);
110 
111  resetMovingEdge();
112 
113  if (useScanLine) {
114  cam.computeFov(I.getWidth(), I.getHeight());
117  }
118 
119  initPyramid(I, Ipyramid);
120 
121  unsigned int i = (unsigned int)scales.size();
122  do {
123  i--;
124  if (scales[i]) {
125  downScale(i);
127  upScale(i);
128  }
129  } while (i != 0);
130 
132 }
133 
139 {
142 }
143 
144 unsigned int vpMbEdgeKltTracker::initMbtTracking(const unsigned int lvl)
145 {
146  if (lvl >= scales.size() || !scales[lvl]) {
147  throw vpException(vpException::dimensionError, "lvl not used.");
148  }
149 
150  unsigned int nbrow = 0;
151  for (std::list<vpMbtDistanceLine *>::iterator it = lines[lvl].begin(); it != lines[lvl].end(); ++it) {
152  vpMbtDistanceLine *l = *it;
153 
154  if (l->isTracked()) {
156  nbrow += l->nbFeatureTotal;
157  }
158  }
159 
160  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[lvl].begin(); it != cylinders[lvl].end();
161  ++it) {
162  vpMbtDistanceCylinder *cy = *it;
163 
164  if (cy->isTracked()) {
166  nbrow += cy->nbFeature;
167  }
168  }
169 
170  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[lvl].begin(); it != circles[lvl].end(); ++it) {
171  vpMbtDistanceCircle *ci = *it;
172 
173  if (ci->isTracked()) {
175  nbrow += ci->nbFeature;
176  }
177  }
178 
179  return nbrow;
180 }
181 
195 void vpMbEdgeKltTracker::loadConfigFile(const std::string &configFile)
196 {
197  vpMbEdgeKltTracker::loadConfigFile(configFile.c_str());
198 }
199 
264 void vpMbEdgeKltTracker::loadConfigFile(const char *configFile)
265 {
266 #ifdef VISP_HAVE_XML2
268 
269  xmlp.setCameraParameters(cam);
272 
273  xmlp.setMovingEdge(me);
274 
275  xmlp.setMaxFeatures(10000);
276  xmlp.setWindowSize(5);
277  xmlp.setQuality(0.01);
278  xmlp.setMinDistance(5);
279  xmlp.setHarrisParam(0.01);
280  xmlp.setBlockSize(3);
281  xmlp.setPyramidLevels(3);
283 
284  try {
285  std::cout << " *********** Parsing XML for Mb Edge Tracker ************ " << std::endl;
286  xmlp.parse(configFile);
287  } catch (...) {
288  vpERROR_TRACE("Can't open XML file \"%s\"\n ", configFile);
289  throw vpException(vpException::ioError, "problem to parse configuration file.");
290  }
291 
292  vpCameraParameters camera;
293  xmlp.getCameraParameters(camera);
294  setCameraParameters(camera);
295 
298 
299  if (xmlp.hasNearClippingDistance())
301 
302  if (xmlp.hasFarClippingDistance())
304 
305  if (xmlp.getFovClipping()) {
307  }
308 
309  useLodGeneral = xmlp.getLodState();
312 
313  applyLodSettingInConfig = false;
314  if (this->getNbPolygon() > 0) {
319  }
320 
321  vpMe meParser;
322  xmlp.getMe(meParser);
324 
326  tracker.setWindowSize((int)xmlp.getWindowSize());
327  tracker.setQuality(xmlp.getQuality());
330  tracker.setBlockSize((int)xmlp.getBlockSize());
332  maskBorder = xmlp.getMaskBorder();
333 
334  // if(useScanLine)
335  faces.getMbScanLineRenderer().setMaskBorder(maskBorder);
336 
337 #else
338  vpTRACE("You need the libXML2 to read the config file %s", configFile);
339 #endif
340 }
341 
346  const unsigned int lvl)
347 {
348  postTrackingMbt(w_mbt, lvl);
349 
350  if (displayFeatures) {
351  if (lvl == 0) {
352  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[lvl].begin(); it != lines[lvl].end(); ++it) {
353  vpMbtDistanceLine *l = *it;
354  if (l->isVisible() && l->isTracked()) {
355  l->displayMovingEdges(I);
356  }
357  }
358 
359  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[lvl].begin(); it != cylinders[lvl].end();
360  ++it) {
361  vpMbtDistanceCylinder *cy = *it;
362  // A cylinder is always visible: #FIXME AY: Still valid?
363  if (cy->isTracked())
364  cy->displayMovingEdges(I);
365  }
366 
367  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[lvl].begin(); it != circles[lvl].end(); ++it) {
368  vpMbtDistanceCircle *ci = *it;
369  if (ci->isVisible() && ci->isTracked()) {
370  ci->displayMovingEdges(I);
371  }
372  }
373  }
374  }
375 
376  bool reInit = vpMbKltTracker::postTracking(I, w_klt);
377 
378  if (useScanLine) {
379  cam.computeFov(I.getWidth(), I.getHeight());
382  }
383 
385 
388 
389  if (computeProjError)
391 
392  if (reInit)
393  return true;
394 
395  return false;
396 }
397 
408 void vpMbEdgeKltTracker::postTrackingMbt(vpColVector &w, const unsigned int lvl)
409 {
410  if (lvl >= scales.size() || !scales[lvl]) {
411  throw vpException(vpException::dimensionError, "_lvl not used.");
412  }
413 
414  unsigned int n = 0;
416  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[lvl].begin(); it != lines[lvl].end(); ++it) {
417  if ((*it)->isTracked()) {
418  l = *it;
419  unsigned int indexLine = 0;
420  double wmean = 0;
421 
422  for (unsigned int a = 0; a < l->meline.size(); a++) {
423  std::list<vpMeSite>::iterator itListLine;
424  if (l->nbFeature[a] > 0)
425  itListLine = l->meline[a]->getMeList().begin();
426 
427  for (unsigned int i = 0; i < l->nbFeature[a]; i++) {
428  wmean += w[n + indexLine];
429  vpMeSite p = *itListLine;
430  if (w[n + indexLine] < 0.5) {
432  *itListLine = p;
433  }
434 
435  ++itListLine;
436  indexLine++;
437  }
438  }
439 
440  n += l->nbFeatureTotal;
441 
442  if (l->nbFeatureTotal != 0)
443  wmean /= l->nbFeatureTotal;
444  else
445  wmean = 1;
446 
447  l->setMeanWeight(wmean);
448 
449  if (wmean < 0.8)
450  l->Reinit = true;
451  }
452  }
453 
454  // Same thing with cylinders as with lines
456  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[lvl].begin(); it != cylinders[lvl].end();
457  ++it) {
458  if ((*it)->isTracked()) {
459  cy = *it;
460  double wmean = 0;
461  std::list<vpMeSite>::iterator itListCyl1;
462  std::list<vpMeSite>::iterator itListCyl2;
463  if (cy->nbFeature > 0) {
464  itListCyl1 = cy->meline1->getMeList().begin();
465  itListCyl2 = cy->meline2->getMeList().begin();
466  }
467 
468  wmean = 0;
469  for (unsigned int i = 0; i < cy->nbFeaturel1; i++) {
470  wmean += w[n + i];
471  vpMeSite p = *itListCyl1;
472  if (w[n + i] < 0.5) {
474 
475  *itListCyl1 = p;
476  }
477 
478  ++itListCyl1;
479  }
480 
481  if (cy->nbFeaturel1 != 0)
482  wmean /= cy->nbFeaturel1;
483  else
484  wmean = 1;
485 
486  cy->setMeanWeight1(wmean);
487 
488  if (wmean < 0.8) {
489  cy->Reinit = true;
490  }
491 
492  wmean = 0;
493  for (unsigned int i = cy->nbFeaturel1; i < cy->nbFeature; i++) {
494  wmean += w[n + i];
495  vpMeSite p = *itListCyl2;
496  if (w[n + i] < 0.5) {
498 
499  *itListCyl2 = p;
500  }
501 
502  ++itListCyl2;
503  }
504 
505  if (cy->nbFeaturel2 != 0)
506  wmean /= cy->nbFeaturel2;
507  else
508  wmean = 1;
509 
510  cy->setMeanWeight2(wmean);
511 
512  if (wmean < 0.8) {
513  cy->Reinit = true;
514  }
515 
516  n += cy->nbFeature;
517  }
518  }
519 
520  // Same thing with circles as with lines
522  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[lvl].begin(); it != circles[lvl].end(); ++it) {
523  if ((*it)->isTracked()) {
524  ci = *it;
525  double wmean = 0;
526  std::list<vpMeSite>::iterator itListCir;
527 
528  if (ci->nbFeature > 0) {
529  itListCir = ci->meEllipse->getMeList().begin();
530  }
531 
532  wmean = 0;
533  for (unsigned int i = 0; i < ci->nbFeature; i++) {
534  wmean += w[n + i];
535  vpMeSite p = *itListCir;
536  if (w[n + i] < 0.5) {
538 
539  *itListCir = p;
540  }
541 
542  ++itListCir;
543  }
544 
545  if (ci->nbFeature != 0)
546  wmean /= ci->nbFeature;
547  else
548  wmean = 1;
549 
550  ci->setMeanWeight(wmean);
551 
552  if (wmean < 0.8) {
553  ci->Reinit = true;
554  }
555 
556  n += ci->nbFeature;
557  }
558  }
559 }
560 
569 void vpMbEdgeKltTracker::computeVVS(const vpImage<unsigned char> &I, const unsigned int &nbInfos, unsigned int &nbrow,
570  const unsigned int lvl)
571 {
572  vpColVector factor;
573  nbrow = trackFirstLoop(I, factor, lvl);
574 
575  if (nbrow < 4 && nbInfos < 4) {
576  throw vpTrackingException(vpTrackingException::notEnoughPointError, "Error: not enough features");
577  } else if (nbrow < 4)
578  nbrow = 0;
579 
580  unsigned int totalNbRows = nbrow + 2 * nbInfos;
581  double residu = 0;
582  double residu_1 = -1;
583  unsigned int iter = 0;
584 
585  vpMatrix L(totalNbRows, 6);
586  vpMatrix L_mbt, L_klt; // interaction matrix
587  vpColVector weighted_error(totalNbRows);
588  vpColVector R_mbt, R_klt; // residu
589  vpMatrix L_true;
590  vpMatrix LVJ_true;
591 
592  if (nbrow != 0) {
593  L_mbt.resize(nbrow, 6, false, false);
594  R_mbt.resize(nbrow, false);
595  }
596 
597  if (nbInfos != 0) {
598  L_klt.resize(2 * nbInfos, 6, false, false);
599  R_klt.resize(2 * nbInfos, false);
600  }
601 
602  vpColVector v; // "speed" for VVS
603  vpRobust robust_mbt(0), robust_klt(0);
604  vpHomography H;
605 
606  vpMatrix LTL;
607  vpColVector LTR;
608 
609  double factorMBT; // = 1.0;
610  double factorKLT; // = 1.0;
611 
612  // More efficient weight repartition for hybrid tracker should come soon...
613  // factorMBT = 1.0 - (double)nbrow / (double)(nbrow + nbInfos);
614  // factorKLT = 1.0 - factorMBT;
615  factorMBT = 0.35;
616  factorKLT = 0.65;
617 
618  if (nbrow < 4)
619  factorKLT = 1.;
620  if (nbInfos < 4)
621  factorMBT = 1.;
622 
623  double residuMBT = 0;
624  double residuKLT = 0;
625 
626  vpHomogeneousMatrix cMoPrev;
627  vpHomogeneousMatrix ctTc0_Prev;
628  vpColVector m_error_prev;
629  vpColVector m_w_prev;
630 
631  // Init size
632  m_error_hybrid.resize(totalNbRows, false);
633  m_w_hybrid.resize(totalNbRows, false);
634 
635  if (nbrow != 0) {
636  w_mbt.resize(nbrow, false);
637  w_mbt = 1; // needed in vpRobust::psiTukey()
638  robust_mbt.resize(nbrow);
639  }
640 
641  if (nbInfos != 0) {
642  w_klt.resize(2 * nbInfos, false);
643  w_klt = 1; // needed in vpRobust::psiTukey()
644  robust_klt.resize(2 * nbInfos);
645  }
646 
647  double mu = m_initialMu;
648 
649  while (((int)((residu - residu_1) * 1e8) != 0) && (iter < m_maxIter)) {
650  if (nbrow >= 4)
651  trackSecondLoop(I, L_mbt, R_mbt, cMo, lvl);
652 
653  if (nbInfos >= 4) {
654  unsigned int shift = 0;
655 
656  for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = vpMbKltTracker::kltPolygons.begin();
657  it != vpMbKltTracker::kltPolygons.end(); ++it) {
658  vpMbtDistanceKltPoints *kltpoly = *it;
659  if (kltpoly->polygon->isVisible() && kltpoly->isTracked() && kltpoly->hasEnoughPoints()) {
660  vpSubColVector subR(R_klt, shift, 2 * kltpoly->getCurrentNumberPoints());
661  vpSubMatrix subL(L_klt, shift, 0, 2 * kltpoly->getCurrentNumberPoints(), 6);
662  kltpoly->computeHomography(ctTc0, H);
663  kltpoly->computeInteractionMatrixAndResidu(subR, subL);
664  shift += 2 * kltpoly->getCurrentNumberPoints();
665  }
666  }
667 
668  for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
669  ++it) {
670  vpMbtDistanceKltCylinder *kltPolyCylinder = *it;
671 
672  if (kltPolyCylinder->isTracked() && kltPolyCylinder->hasEnoughPoints()) {
673  vpSubColVector subR(R_klt, shift, 2 * kltPolyCylinder->getCurrentNumberPoints());
674  vpSubMatrix subL(L_klt, shift, 0, 2 * kltPolyCylinder->getCurrentNumberPoints(), 6);
675  try {
676  kltPolyCylinder->computeInteractionMatrixAndResidu(ctTc0, subR, subL);
677  } catch (...) {
678  throw vpTrackingException(vpTrackingException::fatalError, "Cannot compute interaction matrix");
679  }
680 
681  shift += 2 * kltPolyCylinder->getCurrentNumberPoints();
682  }
683  }
684  }
685 
686  /* residuals */
687  if (nbrow > 3) {
688  m_error_hybrid.insert(0, R_mbt);
689  }
690 
691  if (nbInfos > 3) {
692  m_error_hybrid.insert(nbrow, R_klt);
693  }
694 
695  unsigned int cpt = 0;
696  while (cpt < (nbrow + 2 * nbInfos)) {
697  if (cpt < (unsigned)nbrow) {
698  m_w_hybrid[cpt] = ((w_mbt[cpt] * factor[cpt]) * factorMBT);
699  } else {
700  m_w_hybrid[cpt] = (w_klt[cpt - nbrow] * factorKLT);
701  }
702  cpt++;
703  }
704 
705  bool reStartFromLastIncrement = false;
706  computeVVSCheckLevenbergMarquardt(iter, m_error_hybrid, m_error_prev, cMoPrev, mu, reStartFromLastIncrement,
707  &m_w_prev);
708  if (reStartFromLastIncrement) {
709  ctTc0 = ctTc0_Prev;
710  }
711 
712  if (!reStartFromLastIncrement) {
713  /* robust */
714  if (nbrow > 3) {
715  residuMBT = 0;
716  for (unsigned int i = 0; i < R_mbt.getRows(); i++)
717  residuMBT += fabs(R_mbt[i]);
718  residuMBT /= R_mbt.getRows();
719 
720  robust_mbt.setThreshold(thresholdMBT / cam.get_px());
721  robust_mbt.MEstimator(vpRobust::TUKEY, R_mbt, w_mbt);
722 
723  L.insert(L_mbt, 0, 0);
724  }
725 
726  if (nbInfos > 3) {
727  residuKLT = 0;
728  for (unsigned int i = 0; i < R_klt.getRows(); i++)
729  residuKLT += fabs(R_klt[i]);
730  residuKLT /= R_klt.getRows();
731 
732  robust_klt.setThreshold(thresholdKLT / cam.get_px());
733  robust_klt.MEstimator(vpRobust::TUKEY, R_klt, w_klt);
734 
735  L.insert(L_klt, nbrow, 0);
736  }
737 
738  unsigned int cpt = 0;
739  while (cpt < (nbrow + 2 * nbInfos)) {
740  if (cpt < (unsigned)nbrow) {
741  m_w_hybrid[cpt] = ((w_mbt[cpt] * factor[cpt]) * factorMBT);
742  } else {
743  m_w_hybrid[cpt] = (w_klt[cpt - nbrow] * factorKLT);
744  }
745  cpt++;
746  }
747 
748  if (computeCovariance) {
749  L_true = L;
750  if (!isoJoIdentity) {
752  cVo.buildFrom(cMo);
753  LVJ_true = (L * cVo * oJo);
754  }
755  }
756 
757  residu_1 = residu;
758  residu = 0;
759  double num = 0;
760  double den = 0;
761 
762  for (unsigned int i = 0; i < weighted_error.getRows(); i++) {
763  num += m_w_hybrid[i] * vpMath::sqr(m_error_hybrid[i]);
764  den += m_w_hybrid[i];
765 
766  weighted_error[i] = m_error_hybrid[i] * m_w_hybrid[i];
767  if (m_computeInteraction) {
768  for (unsigned int j = 0; j < 6; j += 1) {
769  L[i][j] *= m_w_hybrid[i];
770  }
771  }
772  }
773 
774  residu = sqrt(num / den);
775 
776  computeVVSPoseEstimation(isoJoIdentity, iter, L, LTL, weighted_error, m_error_hybrid, m_error_prev, LTR, mu, v,
777  &m_w_hybrid, &m_w_prev);
778 
779  cMoPrev = cMo;
780  ctTc0_Prev = ctTc0;
782  cMo = ctTc0 * c0Mo;
783  }
784 
785  iter++;
786  }
787 
789 }
790 
792 {
793  throw vpException(vpException::fatalError, "vpMbEdgeKltTracker::computeVVSInit() should not be called!");
794 }
795 
797 {
798  throw vpException(vpException::fatalError, "vpMbEdgeKltTracker::"
799  "computeVVSInteractionMatrixAndR"
800  "esidu() should not be called!");
801 }
802 
811 {
812  try {
814  } catch (...) {
815  }
816 
817  if (m_nbInfos >= 4) {
818  unsigned int old_maxIter = m_maxIter;
821  m_maxIter = old_maxIter;
822  } else {
823  m_nbInfos = 0;
824  // std::cout << "[Warning] Unable to init with KLT" << std::endl;
825  }
826 
828 
829  unsigned int nbrow = 0;
830  computeVVS(I, m_nbInfos, nbrow);
831 
832  if (postTracking(I, w_mbt, w_klt)) {
834 
835  // AY : Removed as edge tracked, if necessary, is reinitialized in
836  // postTracking()
837 
838  // initPyramid(I, Ipyramid);
839 
840  // unsigned int i = (unsigned int)scales.size();
841  // do {
842  // i--;
843  // if(scales[i]){
844  // downScale(i);
845  // initMovingEdge(*Ipyramid[i], cMo);
846  // upScale(i);
847  // }
848  // } while(i != 0);
849 
850  // cleanPyramid(Ipyramid);
851  }
852 }
853 
855  const unsigned int lvl)
856 {
860 
861  if (lvl >= scales.size() || !scales[lvl]) {
862  throw vpException(vpException::dimensionError, "_lvl not used.");
863  }
864 
865  unsigned int nbrow = initMbtTracking(lvl);
866 
867  if (nbrow == 0) {
868  // throw vpTrackingException(vpTrackingException::notEnoughPointError,
869  // "Error: not enough features in the interaction matrix...");
870  return nbrow;
871  }
872 
873  factor.resize(nbrow, false);
874  factor = 1;
875 
876  unsigned int n = 0;
877  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[lvl].begin(); it != lines[lvl].end(); ++it) {
878  if ((*it)->isTracked()) {
879  l = *it;
881 
882  double fac = 1;
883  for (std::list<int>::const_iterator itindex = l->Lindex_polygon.begin(); itindex != l->Lindex_polygon.end();
884  ++itindex) {
885  int index = *itindex;
886  if (l->hiddenface->isAppearing((unsigned int)index)) {
887  fac = 0.2;
888  break;
889  }
890  if (l->closeToImageBorder(I, 10)) {
891  fac = 0.1;
892  break;
893  }
894  }
895 
896  unsigned int indexFeature = 0;
897  for (unsigned int a = 0; a < l->meline.size(); a++) {
898  std::list<vpMeSite>::const_iterator itListLine;
899  if (l->meline[a] != NULL) {
900  itListLine = l->meline[a]->getMeList().begin();
901 
902  for (unsigned int i = 0; i < l->nbFeature[a]; i++) {
903  factor[n + i] = fac;
904  vpMeSite site = *itListLine;
905  if (site.getState() != vpMeSite::NO_SUPPRESSION)
906  factor[n + i] = 0.2;
907  ++itListLine;
908  indexFeature++;
909  }
910  n += l->nbFeature[a];
911  }
912  }
913  }
914  }
915 
916  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[lvl].begin(); it != cylinders[lvl].end();
917  ++it) {
918  if ((*it)->isTracked()) {
919  cy = *it;
921  double fac = 1.0;
922 
923  std::list<vpMeSite>::const_iterator itCyl1;
924  std::list<vpMeSite>::const_iterator itCyl2;
925  if ((cy->meline1 != NULL || cy->meline2 != NULL)) {
926  itCyl1 = cy->meline1->getMeList().begin();
927  itCyl2 = cy->meline2->getMeList().begin();
928  }
929 
930  for (unsigned int i = 0; i < cy->nbFeature; i++) {
931  factor[n + i] = fac;
932  vpMeSite site;
933  if (i < cy->nbFeaturel1) {
934  site = *itCyl1;
935  ++itCyl1;
936  } else {
937  site = *itCyl2;
938  ++itCyl2;
939  }
940  if (site.getState() != vpMeSite::NO_SUPPRESSION)
941  factor[n + i] = 0.2;
942  }
943 
944  n += cy->nbFeature;
945  }
946  }
947 
948  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[lvl].begin(); it != circles[lvl].end(); ++it) {
949  if ((*it)->isTracked()) {
950  ci = *it;
952  double fac = 1.0;
953 
954  std::list<vpMeSite>::const_iterator itCir;
955  if (ci->meEllipse != NULL) {
956  itCir = ci->meEllipse->getMeList().begin();
957  }
958 
959  for (unsigned int i = 0; i < ci->nbFeature; i++) {
960  factor[n + i] = fac;
961  vpMeSite site = *itCir;
962  if (site.getState() != vpMeSite::NO_SUPPRESSION)
963  factor[n + i] = 0.2;
964  ++itCir;
965  }
966 
967  n += ci->nbFeature;
968  }
969  }
970 
971  return nbrow;
972 }
973 
975  vpHomogeneousMatrix &cMo_, const unsigned int lvl)
976 {
980 
981  unsigned int n = 0;
982  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[lvl].begin(); it != lines[lvl].end(); ++it) {
983  if ((*it)->isTracked()) {
984  l = *it;
986  for (unsigned int i = 0; i < l->nbFeatureTotal; i++) {
987  for (unsigned int j = 0; j < 6; j++) {
988  L[n + i][j] = l->L[i][j];
989  error[n + i] = l->error[i];
990  }
991  }
992  n += l->nbFeatureTotal;
993  }
994  }
995 
996  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[lvl].begin(); it != cylinders[lvl].end();
997  ++it) {
998  if ((*it)->isTracked()) {
999  cy = *it;
1000  cy->computeInteractionMatrixError(cMo_, I);
1001  for (unsigned int i = 0; i < cy->nbFeature; i++) {
1002  for (unsigned int j = 0; j < 6; j++) {
1003  L[n + i][j] = cy->L[i][j];
1004  error[n + i] = cy->error[i];
1005  }
1006  }
1007  n += cy->nbFeature;
1008  }
1009  }
1010  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[lvl].begin(); it != circles[lvl].end(); ++it) {
1011  if ((*it)->isTracked()) {
1012  ci = *it;
1014  for (unsigned int i = 0; i < ci->nbFeature; i++) {
1015  for (unsigned int j = 0; j < 6; j++) {
1016  L[n + i][j] = ci->L[i][j];
1017  error[n + i] = ci->error[i];
1018  }
1019  }
1020 
1021  n += ci->nbFeature;
1022  }
1023  }
1024 }
1025 
1032 {
1033  this->cam = camera;
1034 
1037 }
1038 
1046 {
1049 }
1057 {
1060 }
1061 
1072 void vpMbEdgeKltTracker::initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius,
1073  const int idFace, const std::string &name)
1074 {
1075  vpMbEdgeTracker::initCircle(p1, p2, p3, radius, idFace, name);
1076 }
1077 
1088 void vpMbEdgeKltTracker::initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace,
1089  const std::string &name)
1090 {
1091  vpMbEdgeTracker::initCylinder(p1, p2, radius, idFace, name);
1092  vpMbKltTracker::initCylinder(p1, p2, radius, idFace, name);
1093 }
1094 
1107  const vpCameraParameters &camera, const vpColor &col, const unsigned int thickness,
1108  const bool displayFullModel)
1109 {
1110  for (unsigned int i = 0; i < scales.size(); i += 1) {
1111  if (scales[i]) {
1112  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[scaleLevel].begin(); it != lines[scaleLevel].end();
1113  ++it) {
1114  (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1115  }
1116 
1117  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[scaleLevel].begin();
1118  it != cylinders[scaleLevel].end(); ++it) {
1119  (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1120  }
1121 
1122  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[scaleLevel].begin();
1123  it != circles[scaleLevel].end(); ++it) {
1124  (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1125  }
1126 
1127  break; // displaying model on one scale only
1128  }
1129  }
1130 
1131  for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end(); ++it) {
1132  vpMbtDistanceKltPoints *kltpoly = *it;
1133  if (displayFeatures && kltpoly->hasEnoughPoints() && kltpoly->isTracked() && kltpoly->polygon->isVisible()) {
1134  kltpoly->displayPrimitive(I);
1135  }
1136  }
1137 
1138  for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
1139  ++it) {
1140  vpMbtDistanceKltCylinder *kltPolyCylinder = *it;
1141  if (displayFeatures && kltPolyCylinder->isTracked() && kltPolyCylinder->hasEnoughPoints())
1142  kltPolyCylinder->displayPrimitive(I);
1143  }
1144 
1145 #ifdef VISP_HAVE_OGRE
1146  if (useOgre)
1147  faces.displayOgre(cMo_);
1148 #endif
1149 }
1150 
1163  const vpCameraParameters &camera, const vpColor &col, const unsigned int thickness,
1164  const bool displayFullModel)
1165 {
1166  for (unsigned int i = 0; i < scales.size(); i += 1) {
1167  if (scales[i]) {
1168  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[scaleLevel].begin(); it != lines[scaleLevel].end();
1169  ++it) {
1170  (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1171  }
1172 
1173  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[scaleLevel].begin();
1174  it != cylinders[scaleLevel].end(); ++it) {
1175  (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1176  }
1177 
1178  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[scaleLevel].begin();
1179  it != circles[scaleLevel].end(); ++it) {
1180  (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1181  }
1182 
1183  break; // displaying model on one scale only
1184  }
1185  }
1186 
1187  for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end(); ++it) {
1188  vpMbtDistanceKltPoints *kltpoly = *it;
1189  if (displayFeatures && kltpoly->hasEnoughPoints() && kltpoly->isTracked() && kltpoly->polygon->isVisible()) {
1190  kltpoly->displayPrimitive(I);
1191  }
1192  }
1193 
1194  for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
1195  ++it) {
1196  vpMbtDistanceKltCylinder *kltPolyCylinder = *it;
1197  if (displayFeatures && kltPolyCylinder->isTracked() && kltPolyCylinder->hasEnoughPoints())
1198  kltPolyCylinder->displayPrimitive(I);
1199  }
1200 
1201 #ifdef VISP_HAVE_OGRE
1202  if (useOgre)
1203  faces.displayOgre(cMo_);
1204 #endif
1205 }
1206 
1216 void vpMbEdgeKltTracker::reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
1217  const vpHomogeneousMatrix &cMo_, const bool verbose)
1218 {
1219  reInitModel(I, cad_name.c_str(), cMo_, verbose);
1220 }
1221 
1231 void vpMbEdgeKltTracker::reInitModel(const vpImage<unsigned char> &I, const char *cad_name,
1232  const vpHomogeneousMatrix &cMo_, const bool verbose)
1233 {
1234 // Reinit klt
1235 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1236  if (cur != NULL) {
1237  cvReleaseImage(&cur);
1238  cur = NULL;
1239  }
1240 #endif
1241 
1242  // delete the Klt Polygon features
1243  for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end(); ++it) {
1244  vpMbtDistanceKltPoints *kltpoly = *it;
1245  if (kltpoly != NULL) {
1246  delete kltpoly;
1247  }
1248  kltpoly = NULL;
1249  }
1250  kltPolygons.clear();
1251 
1252  for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
1253  ++it) {
1254  vpMbtDistanceKltCylinder *kltPolyCylinder = *it;
1255  if (kltPolyCylinder != NULL) {
1256  delete kltPolyCylinder;
1257  }
1258  kltPolyCylinder = NULL;
1259  }
1260  kltCylinders.clear();
1261 
1262  // delete the structures used to display circles
1263  vpMbtDistanceCircle *ci;
1264  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles_disp.begin(); it != circles_disp.end(); ++it) {
1265  ci = *it;
1266  if (ci != NULL) {
1267  delete ci;
1268  }
1269  ci = NULL;
1270  }
1271 
1272  circles_disp.clear();
1273 
1274  firstInitialisation = true;
1275 
1276  // Reinit edge
1277  vpMbtDistanceLine *l;
1279 
1280  for (unsigned int i = 0; i < scales.size(); i += 1) {
1281  if (scales[i]) {
1282  for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[i].begin(); it != lines[i].end(); ++it) {
1283  l = *it;
1284  if (l != NULL)
1285  delete l;
1286  l = NULL;
1287  }
1288 
1289  for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[i].begin(); it != cylinders[i].end();
1290  ++it) {
1291  cy = *it;
1292  if (cy != NULL)
1293  delete cy;
1294  cy = NULL;
1295  }
1296 
1297  for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[i].begin(); it != circles[i].end(); ++it) {
1298  ci = *it;
1299  if (ci != NULL)
1300  delete ci;
1301  ci = NULL;
1302  }
1303 
1304  lines[i].clear();
1305  cylinders[i].clear();
1306  circles[i].clear();
1307  }
1308  }
1309 
1310  // compute_interaction=1;
1311  nline = 0;
1312  ncylinder = 0;
1313  ncircle = 0;
1314  // lambda = 1;
1315  nbvisiblepolygone = 0;
1316 
1317  // Reinit common parts
1318  faces.reset();
1319 
1320  loadModel(cad_name, verbose);
1321 
1322  this->cMo = cMo_;
1323  init(I);
1324 }
1325 
1326 #elif !defined(VISP_BUILD_SHARED_LIBS)
1327 // Work arround to avoid warning: libvisp_mbt.a(vpMbEdgeKltTracker.cpp.o) has
1328 // no symbols
1329 void dummy_vpMbEdgeKltTracker(){};
1330 #endif // VISP_HAVE_OPENCV
bool m_computeInteraction
Definition: vpMbTracker.h:187
void setWindowName(const Ogre::String &n)
Definition: vpAROgre.h:269
void trackSecondLoop(const vpImage< unsigned char > &I, vpMatrix &L, vpColVector &_error, vpHomogeneousMatrix &cMo, const unsigned int lvl=0)
virtual void initCircle(const vpPoint &, const vpPoint &, const vpPoint &, const double r, const int idFace=0, const std::string &name="")
bool computeProjError
Definition: vpMbTracker.h:135
unsigned int ncylinder
void setQuality(const double &q)
void postTrackingMbt(vpColVector &w, const unsigned int level=0)
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
void displayMovingEdges(const vpImage< unsigned char > &I)
void displayPrimitive(const vpImage< unsigned char > &_I)
void setMovingEdge(const vpMe &me)
bool getFovClipping() const
vpMeSiteState getState() const
Definition: vpMeSite.h:188
Parse an Xml file to extract configuration parameters of a mbtConfig object.Data parser for the model...
unsigned int nbFeature
The number of moving edges.
unsigned int nbFeatureTotal
The number of moving edges.
void upScale(const unsigned int _scale)
void parse(const char *filename)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
Definition: vpRobust.cpp:176
void setHarrisFreeParameter(double harris_k)
bool isAppearing(const unsigned int i)
double getAngleAppear() const
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
Definition: vpMbTracker.h:145
bool Reinit
Indicates if the line has to be reinitialized.
void setMeanWeight2(const double wmean)
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
unsigned int scaleLevel
std::list< int > Lindex_polygon
Index of the faces which contain the line.
vpMatrix L
The interaction matrix.
unsigned int getWindowSize() const
bool isTracked() const
Performs search in a given direction(normal) for a given distance(pixels) for a given &#39;site&#39;...
Definition: vpMeSite.h:71
void getMe(vpMe &_ecm) const
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
#define vpERROR_TRACE
Definition: vpDebug.h:393
unsigned int getBlockSize() const
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true, const bool recopy_=true)
Definition: vpArray2D.h:171
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
void setMaxFeatures(const int maxCount)
std::list< vpMbtDistanceKltCylinder * > kltCylinders
unsigned int m_maxIterKlt
The maximum iteration of the virtual visual servoing stage.
virtual void initCylinder(const vpPoint &, const vpPoint &, const double, const int, const std::string &name="")
vpHomogeneousMatrix cMo
The current pose.
Definition: vpMbTracker.h:115
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
unsigned int getMaxFeatures() const
void displayMovingEdges(const vpImage< unsigned char > &I)
unsigned int ncircle
double thresholdKLT
The threshold used in the robust estimation of KLT.
std::vector< const vpImage< unsigned char > * > Ipyramid
vpColVector error
The error vector.
void setMinDistance(double minDistance)
error that can be emited by ViSP classes.
Definition: vpException.h:71
vpMbtMeEllipse * meEllipse
The moving edge containers.
Manage a cylinder used in the model-based tracker.
vpMbScanLine & getMbScanLineRenderer()
unsigned int getRows() const
Definition: vpArray2D.h:156
Definition: vpMe.h:60
vpHomogeneousMatrix inverse() const
Manage the line of a polygon used in the model-based tracker.
unsigned int nbFeature
The number of moving edges.
void getCameraParameters(vpCameraParameters &_cam) const
virtual void setClipping(const unsigned int &flags)
vpColVector m_w_hybrid
Robust weights.
bool useOgre
Use Ogre3d for visibility tests.
Definition: vpMbTracker.h:157
bool hasNearClippingDistance() const
virtual void setCameraParameters(const vpCameraParameters &camera)
void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
bool getLodState() const
Definition of the vpSubMatrix vpSubMatrix class provides a mask on a vpMatrix all properties of vpMat...
Definition: vpSubMatrix.h:62
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
Definition: vpMbTracker.h:130
vpMe me
The moving edges parameters.
void updateMovingEdge(const vpImage< unsigned char > &I)
vpColVector w_mbt
Robust weights for Edge.
virtual void reinit(const vpImage< unsigned char > &I)
virtual void setFarClippingDistance(const double &dist)
void downScale(const unsigned int _scale)
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
Class that defines what is a point.
Definition: vpPoint.h:58
vpMatrix L
The interaction matrix.
vpCameraParameters cam
The camera parameters.
Definition: vpMbTracker.h:113
void computeClippedPolygons(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam)
void setQuality(double qualityLevel)
virtual void init(const vpImage< unsigned char > &I)
vpHomogeneousMatrix ctTc0
unsigned int getMaskBorder() const
double getAngleDisappear() const
unsigned int nbFeaturel1
The number of moving edges on line 1.
Implementation of an homography and operations on homographies.
Definition: vpHomography.h:174
vpAROgre * getOgreContext()
void setPyramidLevels(const unsigned int &pL)
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
virtual void computeVVSInit()
Manage a circle used in the model-based tracker.
void insert(const vpMatrix &A, const unsigned int r, const unsigned int c)
Definition: vpMatrix.cpp:4512
vpMatrix oJo
The Degrees of Freedom to estimate.
Definition: vpMbTracker.h:117
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
bool Reinit
Indicates if the circle has to be reinitialized.
Error that can be emited by the vpTracker class and its derivates.
Implementation of a polygon of the model used by the model-based tracker.
Definition: vpMbtPolygon.h:66
double getNearClippingDistance() const
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void computeInteractionMatrixAndResidu(const vpHomogeneousMatrix &cMc0, vpColVector &_R, vpMatrix &_J)
void displayPrimitive(const vpImage< unsigned char > &_I)
void setWindowSize(const unsigned int &w)
bool useScanLine
Use Scanline for visibility tests.
Definition: vpMbTracker.h:160
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
#define vpTRACE
Definition: vpDebug.h:416
double getFarClippingDistance() const
static double sqr(double x)
Definition: vpMath.h:108
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
Definition: vpMbTracker.h:179
vpColVector w_klt
Robust weights for KLT.
void setAngleDisappear(const double &adisappear)
vpColVector error
The error vector.
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void track(const vpImage< unsigned char > &I)
unsigned int maskBorder
Erosion of the mask.
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)
Generic class defining intrinsic camera parameters.
void cleanPyramid(std::vector< const vpImage< unsigned char > *> &_pyramid)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
Definition: vpMbTracker.h:195
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
double m_lambda
Gain of the virtual visual servoing stage.
Definition: vpMbTracker.h:189
void setHarrisParam(const double &hp)
void setMinDistance(const double &mD)
void loadConfigFile(const char *configFile)
void setCameraParameters(const vpCameraParameters &_cam)
double angleAppears
Angle used to detect a face appearance.
Definition: vpMbTracker.h:147
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 >())
void setPyramidLevels(const int pyrMaxLevel)
void setState(const vpMeSiteState &flag)
Definition: vpMeSite.h:174
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void displayMovingEdges(const vpImage< unsigned char > &I)
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
Definition: vpMbTracker.h:191
unsigned int getCurrentNumberPoints() const
static double rad(double deg)
Definition: vpMath.h:102
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
void setMeanWeight1(const double wmean)
std::vector< std::list< vpMbtDistanceCircle * > > circles
Vector of the tracked circles.
virtual void setCameraParameters(const vpCameraParameters &cam)
void computeProjectionError(const vpImage< unsigned char > &_I)
void insert(unsigned int i, const vpColVector &v)
cv::Mat cur
Temporary OpenCV image for fast conversion.
virtual void initFaceFromLines(vpMbtPolygon &polygon)
unsigned int getCurrentNumberPoints() const
void setMaxFeatures(const unsigned int &mF)
void computeHomography(const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
bool closeToImageBorder(const vpImage< unsigned char > &I, const unsigned int threshold)
std::list< vpMbtDistanceCircle * > circles_disp
Vector of the circles used here only to display the full model.
bool isVisible() const
void setWindowSize(const int winSize)
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
Definition: vpMbTracker.h:181
static double deg(double rad)
Definition: vpMath.h:95
bool displayFeatures
If true, the features are displayed.
Definition: vpMbTracker.h:140
virtual void loadModel(const char *modelFile, const bool verbose=false)
unsigned int getHeight() const
Definition: vpImage.h:178
virtual void initCylinder(const vpPoint &, const vpPoint &, const double r, const int idFace, const std::string &name="")
double getMinDistance() const
void setCameraParameters(const vpCameraParameters &cam)
void preTracking(const vpImage< unsigned char > &I)
virtual unsigned int getNbPolygon() const
Definition: vpMbTracker.h:335
double getMinPolygonAreaThreshold() const
bool applyLodSettingInConfig
Definition: vpMbTracker.h:177
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
void setAngleAppear(const double &aappear)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
vpColVector m_error_hybrid
(s - s*)
double getHarrisParam() const
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")
unsigned int initMbtTracking(const unsigned int level=0)
virtual void computeVVSPoseEstimation(const bool isoJoIdentity_, const unsigned int iter, vpMatrix &L, vpMatrix &LTL, vpColVector &R, const vpColVector &error, vpColVector &error_prev, vpColVector &LTR, double &mu, vpColVector &v, const vpColVector *const w=NULL, vpColVector *const m_w_prev=NULL)
bool hasFarClippingDistance() const
unsigned int trackFirstLoop(const vpImage< unsigned char > &I, vpColVector &factor, const unsigned int lvl=0)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setBlockSize(const int blockSize)
static vpHomogeneousMatrix direct(const vpColVector &v)
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity_, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
void setMeanWeight(const double _wmean)
Contains an M-Estimator and various influence function.
Definition: vpRobust.h:58
unsigned int nbvisiblepolygone
Number of polygon (face) currently visible.
double angleDisappears
Angle used to detect a face disappearance.
Definition: vpMbTracker.h:149
virtual void initFaceFromLines(vpMbtPolygon &polygon)
vpMbtPolygon * polygon
Pointer to the polygon that define a face.
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w_mbt, vpColVector &w_klt, const unsigned int lvl=0)
void setMeanWeight(const double w_mean)
vpColVector error
The error vector.
std::vector< std::list< vpMbtDistanceLine * > > lines
unsigned int getPyramidLevels() const
double getQuality() const
unsigned int m_nbInfos
bool Reinit
Indicates if the line has to be reinitialized.
virtual void init(const vpImage< unsigned char > &I)
double getMinLineLengthThreshold() const
std::vector< vpMbtMeLine * > meline
The moving edge container.
void setBlockSize(const unsigned int &bs)
unsigned int clippingFlag
Flags specifying which clipping to used.
Definition: vpMbTracker.h:155
unsigned int nline
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > *> &_pyramid)
void trackMovingEdge(const vpImage< unsigned char > &I)
void displayOgre(const vpHomogeneousMatrix &cMo)
unsigned int nbFeaturel2
The number of moving edges on line 2.
virtual void initFaceFromLines(vpMbtPolygon &polygon)
void setThreshold(const double noise_threshold)
Definition: vpRobust.h:115
void resize(unsigned int n_data)
Resize containers for sort methods.
Definition: vpRobust.cpp:128
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
virtual void computeVVSInteractionMatrixAndResidu()
unsigned int getWidth() const
Definition: vpImage.h:229
bool useLodGeneral
True if LOD mode is enabled.
Definition: vpMbTracker.h:174
vpMatrix L
The interaction matrix.
void computeScanLineRender(const vpCameraParameters &cam, const unsigned int &w, const unsigned int &h)
std::vector< unsigned int > nbFeature
The number of moving edges.
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage< unsigned char > &I)
virtual void computeVVSCheckLevenbergMarquardt(const unsigned int iter, vpColVector &error, const vpColVector &m_error_prev, const vpHomogeneousMatrix &cMoPrev, double &mu, bool &reStartFromLastIncrement, vpColVector *const w=NULL, const vpColVector *const m_w_prev=NULL)
std::list< vpMbtDistanceKltPoints * > kltPolygons
void setMovingEdge(const vpMe &_ecm)
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
Definition: vpMbTracker.h:119
void setMaskBorder(const unsigned int &mb)
void computeInteractionMatrixAndResidu(vpColVector &_R, vpMatrix &_J)
vpHomogeneousMatrix c0Mo
Initial pose.
double thresholdMBT
The threshold used in the robust estimation of MBT.
virtual void setNearClippingDistance(const double &dist)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:241
virtual void setLod(const bool useLod, const std::string &name="")
void computeFov(const unsigned int &w, const unsigned int &h)