Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpMbEdgeMultiTracker.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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  * Model-based edge tracker with multiple cameras.
33  *
34  * Authors:
35  * Souriya Trinh
36  *
37  *****************************************************************************/
38 
44 #include <visp3/core/vpDebug.h>
45 #include <visp3/core/vpExponentialMap.h>
46 #include <visp3/core/vpTrackingException.h>
47 #include <visp3/core/vpVelocityTwistMatrix.h>
48 #include <visp3/mbt/vpMbEdgeMultiTracker.h>
49 
50 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
51 
56  : m_mapOfCameraTransformationMatrix(), m_mapOfEdgeTrackers(), m_mapOfPyramidalImages(),
57  m_referenceCameraName("Camera"), m_L_edgeMulti(), m_error_edgeMulti(), m_w_edgeMulti(), m_weightedError_edgeMulti()
58 {
59  m_mapOfEdgeTrackers["Camera"] = new vpMbEdgeTracker();
60 
61  // Add default camera transformation matrix
63 }
64 
70 vpMbEdgeMultiTracker::vpMbEdgeMultiTracker(const unsigned int nbCameras)
73 {
74 
75  if (nbCameras == 0) {
76  throw vpException(vpTrackingException::fatalError, "Cannot construct a vpMbEdgeMultiTracker with no camera !");
77  } else if (nbCameras == 1) {
78  m_mapOfEdgeTrackers["Camera"] = new vpMbEdgeTracker();
79 
80  // Add default camera transformation matrix
82  } else if (nbCameras == 2) {
83  m_mapOfEdgeTrackers["Camera1"] = new vpMbEdgeTracker();
84  m_mapOfEdgeTrackers["Camera2"] = new vpMbEdgeTracker();
85 
86  // Add default camera transformation matrix
89 
90  // Set by default the reference camera to Camera1
91  m_referenceCameraName = "Camera1";
92  } else {
93  for (unsigned int i = 1; i <= nbCameras; i++) {
94  std::stringstream ss;
95  ss << "Camera" << i;
96  m_mapOfEdgeTrackers[ss.str()] = new vpMbEdgeTracker();
97 
98  // Add default camera transformation matrix
100  }
101 
102  // Set by default the reference camera to the first one
104  }
105 }
106 
114 vpMbEdgeMultiTracker::vpMbEdgeMultiTracker(const std::vector<std::string> &cameraNames)
117 {
118 
119  if (cameraNames.empty()) {
120  throw vpException(vpTrackingException::fatalError, "Cannot construct a vpMbEdgeMultiTracker with no camera !");
121  }
122 
123  for (std::vector<std::string>::const_iterator it = cameraNames.begin(); it != cameraNames.end(); ++it) {
125  }
126 
127  // Set by default the reference camera
128  m_referenceCameraName = cameraNames.front();
129 }
130 
135 {
136  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
137  it != m_mapOfEdgeTrackers.end(); ++it) {
138  delete it->second;
139  }
140 
141  m_mapOfEdgeTrackers.clear();
142 
144 }
145 
146 void vpMbEdgeMultiTracker::cleanPyramid(std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid)
147 {
148  for (std::map<std::string, std::vector<const vpImage<unsigned char> *> >::iterator it1 = pyramid.begin();
149  it1 != pyramid.end(); ++it1) {
150  if (it1->second.size() > 0) {
151  it1->second[0] = NULL;
152  for (size_t i = 1; i < it1->second.size(); i++) {
153  if (it1->second[i] != NULL) {
154  delete it1->second[i];
155  it1->second[i] = NULL;
156  }
157  }
158  it1->second.clear();
159  }
160  }
161 }
162 
164 {
165  if (computeProjError) {
166  double rawTotalProjectionError = 0.0;
167  unsigned int nbTotalFeaturesUsed = 0;
168  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
169  it != m_mapOfEdgeTrackers.end(); ++it) {
170  double curProjError = it->second->getProjectionError();
171  unsigned int nbFeaturesUsed = it->second->nbFeaturesForProjErrorComputation;
172 
173  if (nbFeaturesUsed > 0) {
174  nbTotalFeaturesUsed += nbFeaturesUsed;
175  rawTotalProjectionError += (vpMath::rad(curProjError) * nbFeaturesUsed);
176  }
177  }
178 
179  if (nbTotalFeaturesUsed > 0) {
180  nbFeaturesForProjErrorComputation = nbTotalFeaturesUsed;
181  projectionError = vpMath::deg(rawTotalProjectionError / (double)nbTotalFeaturesUsed);
182  } else {
184  projectionError = 90.0;
185  }
186  }
187 }
188 
189 void vpMbEdgeMultiTracker::computeVVS(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
190  const unsigned int lvl)
191 {
192  computeVVSInit();
193  unsigned int nbrow = m_error_edgeMulti.getRows();
194 
195  unsigned int iter = 0;
196  // Parametre pour la premiere phase d'asservissement
197  bool reloop = true;
198 
199  bool isoJoIdentity_ = isoJoIdentity; // Backup since it can be modified if L is not full rank
200 
201  std::map<std::string, vpVelocityTwistMatrix> mapOfVelocityTwist;
202  for (std::map<std::string, vpHomogeneousMatrix>::const_iterator it = m_mapOfCameraTransformationMatrix.begin();
203  it != m_mapOfCameraTransformationMatrix.end(); ++it) {
205  cVo.buildFrom(it->second);
206  mapOfVelocityTwist[it->first] = cVo;
207  }
208 
209  // std::cout << "\n\n\ncMo used before the first phase=\n" << cMo <<
210  // std::endl;
211 
212  /*** First phase ***/
213 
214  vpMbEdgeTracker *edge;
215  while (reloop == true && iter < 10) {
216  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
217  it != m_mapOfEdgeTrackers.end(); ++it) {
218  it->second->cMo = m_mapOfCameraTransformationMatrix[it->first] * cMo;
219  }
220 
221  double count = 0;
222  reloop = false;
223 
224  unsigned int start_idx = 0;
225  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
226  it != m_mapOfEdgeTrackers.end(); ++it) {
227  double count_tmp = 0.0;
228  edge = it->second;
229  edge->computeVVSFirstPhase(*mapOfImages[it->first], iter, count_tmp, lvl);
230  count += count_tmp;
231 
232  m_L_edgeMulti.insert(edge->m_L_edge * mapOfVelocityTwist[it->first], start_idx, 0);
233  m_factor.insert(start_idx, edge->m_factor);
234  m_w_edgeMulti.insert(start_idx, edge->m_w_edge);
235  m_error_edgeMulti.insert(start_idx, edge->m_error_edge);
236 
237  start_idx += edge->m_error_edge.getRows();
238  }
239 
240  count = count / (double)nbrow;
241  if (count < 0.85) {
242  reloop = true;
243  }
244 
245  computeVVSFirstPhasePoseEstimation(iter, isoJoIdentity_);
246 
247  iter++;
248  }
249 
250  // std::cout << "\n\t First minimization in " << iter << " iteration give
251  // as initial cMo: \n" << cMo << std::endl; std::cout << "Residual=" <<
252  // m_error.sum() / m_error.size() << std::endl;
253 
254  /*** Second phase ***/
255 
256  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
257  it != m_mapOfEdgeTrackers.end(); ++it) {
258  edge = it->second;
259  edge->m_w_edge = 1;
260  }
261 
262  iter = 0;
263 
264  vpHomogeneousMatrix cMoPrev;
265  vpColVector W_true(nbrow);
266  vpMatrix L_true;
267  vpMatrix LVJ_true;
268 
269  double mu = m_initialMu;
270  vpColVector m_error_prev;
271  vpColVector m_w_prev;
272 
273  double residu_1 = 1e3;
274  double r = 1e3 - 1;
275 
276  // For computeVVSPoseEstimation
277  vpColVector LTR;
278  vpColVector v;
279  vpMatrix LTL;
280 
281  // while ( ((int)((residu_1 - r)*1e8) != 0 ) && (iter<30))
282  while (std::fabs((residu_1 - r) * 1e8) > std::numeric_limits<double>::epsilon() && (iter < m_maxIter)) {
283  computeVVSInteractionMatrixAndResidu(mapOfImages, mapOfVelocityTwist);
284 
285  bool reStartFromLastIncrement = false;
286  computeVVSCheckLevenbergMarquardt(iter, m_error_edgeMulti, m_error_prev, cMoPrev, mu, reStartFromLastIncrement,
287  &m_w_prev);
288 
289  if (!reStartFromLastIncrement) {
291 
292  L_true = m_L_edgeMulti;
294 
295  if (computeCovariance) {
296  L_true = m_L_edgeMulti;
297  if (!isoJoIdentity_) {
298  cVo.buildFrom(cMo);
299  LVJ_true = (m_L_edgeMulti * cVo * oJo);
300  }
301  }
302 
303  double wi = 0.0, eri = 0.0;
304  double num = 0.0, den = 0.0;
305  if ((iter == 0) || m_computeInteraction) {
306  for (unsigned int i = 0; i < nbrow; i++) {
307  wi = m_w_edgeMulti[i] * m_factor[i];
308  W_true[i] = wi;
309  eri = m_error_edgeMulti[i];
310  num += wi * vpMath::sqr(eri);
311  den += wi;
312 
313  m_weightedError_edgeMulti[i] = wi * eri;
314 
315  for (unsigned int j = 0; j < 6; j++) {
316  m_L_edgeMulti[i][j] = wi * m_L_edgeMulti[i][j];
317  }
318  }
319  } else {
320  for (unsigned int i = 0; i < nbrow; i++) {
321  wi = m_w_edgeMulti[i] * m_factor[i];
322  W_true[i] = wi;
323  eri = m_error_edgeMulti[i];
324  num += wi * vpMath::sqr(eri);
325  den += wi;
326 
327  m_weightedError_edgeMulti[i] = wi * eri;
328  }
329  }
330 
331  residu_1 = r;
332  r = sqrt(num / den); // Le critere d'arret prend en compte le poids
333 
335  m_error_prev, LTR, mu, v, &m_w_edgeMulti, &m_w_prev);
336 
337  cMoPrev = cMo;
339  }
340 
341  iter++;
342  }
343 
344  // std::cout << "VVS estimate pose cMo:\n" << cMo << std::endl;
345 
346  computeCovarianceMatrixVVS(isoJoIdentity_, W_true, cMoPrev, L_true, LVJ_true, m_error_edgeMulti);
347 
348  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
349  it != m_mapOfEdgeTrackers.end(); ++it) {
350  edge = it->second;
351  edge->updateMovingEdgeWeights();
352  }
353 }
354 
355 void vpMbEdgeMultiTracker::computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_)
356 {
357  unsigned int nerror = m_weightedError_edgeMulti.getRows();
358 
359  double wi, eri;
360  if ((iter == 0) || m_computeInteraction) {
361  for (unsigned int i = 0; i < nerror; i++) {
362  wi = m_w_edgeMulti[i] * m_factor[i];
363  eri = m_error_edgeMulti[i];
364 
365  m_weightedError_edgeMulti[i] = wi * eri;
366 
367  for (unsigned int j = 0; j < 6; j++) {
368  m_L_edgeMulti[i][j] = wi * m_L_edgeMulti[i][j];
369  }
370  }
371  } else {
372  for (unsigned int i = 0; i < nerror; i++) {
373  wi = m_w_edgeMulti[i] * m_factor[i];
374  eri = m_error_edgeMulti[i];
375 
376  m_weightedError_edgeMulti[i] = wi * eri;
377  }
378  }
379 
381 
382  // If all the 6 dof should be estimated, we check if the interaction matrix
383  // is full rank. If not we remove automatically the dof that cannot be
384  // estimated This is particularly useful when consering circles (rank 5) and
385  // cylinders (rank 4)
386  if (isoJoIdentity_) {
387  cVo.buildFrom(cMo);
388 
389  vpMatrix K; // kernel
390  unsigned int rank = (m_L_edgeMulti * cVo).kernel(K);
391  if (rank == 0) {
392  throw vpException(vpException::fatalError, "Rank=0, cannot estimate the pose !");
393  }
394  if (rank != 6) {
395  vpMatrix I; // Identity
396  I.eye(6);
397  oJo = I - K.AtA();
398 
399  isoJoIdentity_ = false;
400  }
401  }
402 
403  vpColVector v;
404  vpMatrix LTL;
405  vpColVector LTR;
406 
407  if (isoJoIdentity_) {
408  LTL = m_L_edgeMulti.AtA();
410  v = -0.7 * LTL.pseudoInverse(LTL.getRows() * std::numeric_limits<double>::epsilon()) * LTR;
411  } else {
412  cVo.buildFrom(cMo);
413  vpMatrix LVJ = (m_L_edgeMulti * cVo * oJo);
414  vpMatrix LVJTLVJ = (LVJ).AtA();
415  vpColVector LVJTR;
417  v = -0.7 * LVJTLVJ.pseudoInverse(LVJTLVJ.getRows() * std::numeric_limits<double>::epsilon()) * LVJTR;
418  v = cVo * v;
419  }
420 
422 }
423 
425 {
426  unsigned int nbrow = 0;
427 
428  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
429  it != m_mapOfEdgeTrackers.end(); ++it) {
430  vpMbEdgeTracker *edge = it->second;
431 
432  try {
433  edge->computeVVSInit();
434  nbrow += edge->m_error_edge.getRows();
435  } catch (...) {
436  }
437  }
438 
439  if (nbrow < 4) {
441  "No data found to compute the interaction matrix...");
442  }
443 
444  // Initialize with correct size
445  m_L_edgeMulti.resize(nbrow, 6, false, false);
446  m_w_edgeMulti.resize(nbrow, false);
447  m_error_edgeMulti.resize(nbrow, false);
448  m_weightedError_edgeMulti.resize(nbrow, false);
449  m_factor.resize(nbrow, false);
450 }
451 
453 {
454  throw vpException(vpException::fatalError, "vpMbEdgeMultiTracker::"
455  "computeVVSInteractionMatrixAndR"
456  "esidu() should not be called!");
457 }
458 
460  std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
461  std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist)
462 {
463  unsigned int start_idx = 0;
464 
465  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
466  it != m_mapOfEdgeTrackers.end(); ++it) {
467  vpMbEdgeTracker *edge = it->second;
468  edge->cMo = m_mapOfCameraTransformationMatrix[it->first] * cMo;
469 
470  edge->computeVVSInteractionMatrixAndResidu(*mapOfImages[it->first]);
471 
472  m_L_edgeMulti.insert(edge->m_L_edge * mapOfVelocityTwist[it->first], start_idx, 0);
473  m_error_edgeMulti.insert(start_idx, edge->m_error_edge);
474 
475  start_idx += edge->m_error_edge.getRows();
476  }
477 }
478 
480 {
481  unsigned int start_idx = 0;
482 
483  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
484  it != m_mapOfEdgeTrackers.end(); ++it) {
485  vpMbEdgeTracker *edge = it->second;
486 
487  // Compute weights
488  edge->computeVVSWeights();
489 
490  m_w_edgeMulti.insert(start_idx, edge->m_w_edge);
491  start_idx += edge->m_w_edge.getRows();
492  }
493 }
494 
507  const vpCameraParameters &cam_, const vpColor &col, const unsigned int thickness,
508  const bool displayFullModel)
509 {
510 
511  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
512  if (it != m_mapOfEdgeTrackers.end()) {
513  it->second->display(I, cMo_, cam_, col, thickness, displayFullModel);
514  } else {
515  std::cerr << "Cannot find reference camera: " << m_referenceCameraName << " !" << std::endl;
516  }
517 }
518 
531  const vpCameraParameters &cam_, const vpColor &col, const unsigned int thickness,
532  const bool displayFullModel)
533 {
534 
535  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
536  if (it != m_mapOfEdgeTrackers.end()) {
537  it->second->display(I, cMo_, cam_, col, thickness, displayFullModel);
538  } else {
539  std::cerr << "Cannot find reference camera: " << m_referenceCameraName << " !" << std::endl;
540  }
541 }
542 
559  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
560  const vpCameraParameters &cam1, const vpCameraParameters &cam2, const vpColor &col,
561  const unsigned int thickness, const bool displayFullModel)
562 {
563 
564  if (m_mapOfEdgeTrackers.size() == 2) {
565  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
566  it->second->display(I1, c1Mo, cam1, col, thickness, displayFullModel);
567  ++it;
568 
569  it->second->display(I2, c2Mo, cam2, col, thickness, displayFullModel);
570  } else {
571  std::cerr << "This display is only for the stereo case ! There are " << m_mapOfEdgeTrackers.size() << " camera !"
572  << std::endl;
573  }
574 }
575 
592  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
593  const vpCameraParameters &cam1, const vpCameraParameters &cam2, const vpColor &col,
594  const unsigned int thickness, const bool displayFullModel)
595 {
596 
597  if (m_mapOfEdgeTrackers.size() == 2) {
598  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
599  it->second->display(I1, c1Mo, cam1, col, thickness, displayFullModel);
600  ++it;
601 
602  it->second->display(I2, c2Mo, cam2, col, thickness, displayFullModel);
603  } else {
604  std::cerr << "This display is only for the stereo case ! There are " << m_mapOfEdgeTrackers.size() << " cameras !"
605  << std::endl;
606  }
607 }
608 
621 void vpMbEdgeMultiTracker::display(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
622  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
623  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
624  const vpColor &col, const unsigned int thickness, const bool displayFullModel)
625 {
626 
627  // Display only for the given images
628  for (std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.begin();
629  it_img != mapOfImages.end(); ++it_img) {
630  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(it_img->first);
631  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
632  std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
633 
634  if (it_edge != m_mapOfEdgeTrackers.end() && it_camPose != mapOfCameraPoses.end() &&
635  it_cam != mapOfCameraParameters.end()) {
636  it_edge->second->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
637  } else {
638  std::cerr << "Missing elements !" << std::endl;
639  }
640  }
641 }
642 
655 void vpMbEdgeMultiTracker::display(const std::map<std::string, const vpImage<vpRGBa> *> &mapOfImages,
656  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
657  const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
658  const vpColor &col, const unsigned int thickness, const bool displayFullModel)
659 {
660 
661  // Display only for the given images
662  for (std::map<std::string, const vpImage<vpRGBa> *>::const_iterator it_img = mapOfImages.begin();
663  it_img != mapOfImages.end(); ++it_img) {
664  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(it_img->first);
665  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
666  std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
667 
668  if (it_edge != m_mapOfEdgeTrackers.end() && it_camPose != mapOfCameraPoses.end() &&
669  it_cam != mapOfCameraParameters.end()) {
670  it_edge->second->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
671  } else {
672  std::cerr << "Missing elements !" << std::endl;
673  }
674  }
675 }
676 
682 std::vector<std::string> vpMbEdgeMultiTracker::getCameraNames() const
683 {
684  std::vector<std::string> cameraNames;
685 
686  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
687  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
688  cameraNames.push_back(it_edge->first);
689  }
690 
691  return cameraNames;
692 }
693 
700 {
701  // Get the reference camera parameters
702  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
703  if (it != m_mapOfEdgeTrackers.end()) {
704  it->second->getCameraParameters(camera);
705  } else {
706  std::cerr << "The reference camera name: " << m_referenceCameraName << " does not exist !" << std::endl;
707  }
708 }
709 
717 {
718  if (m_mapOfEdgeTrackers.size() == 2) {
719  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
720  it->second->getCameraParameters(cam1);
721  ++it;
722 
723  it->second->getCameraParameters(cam2);
724  } else {
725  std::cerr << "Problem with the number of cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !"
726  << std::endl;
727  }
728 }
729 
736 void vpMbEdgeMultiTracker::getCameraParameters(const std::string &cameraName, vpCameraParameters &camera) const
737 {
738  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
739  if (it != m_mapOfEdgeTrackers.end()) {
740  it->second->getCameraParameters(camera);
741  } else {
742  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
743  }
744 }
745 
751 void vpMbEdgeMultiTracker::getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters) const
752 {
753  // Clear the input map
754  mapOfCameraParameters.clear();
755 
756  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
757  it != m_mapOfEdgeTrackers.end(); ++it) {
758  vpCameraParameters cam_;
759  it->second->getCameraParameters(cam_);
760  mapOfCameraParameters[it->first] = cam_;
761  }
762 }
763 
771 unsigned int vpMbEdgeMultiTracker::getClipping(const std::string &cameraName) const
772 {
773  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
774  if (it != m_mapOfEdgeTrackers.end()) {
775  return it->second->getClipping();
776  } else {
777  std::cerr << "Cannot find camera: " << cameraName << std::endl;
778  }
779 
780  return vpMbTracker::getClipping();
781 }
782 
789 {
790  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
791  if (it != m_mapOfEdgeTrackers.end()) {
792  return it->second->getFaces();
793  }
794 
795  std::cerr << "The reference camera: " << m_referenceCameraName << " cannot be found !" << std::endl;
796  return faces;
797 }
798 
805 {
806  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
807  if (it != m_mapOfEdgeTrackers.end()) {
808  return it->second->getFaces();
809  }
810 
811  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
812  return faces;
813 }
814 
820 std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > vpMbEdgeMultiTracker::getFaces() const
821 {
822  std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > mapOfFaces;
823  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
824  it != m_mapOfEdgeTrackers.end(); ++it) {
825  mapOfFaces[it->first] = it->second->faces;
826  }
827 
828  return mapOfFaces;
829 }
830 
841 void vpMbEdgeMultiTracker::getLcircle(std::list<vpMbtDistanceCircle *> &circlesList, const unsigned int level) const
842 {
843  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
844 
845  if (it_edge != m_mapOfEdgeTrackers.end()) {
846  it_edge->second->getLcircle(circlesList, level);
847  } else {
848  std::cerr << "Cannot find reference camera: " << m_referenceCameraName << " !" << std::endl;
849  }
850 }
851 
863 void vpMbEdgeMultiTracker::getLcircle(const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
864  const unsigned int level) const
865 {
866  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
867  if (it != m_mapOfEdgeTrackers.end()) {
868  it->second->getLcircle(circlesList, level);
869  } else {
870  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
871  }
872 }
873 
884 void vpMbEdgeMultiTracker::getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList,
885  const unsigned int level) const
886 {
887  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
888 
889  if (it_edge != m_mapOfEdgeTrackers.end()) {
890  it_edge->second->getLcylinder(cylindersList, level);
891  } else {
892  std::cerr << "Cannot find reference camera: " << m_referenceCameraName << " !" << std::endl;
893  }
894 }
895 
907 void vpMbEdgeMultiTracker::getLcylinder(const std::string &cameraName,
908  std::list<vpMbtDistanceCylinder *> &cylindersList,
909  const unsigned int level) const
910 {
911  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
912  if (it != m_mapOfEdgeTrackers.end()) {
913  it->second->getLcylinder(cylindersList, level);
914  } else {
915  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
916  }
917 }
918 
929 void vpMbEdgeMultiTracker::getLline(std::list<vpMbtDistanceLine *> &linesList, const unsigned int level) const
930 {
931  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
932 
933  if (it_edge != m_mapOfEdgeTrackers.end()) {
934  it_edge->second->getLline(linesList, level);
935  } else {
936  std::cerr << "Cannot find reference camera: " << m_referenceCameraName << " !" << std::endl;
937  }
938 }
939 
951 void vpMbEdgeMultiTracker::getLline(const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
952  const unsigned int level) const
953 {
954  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
955  if (it != m_mapOfEdgeTrackers.end()) {
956  it->second->getLline(linesList, level);
957  } else {
958  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
959  }
960 }
961 
969 {
970  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
971  if (it_edge != m_mapOfEdgeTrackers.end()) {
972  it_edge->second->getMovingEdge(p_me);
973  } else {
974  std::cerr << "The reference camera: " << m_referenceCameraName << " does not exist !" << std::endl;
975  }
976 }
977 
984 {
985  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
986  vpMe me_tmp;
987  if (it_edge != m_mapOfEdgeTrackers.end()) {
988  it_edge->second->getMovingEdge(me_tmp);
989  } else {
990  std::cerr << "The reference camera: " << m_referenceCameraName << " does not exist !" << std::endl;
991  }
992 
993  return me_tmp;
994 }
995 
1003 void vpMbEdgeMultiTracker::getMovingEdge(const std::string &cameraName, vpMe &p_me) const
1004 {
1005  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
1006  if (it != m_mapOfEdgeTrackers.end()) {
1007  it->second->getMovingEdge(p_me);
1008  } else {
1009  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
1010  }
1011 }
1012 
1020 vpMe vpMbEdgeMultiTracker::getMovingEdge(const std::string &cameraName) const
1021 {
1022  vpMe me_tmp;
1023  getMovingEdge(cameraName, me_tmp);
1024  return me_tmp;
1025 }
1026 
1039 unsigned int vpMbEdgeMultiTracker::getNbPoints(const unsigned int level) const
1040 {
1041  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1042 
1043  unsigned int nbGoodPoints = 0;
1044  if (it_edge != m_mapOfEdgeTrackers.end()) {
1045 
1046  nbGoodPoints += it_edge->second->getNbPoints(level);
1047  } else {
1048  std::cerr << "The reference camera: " << m_referenceCameraName << " does not exist !" << std::endl;
1049  }
1050 
1051  return nbGoodPoints;
1052 }
1053 
1067 unsigned int vpMbEdgeMultiTracker::getNbPoints(const std::string &cameraName, const unsigned int level) const
1068 {
1069  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
1070  if (it != m_mapOfEdgeTrackers.end()) {
1071  return it->second->getNbPoints(level);
1072  } else {
1073  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
1074  }
1075 
1076  return 0;
1077 }
1078 
1085 {
1086  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1087  if (it != m_mapOfEdgeTrackers.end()) {
1088  return it->second->getNbPolygon();
1089  }
1090 
1091  std::cerr << "The reference camera: " << m_referenceCameraName << " cannot be found !" << std::endl;
1092  return 0;
1093 }
1094 
1101 unsigned int vpMbEdgeMultiTracker::getNbPolygon(const std::string &cameraName) const
1102 {
1103  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
1104  if (it != m_mapOfEdgeTrackers.end()) {
1105  return it->second->getNbPolygon();
1106  }
1107 
1108  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
1109  return 0;
1110 }
1111 
1118 std::map<std::string, unsigned int> vpMbEdgeMultiTracker::getMultiNbPolygon() const
1119 {
1120  std::map<std::string, unsigned int> mapOfNbPolygons;
1121  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1122  it != m_mapOfEdgeTrackers.end(); ++it) {
1123  mapOfNbPolygons[it->first] = it->second->getNbPolygon();
1124  }
1125 
1126  return mapOfNbPolygons;
1127 }
1128 
1136 {
1137  if (m_mapOfEdgeTrackers.size() == 2) {
1138  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1139  it->second->getPose(c1Mo);
1140  ++it;
1141 
1142  it->second->getPose(c2Mo);
1143  } else {
1144  std::cerr << "Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !" << std::endl;
1145  }
1146 }
1147 
1156 void vpMbEdgeMultiTracker::getPose(const std::string &cameraName, vpHomogeneousMatrix &cMo_) const
1157 {
1158  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
1159  if (it != m_mapOfEdgeTrackers.end()) {
1160  it->second->getPose(cMo_);
1161  } else {
1162  std::cerr << "The camera: " << cameraName << " does not exist !" << std::endl;
1163  }
1164 }
1165 
1171 void vpMbEdgeMultiTracker::getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses) const
1172 {
1173  // Clear the map
1174  mapOfCameraPoses.clear();
1175 
1176  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1177  it != m_mapOfEdgeTrackers.end(); ++it) {
1178  vpHomogeneousMatrix cMo_;
1179  it->second->getPose(cMo_);
1180  mapOfCameraPoses[it->first] = cMo_;
1181  }
1182 }
1183 
1185 
1186 #ifdef VISP_HAVE_MODULE_GUI
1187 
1197 void vpMbEdgeMultiTracker::initClick(const vpImage<unsigned char> &I, const std::vector<vpPoint> &points3D_list,
1198  const std::string &displayFile)
1199 {
1200  if (m_mapOfEdgeTrackers.empty()) {
1201  throw vpException(vpTrackingException::initializationError, "There is no camera !");
1202  } else if (m_mapOfEdgeTrackers.size() > 1) {
1203  throw vpException(vpTrackingException::initializationError, "There is more than one camera !");
1204  } else {
1205  // Get the vpMbEdgeTracker object for the reference camera name
1206  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1207  if (it != m_mapOfEdgeTrackers.end()) {
1208  it->second->initClick(I, points3D_list, displayFile);
1209  it->second->getPose(cMo);
1210  } else {
1211  std::stringstream ss;
1212  ss << "Cannot initClick as the reference camera: " << m_referenceCameraName << " does not exist !";
1214  }
1215  }
1216 }
1217 
1249 void vpMbEdgeMultiTracker::initClick(const vpImage<unsigned char> &I, const std::string &initFile,
1250  const bool displayHelp, const vpHomogeneousMatrix &T)
1251 {
1252  if (m_mapOfEdgeTrackers.empty()) {
1253  throw vpException(vpTrackingException::initializationError, "There is no camera !");
1254  } else if (m_mapOfEdgeTrackers.size() > 1) {
1255  throw vpException(vpTrackingException::initializationError, "There is more than one camera !");
1256  } else {
1257  // Get the vpMbEdgeTracker object for the reference camera name
1258  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1259  if (it != m_mapOfEdgeTrackers.end()) {
1260  it->second->initClick(I, initFile, displayHelp, T);
1261  it->second->getPose(cMo);
1262  } else {
1263  std::stringstream ss;
1264  ss << "Cannot initClick as the reference camera: " << m_referenceCameraName << " does not exist !";
1266  }
1267  }
1268 }
1269 
1306  const std::string &initFile1, const std::string &initFile2, const bool displayHelp,
1307  const bool firstCameraIsReference)
1308 {
1309  if (m_mapOfEdgeTrackers.size() == 2) {
1310  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1311  it->second->initClick(I1, initFile1, displayHelp);
1312 
1313  if (firstCameraIsReference) {
1314  // Set the reference cMo
1315  it->second->getPose(cMo);
1316 
1317  // Set the reference camera parameters
1318  it->second->getCameraParameters(this->cam);
1319  }
1320 
1321  ++it;
1322 
1323  it->second->initClick(I2, initFile2, displayHelp);
1324 
1325  if (!firstCameraIsReference) {
1326  // Set the reference cMo
1327  it->second->getPose(cMo);
1328 
1329  // Set the reference camera parameters
1330  it->second->getCameraParameters(this->cam);
1331  }
1332  } else {
1333  std::stringstream ss;
1334  ss << "Cannot init click ! Require two cameras but there are " << m_mapOfEdgeTrackers.size() << " cameras !";
1336  }
1337 }
1338 
1368 void vpMbEdgeMultiTracker::initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1369  const std::string &initFile, const bool displayHelp)
1370 {
1371  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1372  if (it_edge != m_mapOfEdgeTrackers.end()) {
1373  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1374  mapOfImages.find(m_referenceCameraName);
1375 
1376  if (it_img != mapOfImages.end()) {
1377  // Init click on reference camera
1378  it_edge->second->initClick(*it_img->second, initFile, displayHelp);
1379 
1380  // Set the reference cMo
1381  it_edge->second->getPose(cMo);
1382 
1383  // Set the pose for the others cameras
1384  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1385  if (it_edge->first != m_referenceCameraName) {
1386  it_img = mapOfImages.find(it_edge->first);
1387  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1388  m_mapOfCameraTransformationMatrix.find(it_edge->first);
1389 
1390  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
1391  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
1392  it_edge->second->setPose(*it_img->second, cCurrentMo);
1393  } else {
1394  std::stringstream ss;
1395  ss << "Cannot init click ! Missing image for camera: " << m_referenceCameraName << " !";
1397  }
1398  }
1399  }
1400  } else {
1401  std::stringstream ss;
1402  ss << "Cannot init click ! Missing image for camera: " << m_referenceCameraName << " !";
1404  }
1405  } else {
1406  std::stringstream ss;
1407  ss << "Cannot init click ! The reference camera: " << m_referenceCameraName << " does not exist !";
1409  }
1410 }
1411 
1441 void vpMbEdgeMultiTracker::initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1442  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp)
1443 {
1444  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1445  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1446  mapOfImages.find(m_referenceCameraName);
1447  std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(m_referenceCameraName);
1448 
1449  if (it_edge != m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1450  // InitClick for the reference camera
1451  it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1452 
1453  // Get reference camera pose
1454  it_edge->second->getPose(cMo);
1455  } else {
1456  throw vpException(vpTrackingException::initializationError, "Cannot initClick for the reference camera !");
1457  }
1458 
1459  // Vector of missing pose matrices for cameras
1460  std::vector<std::string> vectorOfMissingCameraPoses;
1461 
1462  // InitClick for all the cameras that have an initFile
1463  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1464  if (it_edge->first != m_referenceCameraName) {
1465  it_img = mapOfImages.find(it_edge->first);
1466  it_initFile = mapOfInitFiles.find(it_edge->first);
1467 
1468  if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1469  it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1470  } else {
1471  vectorOfMissingCameraPoses.push_back(it_edge->first);
1472  }
1473  }
1474  }
1475 
1476  // SetPose for cameras that do not have an initFile
1477  for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1478  it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1479  it_img = mapOfImages.find(*it1);
1480  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1482 
1483  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
1484  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
1485  m_mapOfEdgeTrackers[*it1]->setPose(*it_img->second, cCurrentMo);
1486  } else {
1487  std::stringstream ss;
1488  ss << "Missing image or missing camera transformation matrix ! Cannot "
1489  "set the pose for camera: "
1490  << (*it1) << " !";
1492  }
1493  }
1494 }
1495 #endif //#ifdef VISP_HAVE_MODULE_GUI
1496 
1516 void vpMbEdgeMultiTracker::initFromPose(const vpImage<unsigned char> &I, const std::string &initFile)
1517 {
1518  // Monocular case only !
1519  if (m_mapOfEdgeTrackers.size() > 1) {
1521  "This method can only be used for the monocular case !");
1522  }
1523 
1524  char s[FILENAME_MAX];
1525  std::fstream finit;
1526  vpPoseVector init_pos;
1527 
1528  std::string ext = ".pos";
1529  size_t pos = initFile.rfind(ext);
1530 
1531  if (pos == initFile.size() - ext.size() && pos != 0)
1532  sprintf(s, "%s", initFile.c_str());
1533  else
1534  sprintf(s, "%s.pos", initFile.c_str());
1535 
1536  finit.open(s, std::ios::in);
1537  if (finit.fail()) {
1538  std::cerr << "cannot read " << s << std::endl;
1539  throw vpException(vpException::ioError, "cannot read init file");
1540  }
1541 
1542  for (unsigned int i = 0; i < 6; i += 1) {
1543  finit >> init_pos[i];
1544  }
1545 
1546  // Set the new pose for the reference camera
1547  cMo.buildFrom(init_pos);
1548 
1549  // Init for the reference camera
1550  std::map<std::string, vpMbEdgeTracker *>::iterator it_ref = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1551  if (it_ref == m_mapOfEdgeTrackers.end()) {
1552  throw vpException(vpTrackingException::initializationError, "Cannot find the reference camera !");
1553  }
1554 
1555  it_ref->second->cMo = cMo;
1556  it_ref->second->init(I);
1557 }
1558 
1566 {
1567  if (m_mapOfEdgeTrackers.size() != 1) {
1568  std::stringstream ss;
1569  ss << "This method requires exactly one camera, there are " << m_mapOfEdgeTrackers.size() << " cameras !";
1571  }
1572 
1573  this->cMo = cMo_;
1574 
1575  // Init for the reference camera
1576  std::map<std::string, vpMbEdgeTracker *>::iterator it_ref = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1577  if (it_ref == m_mapOfEdgeTrackers.end()) {
1578  throw vpException(vpTrackingException::initializationError, "Cannot find the reference camera !");
1579  }
1580 
1581  it_ref->second->cMo = cMo;
1582  it_ref->second->init(I);
1583 }
1584 
1592 {
1593  vpHomogeneousMatrix _cMo(cPo);
1595 }
1596 
1608  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
1609  const bool firstCameraIsReference)
1610 {
1611  // For Edge, initFromPose has the same behavior than setPose
1612  // So, for convenience we call setPose
1613  vpMbEdgeMultiTracker::setPose(I1, I2, c1Mo, c2Mo, firstCameraIsReference);
1614 }
1615 
1623 void vpMbEdgeMultiTracker::initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1624  const vpHomogeneousMatrix &cMo_)
1625 {
1626  // For Edge, initFromPose has the same behavior than setPose
1627  // So, for convenience we call setPose
1628  vpMbEdgeMultiTracker::setPose(mapOfImages, cMo_);
1629 }
1630 
1637 void vpMbEdgeMultiTracker::initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1638  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1639 {
1640  // For Edge, initFromPose has the same behavior than setPose
1641  // So, for convenience we call setPose
1642  vpMbEdgeMultiTracker::setPose(mapOfImages, mapOfCameraPoses);
1643 }
1644 
1645 void vpMbEdgeMultiTracker::initPyramid(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1646  std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid)
1647 {
1648  for (std::map<std::string, const vpImage<unsigned char> *>::const_iterator it = mapOfImages.begin();
1649  it != mapOfImages.end(); ++it) {
1650  pyramid[it->first].resize(scales.size());
1651 
1652  vpMbEdgeTracker::initPyramid(*it->second, pyramid[it->first]);
1653  }
1654 }
1655 
1706 void vpMbEdgeMultiTracker::loadConfigFile(const std::string &configFile)
1707 {
1708  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1709  if (it != m_mapOfEdgeTrackers.end()) {
1710  // Load ConfigFile for reference camera
1711  it->second->loadConfigFile(configFile);
1712  it->second->getCameraParameters(cam);
1713 
1714  // Set Moving Edge parameters
1715  this->me = it->second->getMovingEdge();
1716 
1717  // Set clipping
1718  this->clippingFlag = it->second->getClipping();
1719  this->angleAppears = it->second->getAngleAppear();
1720  this->angleDisappears = it->second->getAngleDisappear();
1721  } else {
1722  std::stringstream ss;
1723  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
1725  }
1726 }
1727 
1744 void vpMbEdgeMultiTracker::loadConfigFile(const std::string &configFile1, const std::string &configFile2,
1745  const bool firstCameraIsReference)
1746 {
1747  if (m_mapOfEdgeTrackers.size() == 2) {
1748  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1749  it->second->loadConfigFile(configFile1);
1750 
1751  if (firstCameraIsReference) {
1752  it->second->getCameraParameters(cam);
1753 
1754  // Set Moving Edge parameters
1755  this->me = it->second->getMovingEdge();
1756 
1757  // Set clipping
1758  this->clippingFlag = it->second->getClipping();
1759  this->angleAppears = it->second->getAngleAppear();
1760  this->angleDisappears = it->second->getAngleDisappear();
1761  }
1762  ++it;
1763 
1764  it->second->loadConfigFile(configFile2);
1765 
1766  if (!firstCameraIsReference) {
1767  it->second->getCameraParameters(cam);
1768 
1769  // Set Moving Edge parameters
1770  this->me = it->second->getMovingEdge();
1771 
1772  // Set clipping
1773  this->clippingFlag = it->second->getClipping();
1774  this->angleAppears = it->second->getAngleAppear();
1775  this->angleDisappears = it->second->getAngleDisappear();
1776  }
1777  } else {
1778  std::stringstream ss;
1779  ss << "Cannot loadConfigFile. Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !";
1781  }
1782 }
1783 
1797 void vpMbEdgeMultiTracker::loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles)
1798 {
1799  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
1800  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1801  std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_edge->first);
1802  if (it_config != mapOfConfigFiles.end()) {
1803  it_edge->second->loadConfigFile(it_config->second);
1804  } else {
1805  std::stringstream ss;
1806  ss << "Missing configuration file for camera: " << it_edge->first << " !";
1808  }
1809  }
1810 
1811  // Set the reference camera parameters
1812  std::map<std::string, vpMbEdgeTracker *>::iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1813  if (it != m_mapOfEdgeTrackers.end()) {
1814  it->second->getCameraParameters(cam);
1815 
1816  // Set Moving Edge parameters
1817  this->me = it->second->getMovingEdge();
1818 
1819  // Set clipping
1820  this->clippingFlag = it->second->getClipping();
1821  this->angleAppears = it->second->getAngleAppear();
1822  this->angleDisappears = it->second->getAngleDisappear();
1823  } else {
1824  std::stringstream ss;
1825  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
1827  }
1828 }
1829 
1857 void vpMbEdgeMultiTracker::loadModel(const std::string &modelFile, const bool verbose,
1858  const vpHomogeneousMatrix &T)
1859 {
1860  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1861  it != m_mapOfEdgeTrackers.end(); ++it) {
1862  it->second->loadModel(modelFile, verbose, T);
1863  }
1864 
1865  modelInitialised = true;
1866 }
1867 
1880 void vpMbEdgeMultiTracker::reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
1881  const vpHomogeneousMatrix &cMo_, const bool verbose,
1882  const vpHomogeneousMatrix &T)
1883 {
1884  if (m_mapOfEdgeTrackers.size() != 1) {
1885  std::stringstream ss;
1886  ss << "This method requires exactly one camera, there are " << m_mapOfEdgeTrackers.size() << " cameras !";
1888  }
1889 
1890  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1891  if (it_edge != m_mapOfEdgeTrackers.end()) {
1892  it_edge->second->reInitModel(I, cad_name, cMo_, verbose, T);
1893 
1894  // Set reference pose
1895  it_edge->second->getPose(cMo);
1896 
1897  modelInitialised = true;
1898  }
1899 }
1900 
1915  const std::string &cad_name, const vpHomogeneousMatrix &c1Mo,
1916  const vpHomogeneousMatrix &c2Mo, const bool verbose,
1917  const bool firstCameraIsReference)
1918 {
1919  if (m_mapOfEdgeTrackers.size() == 2) {
1920  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
1921 
1922  it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1923 
1924  if (firstCameraIsReference) {
1925  // Set reference pose
1926  it_edge->second->getPose(cMo);
1927  }
1928 
1929  ++it_edge;
1930 
1931  it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1932 
1933  if (!firstCameraIsReference) {
1934  // Set reference pose
1935  it_edge->second->getPose(cMo);
1936  }
1937  } else {
1938  throw vpException(vpTrackingException::fatalError, "This method requires exactly two cameras !");
1939  }
1940 }
1941 
1952 void vpMbEdgeMultiTracker::reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1953  const std::string &cad_name,
1954  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1955  const bool verbose)
1956 {
1957  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1958  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1959  mapOfImages.find(m_referenceCameraName);
1960  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(m_referenceCameraName);
1961 
1962  if (it_edge != m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1963  it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1964  modelInitialised = true;
1965 
1966  // Set reference pose
1967  it_edge->second->getPose(cMo);
1968  } else {
1969  throw vpException(vpTrackingException::fatalError, "Cannot reInitModel for reference camera !");
1970  }
1971 
1972  std::vector<std::string> vectorOfMissingCameras;
1973  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1974  if (it_edge->first != m_referenceCameraName) {
1975  it_img = mapOfImages.find(it_edge->first);
1976  it_camPose = mapOfCameraPoses.find(it_edge->first);
1977 
1978  if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1979  it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1980  } else {
1981  vectorOfMissingCameras.push_back(it_edge->first);
1982  }
1983  }
1984  }
1985 
1986  for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1987  ++it) {
1988  it_img = mapOfImages.find(*it);
1989  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1991 
1992  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
1993  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
1994  m_mapOfEdgeTrackers[*it]->reInitModel(*it_img->second, cad_name, cCurrentMo, verbose);
1995  }
1996  }
1997 }
1998 
2004 {
2005  this->cMo.eye();
2006 
2007  // Reset all internal trackers
2008  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2009  it != m_mapOfEdgeTrackers.end(); ++it) {
2010  it->second->resetTracker();
2011  }
2012 
2013  useScanLine = false;
2014 
2015 #ifdef VISP_HAVE_OGRE
2016  useOgre = false;
2017 #endif
2018 
2019  m_computeInteraction = true;
2020  // nline = 0; //Not used in vpMbEdgeMultiTracker class
2021  // ncylinder = 0; //Not used in vpMbEdgeMultiTracker class
2022  m_lambda = 1.0;
2023  // nbvisiblepolygone = 0; //Not used in vpMbEdgeMultiTracker class
2024  percentageGdPt = 0.4;
2025 
2026  angleAppears = vpMath::rad(89);
2029 
2031 
2032  // reinitialization of the scales.
2033  this->setScales(scales);
2034 }
2035 
2046 {
2048 
2049  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2050  it != m_mapOfEdgeTrackers.end(); ++it) {
2051  it->second->setAngleAppear(a);
2052  }
2053 }
2054 
2065 {
2067 
2068  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2069  it != m_mapOfEdgeTrackers.end(); ++it) {
2070  it->second->setAngleDisappear(a);
2071  }
2072 }
2073 
2080 {
2081  if (m_mapOfEdgeTrackers.empty()) {
2082  throw vpException(vpTrackingException::fatalError, "There is no camera !");
2083  } else if (m_mapOfEdgeTrackers.size() > 1) {
2084  throw vpException(vpTrackingException::fatalError, "There is more than one camera !");
2085  } else {
2086  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2087  if (it != m_mapOfEdgeTrackers.end()) {
2088  it->second->setCameraParameters(camera);
2089 
2090  // Set reference camera parameters
2091  this->cam = camera;
2092  } else {
2093  std::stringstream ss;
2094  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
2096  }
2097  }
2098 }
2099 
2109  const bool firstCameraIsReference)
2110 {
2111  if (m_mapOfEdgeTrackers.empty()) {
2112  throw vpException(vpTrackingException::fatalError, "There is no camera !");
2113  } else if (m_mapOfEdgeTrackers.size() == 2) {
2114  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2115  it->second->setCameraParameters(camera1);
2116 
2117  ++it;
2118  it->second->setCameraParameters(camera2);
2119 
2120  if (firstCameraIsReference) {
2121  this->cam = camera1;
2122  } else {
2123  this->cam = camera2;
2124  }
2125  } else {
2126  std::stringstream ss;
2127  ss << "Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !";
2129  }
2130 }
2131 
2138 void vpMbEdgeMultiTracker::setCameraParameters(const std::string &cameraName, const vpCameraParameters &camera)
2139 {
2140  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2141  if (it != m_mapOfEdgeTrackers.end()) {
2142  it->second->setCameraParameters(camera);
2143 
2144  if (it->first == m_referenceCameraName) {
2145  this->cam = camera;
2146  }
2147  } else {
2148  std::stringstream ss;
2149  ss << "The camera: " << cameraName << " does not exist !";
2151  }
2152 }
2153 
2159 void vpMbEdgeMultiTracker::setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters)
2160 {
2161  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
2162  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2163  std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_edge->first);
2164  if (it_cam != mapOfCameraParameters.end()) {
2165  it_edge->second->setCameraParameters(it_cam->second);
2166 
2167  if (it_edge->first == m_referenceCameraName) {
2168  this->cam = it_cam->second;
2169  }
2170  } else {
2171  std::stringstream ss;
2172  ss << "Missing camera parameters for camera: " << it_edge->first << " !";
2174  }
2175  }
2176 }
2177 
2186 void vpMbEdgeMultiTracker::setCameraTransformationMatrix(const std::string &cameraName,
2187  const vpHomogeneousMatrix &cameraTransformationMatrix)
2188 {
2189  std::map<std::string, vpHomogeneousMatrix>::iterator it = m_mapOfCameraTransformationMatrix.find(cameraName);
2190  if (it != m_mapOfCameraTransformationMatrix.end()) {
2191  it->second = cameraTransformationMatrix;
2192  } else {
2193  std::stringstream ss;
2194  ss << "Cannot find camera: " << cameraName << " !";
2196  }
2197 }
2198 
2207  const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2208 {
2209  // Check if all cameras have a transformation matrix
2210  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
2211  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2212  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2213  mapOfTransformationMatrix.find(it_edge->first);
2214 
2215  if (it_camTrans == mapOfTransformationMatrix.end()) {
2216  throw vpException(vpTrackingException::initializationError, "Missing camera transformation matrix !");
2217  }
2218  }
2219 
2220  m_mapOfCameraTransformationMatrix = mapOfTransformationMatrix;
2221 }
2222 
2230 void vpMbEdgeMultiTracker::setClipping(const unsigned int &flags)
2231 {
2232  // Set clipping for vpMbEdgeMultiTracker class
2233  vpMbTracker::setClipping(flags);
2234 
2235  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2236  it != m_mapOfEdgeTrackers.end(); ++it) {
2237  it->second->setClipping(flags);
2238  }
2239 }
2240 
2249 void vpMbEdgeMultiTracker::setClipping(const std::string &cameraName, const unsigned int &flags)
2250 {
2251  // Set clipping for the given camera, do not change the clipping for
2252  // vpMbEdgeMultiTracker class
2253  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2254  if (it != m_mapOfEdgeTrackers.end()) {
2255  it->second->setClipping(flags);
2256  } else {
2257  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2258  }
2259 }
2260 
2267 {
2269 
2270  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2271  it != m_mapOfEdgeTrackers.end(); ++it) {
2272  it->second->setCovarianceComputation(flag);
2273  }
2274 }
2275 
2293 {
2294  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2295  it != m_mapOfEdgeTrackers.end(); ++it) {
2296  it->second->setDisplayFeatures(displayF);
2297  }
2298 
2299  displayFeatures = displayF;
2300 }
2301 
2308 {
2310 
2311  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2312  it != m_mapOfEdgeTrackers.end(); ++it) {
2313  it->second->setFarClippingDistance(dist);
2314  }
2315 }
2316 
2323 void vpMbEdgeMultiTracker::setFarClippingDistance(const std::string &cameraName, const double &dist)
2324 {
2325  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2326  if (it != m_mapOfEdgeTrackers.end()) {
2327  it->second->setFarClippingDistance(dist);
2328  } else {
2329  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2330  }
2331 }
2332 
2347 {
2348  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2349  it != m_mapOfEdgeTrackers.end(); ++it) {
2350  it->second->setGoodMovingEdgesRatioThreshold(threshold);
2351  }
2352 
2353  percentageGdPt = threshold;
2354 }
2355 
2356 #ifdef VISP_HAVE_OGRE
2357 
2367 {
2368  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2369  it != m_mapOfEdgeTrackers.end(); ++it) {
2370  it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2371  }
2372 }
2373 
2384 {
2385  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2386  it != m_mapOfEdgeTrackers.end(); ++it) {
2387  it->second->setNbRayCastingAttemptsForVisibility(attempts);
2388  }
2389 }
2390 #endif
2391 
2403 void vpMbEdgeMultiTracker::setLod(const bool useLod, const std::string &name)
2404 {
2405  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2406  it != m_mapOfEdgeTrackers.end(); ++it) {
2407  it->second->setLod(useLod, name);
2408  }
2409 }
2410 
2423 void vpMbEdgeMultiTracker::setLod(const bool useLod, const std::string &cameraName, const std::string &name)
2424 {
2425  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(cameraName);
2426 
2427  if (it_edge != m_mapOfEdgeTrackers.end()) {
2428  it_edge->second->setLod(useLod, name);
2429  } else {
2430  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
2431  }
2432 }
2433 
2443 void vpMbEdgeMultiTracker::setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name)
2444 {
2445  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2446  it != m_mapOfEdgeTrackers.end(); ++it) {
2447  it->second->setMinLineLengthThresh(minLineLengthThresh, name);
2448  }
2449 }
2450 
2462 void vpMbEdgeMultiTracker::setMinLineLengthThresh(const double minLineLengthThresh, const std::string &cameraName,
2463  const std::string &name)
2464 {
2465  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(cameraName);
2466 
2467  if (it_edge != m_mapOfEdgeTrackers.end()) {
2468  it_edge->second->setMinLineLengthThresh(minLineLengthThresh, name);
2469  } else {
2470  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
2471  }
2472 }
2473 
2482 void vpMbEdgeMultiTracker::setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name)
2483 {
2484  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2485  it != m_mapOfEdgeTrackers.end(); ++it) {
2486  it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2487  }
2488 }
2489 
2500 void vpMbEdgeMultiTracker::setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &cameraName,
2501  const std::string &name)
2502 {
2503  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(cameraName);
2504 
2505  if (it_edge != m_mapOfEdgeTrackers.end()) {
2506  it_edge->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2507  } else {
2508  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
2509  }
2510 }
2511 
2518 {
2519  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2520  it != m_mapOfEdgeTrackers.end(); ++it) {
2521  it->second->setMovingEdge(me);
2522  }
2523 }
2524 
2531 void vpMbEdgeMultiTracker::setMovingEdge(const std::string &cameraName, const vpMe &me)
2532 {
2533  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2534  if (it != m_mapOfEdgeTrackers.end()) {
2535  it->second->setMovingEdge(me);
2536  } else {
2537  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2538  }
2539 }
2540 
2547 {
2549 
2550  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2551  it != m_mapOfEdgeTrackers.end(); ++it) {
2552  it->second->setNearClippingDistance(dist);
2553  }
2554 }
2555 
2562 void vpMbEdgeMultiTracker::setNearClippingDistance(const std::string &cameraName, const double &dist)
2563 {
2564  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2565  if (it != m_mapOfEdgeTrackers.end()) {
2566  it->second->setNearClippingDistance(dist);
2567  } else {
2568  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2569  }
2570 }
2571 
2582 void vpMbEdgeMultiTracker::setOgreShowConfigDialog(const bool showConfigDialog)
2583 {
2584  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2585  it != m_mapOfEdgeTrackers.end(); ++it) {
2586  it->second->setOgreShowConfigDialog(showConfigDialog);
2587  }
2588 }
2589 
2599 {
2600  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2601  it != m_mapOfEdgeTrackers.end(); ++it) {
2602  it->second->setOgreVisibilityTest(v);
2603  }
2604 
2605 #ifdef VISP_HAVE_OGRE
2606  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2607  it != m_mapOfEdgeTrackers.end(); ++it) {
2608  it->second->faces.getOgreContext()->setWindowName("Multi MBT Edge (" + it->first + ")");
2609  }
2610 #endif
2611 
2612  useOgre = v;
2613 }
2614 
2621 {
2622  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2623  it != m_mapOfEdgeTrackers.end(); ++it) {
2624  it->second->setOptimizationMethod(opt);
2625  }
2626 
2627  m_optimizationMethod = opt;
2628 }
2629 
2638 {
2639  if (m_mapOfEdgeTrackers.size() == 1) {
2640  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2641  if (it != m_mapOfEdgeTrackers.end()) {
2642  it->second->setPose(I, cMo_);
2643  this->cMo = cMo_;
2644  } else {
2645  std::stringstream ss;
2646  ss << "Cannot find the reference camera: " << m_referenceCameraName << " !";
2648  }
2649  } else {
2650  std::stringstream ss;
2651  ss << "You are trying to set the pose with only one image and cMo but "
2652  "there are multiple cameras !";
2654  }
2655 }
2656 
2669  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
2670  const bool firstCameraIsReference)
2671 {
2672  if (m_mapOfEdgeTrackers.size() == 2) {
2673  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2674  it->second->setPose(I1, c1Mo);
2675 
2676  ++it;
2677 
2678  it->second->setPose(I2, c2Mo);
2679 
2680  if (firstCameraIsReference) {
2681  this->cMo = c1Mo;
2682  } else {
2683  this->cMo = c2Mo;
2684  }
2685  } else {
2686  std::stringstream ss;
2687  ss << "This method requires 2 cameras but there are " << m_mapOfEdgeTrackers.size() << " cameras !";
2689  }
2690 }
2691 
2700 void vpMbEdgeMultiTracker::setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
2701  const vpHomogeneousMatrix &cMo_)
2702 {
2703  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2704  if (it_edge != m_mapOfEdgeTrackers.end()) {
2705  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2706  mapOfImages.find(m_referenceCameraName);
2707 
2708  if (it_img != mapOfImages.end()) {
2709  // Set pose on reference camera
2710  it_edge->second->setPose(*it_img->second, cMo_);
2711 
2712  // Set the reference cMo
2713  cMo = cMo_;
2714 
2715  // Set the pose for the others cameras
2716  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2717  if (it_edge->first != m_referenceCameraName) {
2718  it_img = mapOfImages.find(it_edge->first);
2719  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2720  m_mapOfCameraTransformationMatrix.find(it_edge->first);
2721 
2722  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
2723  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
2724  it_edge->second->setPose(*it_img->second, cCurrentMo);
2725  } else {
2726  throw vpException(vpTrackingException::fatalError, "Missing image or camera transformation matrix !");
2727  }
2728  }
2729  }
2730  } else {
2731  std::stringstream ss;
2732  ss << "Missing image for camera: " << m_referenceCameraName << " !";
2734  }
2735  } else {
2736  std::stringstream ss;
2737  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
2739  }
2740 }
2741 
2752 void vpMbEdgeMultiTracker::setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
2753  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2754 {
2755  // Set the reference cMo
2756  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2757  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2758  mapOfImages.find(m_referenceCameraName);
2759  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(m_referenceCameraName);
2760 
2761  if (it_edge != m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2762  it_edge->second->setPose(*it_img->second, it_camPose->second);
2763  it_edge->second->getPose(cMo);
2764  } else {
2765  throw vpException(vpTrackingException::fatalError, "Cannot set pose for the reference camera !");
2766  }
2767 
2768  // Vector of missing pose matrices for cameras
2769  std::vector<std::string> vectorOfMissingCameraPoses;
2770 
2771  // Set pose for the specified cameras
2772  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2773  if (it_edge->first != m_referenceCameraName) {
2774  it_img = mapOfImages.find(it_edge->first);
2775  it_camPose = mapOfCameraPoses.find(it_edge->first);
2776 
2777  if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2778  // Set pose
2779  it_edge->second->setPose(*it_img->second, it_camPose->second);
2780  } else {
2781  vectorOfMissingCameraPoses.push_back(it_edge->first);
2782  }
2783  }
2784  }
2785 
2786  for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2787  it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2788  it_img = mapOfImages.find(*it1);
2789  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2791 
2792  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
2793  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
2794  m_mapOfEdgeTrackers[*it1]->setPose(*it_img->second, cCurrentMo);
2795  } else {
2796  std::stringstream ss;
2797  ss << "Missing image or missing camera transformation matrix ! Cannot "
2798  "set the pose for camera: "
2799  << (*it1) << " !";
2801  }
2802  }
2803 }
2804 
2812 {
2813  // Set the flag in the current class
2815 
2816  // Set the flag for each camera
2817  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2818  it != m_mapOfEdgeTrackers.end(); ++it) {
2819  it->second->setProjectionErrorComputation(flag);
2820  }
2821 }
2822 
2828 void vpMbEdgeMultiTracker::setReferenceCameraName(const std::string &referenceCameraName)
2829 {
2830  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(referenceCameraName);
2831  if (it != m_mapOfEdgeTrackers.end()) {
2832  m_referenceCameraName = referenceCameraName;
2833  } else {
2834  std::stringstream ss;
2835  ss << "The reference camera: " << referenceCameraName << " does not exist !";
2837  }
2838 }
2839 
2861 void vpMbEdgeMultiTracker::setScales(const std::vector<bool> &scale)
2862 {
2864  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2865  it != m_mapOfEdgeTrackers.end(); ++it) {
2866  it->second->setScales(scale);
2867  }
2868 }
2869 
2876 {
2877  // Set general setScanLineVisibilityTest
2879 
2880  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2881  it != m_mapOfEdgeTrackers.end(); ++it) {
2882  it->second->setScanLineVisibilityTest(v);
2883  }
2884 }
2885 
2893 void vpMbEdgeMultiTracker::setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
2894 {
2895  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2896  it != m_mapOfEdgeTrackers.end(); ++it) {
2897  it->second->setUseEdgeTracking(name, useEdgeTracking);
2898  }
2899 }
2900 
2909 {
2910  // Track only with reference camera
2911  // Get the reference camera parameters
2912  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2913 
2914  if (it != m_mapOfEdgeTrackers.end()) {
2915  it->second->track(I);
2916  it->second->getPose(cMo);
2917  } else {
2918  std::stringstream ss;
2919  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
2921  }
2922 
2923  if (computeProjError) {
2924  // Use the projection error computed by the single vpMbEdgeTracker in
2925  // m_mapOfEdgeTrackers
2926  projectionError = it->second->getProjectionError();
2927  }
2928 }
2929 
2939 {
2940  // Track with the special case of stereo cameras
2941  if (m_mapOfEdgeTrackers.size() == 2) {
2942  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2943  std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2944  mapOfImages[it->first] = &I1;
2945  ++it;
2946 
2947  mapOfImages[it->first] = &I2;
2948  track(mapOfImages);
2949  } else {
2950  std::stringstream ss;
2951  ss << "Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !";
2953  }
2954 }
2955 
2963 void vpMbEdgeMultiTracker::track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages)
2964 {
2965  // Check if there is an image for each camera
2966  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
2967  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2968  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_edge->first);
2969 
2970  if (it_img == mapOfImages.end()) {
2971  throw vpException(vpTrackingException::fatalError, "Missing images !");
2972  }
2973  }
2974 
2975  initPyramid(mapOfImages, m_mapOfPyramidalImages);
2976 
2977  unsigned int lvl = (unsigned int)scales.size();
2978  do {
2979  lvl--;
2980 
2981  projectionError = 90.0;
2982 
2983  if (scales[lvl]) {
2984  vpHomogeneousMatrix cMo_1 = cMo;
2985  try {
2986  downScale(lvl);
2987  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it1 = m_mapOfEdgeTrackers.begin();
2988  it1 != m_mapOfEdgeTrackers.end(); ++it1) {
2989  // Downscale for each camera
2990  it1->second->downScale(lvl);
2991 
2992  // Track moving edges
2993  try {
2994  it1->second->trackMovingEdge(*m_mapOfPyramidalImages[it1->first][lvl]);
2995  } catch (...) {
2996  vpTRACE("Error in moving edge tracking");
2997  throw;
2998  }
2999  }
3000 
3001  try {
3002  std::map<std::string, const vpImage<unsigned char> *> mapOfPyramidImages;
3003  for (std::map<std::string, std::vector<const vpImage<unsigned char> *> >::const_iterator it =
3004  m_mapOfPyramidalImages.begin();
3005  it != m_mapOfPyramidalImages.end(); ++it) {
3006  mapOfPyramidImages[it->first] = it->second[lvl];
3007  }
3008 
3009  computeVVS(mapOfPyramidImages, lvl);
3010  } catch (...) {
3011  covarianceMatrix = -1;
3012  throw; // throw the original exception
3013  }
3014 
3015  // Test tracking failed only if all testTracking failed
3016  bool isOneTestTrackingOk = false;
3017  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3018  it != m_mapOfEdgeTrackers.end(); ++it) {
3019  // Set the camera pose
3020  it->second->cMo = m_mapOfCameraTransformationMatrix[it->first] * cMo;
3021 
3022  try {
3023  it->second->testTracking();
3024  isOneTestTrackingOk = true;
3025  } catch (/*vpException &e*/...) {
3026  // throw e;
3027  }
3028  }
3029 
3030  if (!isOneTestTrackingOk) {
3031  std::ostringstream oss;
3032  oss << "Not enough moving edges to track the object. Try to reduce "
3033  "the threshold="
3034  << percentageGdPt << " using setGoodMovingEdgesRatioThreshold()";
3036  }
3037 
3038  if (displayFeatures) {
3039  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3040  it != m_mapOfEdgeTrackers.end(); ++it) {
3041  it->second->displayFeaturesOnImage(*mapOfImages[it->first], lvl);
3042  }
3043  }
3044 
3045  // Looking for new visible face
3046  bool newvisibleface = false;
3047  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3048  it != m_mapOfEdgeTrackers.end(); ++it) {
3049  it->second->visibleFace(*mapOfImages[it->first], it->second->cMo, newvisibleface);
3050  }
3051 
3052  if (useScanLine) {
3053  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3054  it != m_mapOfEdgeTrackers.end(); ++it) {
3055  it->second->faces.computeClippedPolygons(it->second->cMo, it->second->cam);
3056  it->second->faces.computeScanLineRender(it->second->cam, mapOfImages[it->first]->getWidth(),
3057  mapOfImages[it->first]->getHeight());
3058  }
3059  }
3060 
3061  try {
3062  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3063  it != m_mapOfEdgeTrackers.end(); ++it) {
3064  it->second->updateMovingEdge(*mapOfImages[it->first]);
3065  }
3066  } catch (...) {
3067  throw; // throw the original exception
3068  }
3069 
3070  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3071  it != m_mapOfEdgeTrackers.end(); ++it) {
3072  it->second->initMovingEdge(*mapOfImages[it->first], it->second->cMo);
3073 
3074  // Reinit the moving edge for the lines which need it.
3075  it->second->reinitMovingEdge(*mapOfImages[it->first], it->second->cMo);
3076 
3077  if (computeProjError) {
3078  // Compute the projection error
3079  it->second->computeProjectionError(*mapOfImages[it->first]);
3080  }
3081  }
3082 
3084 
3085  upScale(lvl);
3086  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3087  it != m_mapOfEdgeTrackers.end(); ++it) {
3088  it->second->upScale(lvl);
3089  }
3090  } catch (const vpException &e) {
3091  if (lvl != 0) {
3092  cMo = cMo_1;
3093  reInitLevel(lvl);
3094  upScale(lvl);
3095 
3096  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3097  it != m_mapOfEdgeTrackers.end(); ++it) {
3098  it->second->cMo = cMo_1;
3099  it->second->reInitLevel(lvl);
3100  it->second->upScale(lvl);
3101  }
3102  } else {
3103  upScale(lvl);
3104  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3105  it != m_mapOfEdgeTrackers.end(); ++it) {
3106  it->second->upScale(lvl);
3107  }
3108  throw(e);
3109  }
3110  }
3111  }
3112  } while (lvl != 0);
3113 
3115 }
3116 #elif !defined(VISP_BUILD_SHARED_LIBS)
3117 // Work arround to avoid warning: libvisp_mbt.a(vpMbEdgeMultiTracker.cpp.o) has no symbols
3118 void dummy_vpMbEdgeMultiTracker(){}
3119 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
bool m_computeInteraction
Definition: vpMbTracker.h:191
bool computeProjError
Definition: vpMbTracker.h:139
std::string m_referenceCameraName
Name of the reference camera.
virtual void setCovarianceComputation(const bool &flag)
Definition: vpMbTracker.h:485
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
vpMatrix covarianceMatrix
Covariance matrix.
Definition: vpMbTracker.h:136
virtual void computeVVSInteractionMatrixAndResidu()
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
virtual void setFarClippingDistance(const double &dist)
virtual void setLod(const bool useLod, const std::string &name="")
vpColVector m_error_edge
(s - s*)
virtual void loadModel(const std::string &modelFile, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
void upScale(const unsigned int _scale)
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:256
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:466
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
Definition: vpMbTracker.h:149
virtual void computeProjectionError()
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void setDisplayFeatures(const bool displayF)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true, const bool recopy_=true)
Definition: vpArray2D.h:171
virtual std::map< std::string, unsigned int > getMultiNbPolygon() const
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
vpColVector m_factor
Edge VVS variables.
virtual void track(const vpImage< unsigned char > &I)
vpHomogeneousMatrix cMo
The current pose.
Definition: vpMbTracker.h:119
virtual void setProjectionErrorComputation(const bool &flag)
virtual void loadConfigFile(const std::string &configFile)
vpColVector m_w_edgeMulti
Robust weights.
bool modelInitialised
Definition: vpMbTracker.h:129
virtual void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_)
virtual void cleanPyramid(std::map< std::string, std::vector< const vpImage< unsigned char > * > > &pyramid)
vpColVector m_w_edge
Robust weights.
error that can be emited by ViSP classes.
Definition: vpException.h:71
void reInitLevel(const unsigned int _lvl)
virtual vpMe getMovingEdge() const
virtual void setClipping(const unsigned int &flags)
Definition: vpMe.h:60
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Make the complete tracking of an object by using its CAD model.
bool useOgre
Use Ogre3d for visibility tests.
Definition: vpMbTracker.h:161
vpColVector m_error_edgeMulti
(s - s*)
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
Definition: vpMbTracker.h:134
vpMe me
The moving edges parameters.
virtual unsigned int getNbPolygon() const
virtual void setReferenceCameraName(const std::string &referenceCameraName)
virtual void setNearClippingDistance(const double &dist)
void downScale(const unsigned int _scale)
vpCameraParameters cam
The camera parameters.
Definition: vpMbTracker.h:117
virtual void computeVVSWeights()
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
double projectionError
Definition: vpMbTracker.h:142
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 setGoodNbRayCastingAttemptsRatio(const double &ratio)
void insert(const vpMatrix &A, const unsigned int r, const unsigned int c)
Definition: vpMatrix.cpp:4570
vpMatrix oJo
The Degrees of Freedom to estimate.
Definition: vpMbTracker.h:121
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
virtual void initClick(const vpImage< unsigned char > &I, const std::vector< vpPoint > &points3D_list, const std::string &displayFile="")
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
vpMatrix m_L_edgeMulti
Interaction matrix.
Error that can be emited by the vpTracker class and its derivates.
void init(const vpImage< unsigned char > &I)
vp_deprecated void init()
vpMatrix AtA() const
Definition: vpMatrix.cpp:524
virtual vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:423
virtual void setOgreVisibilityTest(const bool &v)
bool useScanLine
Use Scanline for visibility tests.
Definition: vpMbTracker.h:164
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, const unsigned int lvl)
#define vpTRACE
Definition: vpDebug.h:416
static double sqr(double x)
Definition: vpMath.h:108
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
virtual void setCameraParameters(const vpCameraParameters &camera)
unsigned int nbFeaturesForProjErrorComputation
Number of features used in the computation of the projection error.
void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, const unsigned int level=0) const
Generic class defining intrinsic camera parameters.
virtual void setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
virtual void computeVVSInteractionMatrixAndResidu()
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
Definition: vpMbTracker.h:199
void getLline(std::list< vpMbtDistanceLine * > &linesList, const unsigned int level=0) const
double m_lambda
Gain of the virtual visual servoing stage.
Definition: vpMbTracker.h:193
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
virtual void setAngleAppear(const double &a)
Definition: vpMbTracker.h:455
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
Definition: vpMbTracker.h:146
unsigned int getRows() const
Definition: vpArray2D.h:156
std::map< std::string, vpMbEdgeTracker * > m_mapOfEdgeTrackers
Map of Model-based edge trackers.
double angleAppears
Angle used to detect a face appearance.
Definition: vpMbTracker.h:151
virtual void setCovarianceComputation(const bool &flag)
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
Definition: vpMbTracker.h:195
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double rad(double deg)
Definition: vpMath.h:102
virtual void setMovingEdge(const vpMe &me)
void insert(unsigned int i, const vpColVector &v)
virtual void setScales(const std::vector< bool > &scales)
void setScales(const std::vector< bool > &_scales)
static double deg(double rad)
Definition: vpMath.h:95
bool displayFeatures
If true, the features are displayed.
Definition: vpMbTracker.h:144
virtual void getCameraParameters(vpCameraParameters &camera) const
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
std::map< std::string, std::vector< const vpImage< unsigned char > * > > m_mapOfPyramidalImages
Map of pyramidal images for each camera.
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)
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:92
vpHomogeneousMatrix inverse() const
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
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)
double angleDisappears
Angle used to detect a face disappearance.
Definition: vpMbTracker.h:153
void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, const unsigned int level=0) const
virtual void computeVVSInit()
virtual std::vector< std::string > getCameraNames() const
virtual unsigned int getNbPoints(const unsigned int level=0) const
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:587
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Definition: vpMatrix.cpp:1932
virtual void setClipping(const unsigned int &flags)
virtual void setAngleDisappear(const double &a)
virtual void setGoodMovingEdgesRatioThreshold(const double threshold)
unsigned int clippingFlag
Flags specifying which clipping to used.
Definition: vpMbTracker.h:159
vpMatrix m_L_edge
Interaction matrix.
virtual void setFarClippingDistance(const double &dist)
void computeVVSFirstPhase(const vpImage< unsigned char > &I, const unsigned int iter, double &count, const unsigned int lvl=0)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
void eye()
Definition: vpMatrix.cpp:360
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)
vpColVector m_weightedError_edgeMulti
Weighted error.
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
Definition: vpMbTracker.h:123
virtual void setAngleAppear(const double &a)
virtual void initPyramid(const std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, std::map< std::string, std::vector< const vpImage< unsigned char > * > > &pyramid)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:244
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:570
virtual void setNearClippingDistance(const double &dist)