Visual Servoing Platform  version 3.1.0
vpMbEdgeMultiTracker.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2016 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 https://visp.inria.fr/download/ 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  * http://www.irisa.fr/lagadic
25  *
26  * If you have questions regarding the use of this file, please contact
27  * INRIA at visp@inria.fr
28  *
29  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31  *
32  *
33  * Description:
34  * Model-based edge tracker with multiple cameras.
35  *
36  * Authors:
37  * Souriya Trinh
38  *
39  *****************************************************************************/
40 
46 #include <visp3/core/vpDebug.h>
47 #include <visp3/core/vpExponentialMap.h>
48 #include <visp3/core/vpTrackingException.h>
49 #include <visp3/core/vpVelocityTwistMatrix.h>
50 #include <visp3/mbt/vpMbEdgeMultiTracker.h>
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 
1247 void vpMbEdgeMultiTracker::initClick(const vpImage<unsigned char> &I, const std::string &initFile,
1248  const bool displayHelp)
1249 {
1250  if (m_mapOfEdgeTrackers.empty()) {
1251  throw vpException(vpTrackingException::initializationError, "There is no camera !");
1252  } else if (m_mapOfEdgeTrackers.size() > 1) {
1253  throw vpException(vpTrackingException::initializationError, "There is more than one camera !");
1254  } else {
1255  // Get the vpMbEdgeTracker object for the reference camera name
1256  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1257  if (it != m_mapOfEdgeTrackers.end()) {
1258  it->second->initClick(I, initFile, displayHelp);
1259  it->second->getPose(cMo);
1260  } else {
1261  std::stringstream ss;
1262  ss << "Cannot initClick as the reference camera: " << m_referenceCameraName << " does not exist !";
1264  }
1265  }
1266 }
1267 
1304  const std::string &initFile1, const std::string &initFile2, const bool displayHelp,
1305  const bool firstCameraIsReference)
1306 {
1307  if (m_mapOfEdgeTrackers.size() == 2) {
1308  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1309  it->second->initClick(I1, initFile1, displayHelp);
1310 
1311  if (firstCameraIsReference) {
1312  // Set the reference cMo
1313  it->second->getPose(cMo);
1314 
1315  // Set the reference camera parameters
1316  it->second->getCameraParameters(this->cam);
1317  }
1318 
1319  ++it;
1320 
1321  it->second->initClick(I2, initFile2, displayHelp);
1322 
1323  if (!firstCameraIsReference) {
1324  // Set the reference cMo
1325  it->second->getPose(cMo);
1326 
1327  // Set the reference camera parameters
1328  it->second->getCameraParameters(this->cam);
1329  }
1330  } else {
1331  std::stringstream ss;
1332  ss << "Cannot init click ! Require two cameras but there are " << m_mapOfEdgeTrackers.size() << " cameras !";
1334  }
1335 }
1336 
1366 void vpMbEdgeMultiTracker::initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1367  const std::string &initFile, const bool displayHelp)
1368 {
1369  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1370  if (it_edge != m_mapOfEdgeTrackers.end()) {
1371  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1372  mapOfImages.find(m_referenceCameraName);
1373 
1374  if (it_img != mapOfImages.end()) {
1375  // Init click on reference camera
1376  it_edge->second->initClick(*it_img->second, initFile, displayHelp);
1377 
1378  // Set the reference cMo
1379  it_edge->second->getPose(cMo);
1380 
1381  // Set the pose for the others cameras
1382  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1383  if (it_edge->first != m_referenceCameraName) {
1384  it_img = mapOfImages.find(it_edge->first);
1385  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1386  m_mapOfCameraTransformationMatrix.find(it_edge->first);
1387 
1388  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
1389  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
1390  it_edge->second->setPose(*it_img->second, cCurrentMo);
1391  } else {
1392  std::stringstream ss;
1393  ss << "Cannot init click ! Missing image for camera: " << m_referenceCameraName << " !";
1395  }
1396  }
1397  }
1398  } else {
1399  std::stringstream ss;
1400  ss << "Cannot init click ! Missing image for camera: " << m_referenceCameraName << " !";
1402  }
1403  } else {
1404  std::stringstream ss;
1405  ss << "Cannot init click ! The reference camera: " << m_referenceCameraName << " does not exist !";
1407  }
1408 }
1409 
1439 void vpMbEdgeMultiTracker::initClick(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1440  const std::map<std::string, std::string> &mapOfInitFiles, const bool displayHelp)
1441 {
1442  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1443  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1444  mapOfImages.find(m_referenceCameraName);
1445  std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(m_referenceCameraName);
1446 
1447  if (it_edge != m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1448  // InitClick for the reference camera
1449  it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1450 
1451  // Get reference camera pose
1452  it_edge->second->getPose(cMo);
1453  } else {
1454  throw vpException(vpTrackingException::initializationError, "Cannot initClick for the reference camera !");
1455  }
1456 
1457  // Vector of missing pose matrices for cameras
1458  std::vector<std::string> vectorOfMissingCameraPoses;
1459 
1460  // InitClick for all the cameras that have an initFile
1461  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1462  if (it_edge->first != m_referenceCameraName) {
1463  it_img = mapOfImages.find(it_edge->first);
1464  it_initFile = mapOfInitFiles.find(it_edge->first);
1465 
1466  if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1467  it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1468  } else {
1469  vectorOfMissingCameraPoses.push_back(it_edge->first);
1470  }
1471  }
1472  }
1473 
1474  // SetPose for cameras that do not have an initFile
1475  for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1476  it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1477  it_img = mapOfImages.find(*it1);
1478  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1480 
1481  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
1482  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
1483  m_mapOfEdgeTrackers[*it1]->setPose(*it_img->second, cCurrentMo);
1484  } else {
1485  std::stringstream ss;
1486  ss << "Missing image or missing camera transformation matrix ! Cannot "
1487  "set the pose for camera: "
1488  << (*it1) << " !";
1490  }
1491  }
1492 }
1493 #endif //#ifdef VISP_HAVE_MODULE_GUI
1494 
1514 void vpMbEdgeMultiTracker::initFromPose(const vpImage<unsigned char> &I, const std::string &initFile)
1515 {
1516  // Monocular case only !
1517  if (m_mapOfEdgeTrackers.size() > 1) {
1519  "This method can only be used for the monocular case !");
1520  }
1521 
1522  char s[FILENAME_MAX];
1523  std::fstream finit;
1524  vpPoseVector init_pos;
1525 
1526  std::string ext = ".pos";
1527  size_t pos = initFile.rfind(ext);
1528 
1529  if (pos == initFile.size() - ext.size() && pos != 0)
1530  sprintf(s, "%s", initFile.c_str());
1531  else
1532  sprintf(s, "%s.pos", initFile.c_str());
1533 
1534  finit.open(s, std::ios::in);
1535  if (finit.fail()) {
1536  std::cerr << "cannot read " << s << std::endl;
1537  throw vpException(vpException::ioError, "cannot read init file");
1538  }
1539 
1540  for (unsigned int i = 0; i < 6; i += 1) {
1541  finit >> init_pos[i];
1542  }
1543 
1544  // Set the new pose for the reference camera
1545  cMo.buildFrom(init_pos);
1546 
1547  // Init for the reference camera
1548  std::map<std::string, vpMbEdgeTracker *>::iterator it_ref = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1549  if (it_ref == m_mapOfEdgeTrackers.end()) {
1550  throw vpException(vpTrackingException::initializationError, "Cannot find the reference camera !");
1551  }
1552 
1553  it_ref->second->cMo = cMo;
1554  it_ref->second->init(I);
1555 }
1556 
1564 {
1565  if (m_mapOfEdgeTrackers.size() != 1) {
1566  std::stringstream ss;
1567  ss << "This method requires exactly one camera, there are " << m_mapOfEdgeTrackers.size() << " cameras !";
1569  }
1570 
1571  this->cMo = cMo_;
1572 
1573  // Init for the reference camera
1574  std::map<std::string, vpMbEdgeTracker *>::iterator it_ref = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1575  if (it_ref == m_mapOfEdgeTrackers.end()) {
1576  throw vpException(vpTrackingException::initializationError, "Cannot find the reference camera !");
1577  }
1578 
1579  it_ref->second->cMo = cMo;
1580  it_ref->second->init(I);
1581 }
1582 
1590 {
1591  vpHomogeneousMatrix _cMo(cPo);
1593 }
1594 
1606  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
1607  const bool firstCameraIsReference)
1608 {
1609  // For Edge, initFromPose has the same behavior than setPose
1610  // So, for convenience we call setPose
1611  vpMbEdgeMultiTracker::setPose(I1, I2, c1Mo, c2Mo, firstCameraIsReference);
1612 }
1613 
1621 void vpMbEdgeMultiTracker::initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1622  const vpHomogeneousMatrix &cMo_)
1623 {
1624  // For Edge, initFromPose has the same behavior than setPose
1625  // So, for convenience we call setPose
1626  vpMbEdgeMultiTracker::setPose(mapOfImages, cMo_);
1627 }
1628 
1635 void vpMbEdgeMultiTracker::initFromPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1636  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1637 {
1638  // For Edge, initFromPose has the same behavior than setPose
1639  // So, for convenience we call setPose
1640  vpMbEdgeMultiTracker::setPose(mapOfImages, mapOfCameraPoses);
1641 }
1642 
1643 void vpMbEdgeMultiTracker::initPyramid(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1644  std::map<std::string, std::vector<const vpImage<unsigned char> *> > &pyramid)
1645 {
1646  for (std::map<std::string, const vpImage<unsigned char> *>::const_iterator it = mapOfImages.begin();
1647  it != mapOfImages.end(); ++it) {
1648  pyramid[it->first].resize(scales.size());
1649 
1650  vpMbEdgeTracker::initPyramid(*it->second, pyramid[it->first]);
1651  }
1652 }
1653 
1704 void vpMbEdgeMultiTracker::loadConfigFile(const std::string &configFile)
1705 {
1706  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1707  if (it != m_mapOfEdgeTrackers.end()) {
1708  // Load ConfigFile for reference camera
1709  it->second->loadConfigFile(configFile);
1710  it->second->getCameraParameters(cam);
1711 
1712  // Set Moving Edge parameters
1713  this->me = it->second->getMovingEdge();
1714 
1715  // Set clipping
1716  this->clippingFlag = it->second->getClipping();
1717  this->angleAppears = it->second->getAngleAppear();
1718  this->angleDisappears = it->second->getAngleDisappear();
1719  } else {
1720  std::stringstream ss;
1721  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
1723  }
1724 }
1725 
1742 void vpMbEdgeMultiTracker::loadConfigFile(const std::string &configFile1, const std::string &configFile2,
1743  const bool firstCameraIsReference)
1744 {
1745  if (m_mapOfEdgeTrackers.size() == 2) {
1746  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1747  it->second->loadConfigFile(configFile1);
1748 
1749  if (firstCameraIsReference) {
1750  it->second->getCameraParameters(cam);
1751 
1752  // Set Moving Edge parameters
1753  this->me = it->second->getMovingEdge();
1754 
1755  // Set clipping
1756  this->clippingFlag = it->second->getClipping();
1757  this->angleAppears = it->second->getAngleAppear();
1758  this->angleDisappears = it->second->getAngleDisappear();
1759  }
1760  ++it;
1761 
1762  it->second->loadConfigFile(configFile2);
1763 
1764  if (!firstCameraIsReference) {
1765  it->second->getCameraParameters(cam);
1766 
1767  // Set Moving Edge parameters
1768  this->me = it->second->getMovingEdge();
1769 
1770  // Set clipping
1771  this->clippingFlag = it->second->getClipping();
1772  this->angleAppears = it->second->getAngleAppear();
1773  this->angleDisappears = it->second->getAngleDisappear();
1774  }
1775  } else {
1776  std::stringstream ss;
1777  ss << "Cannot loadConfigFile. Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !";
1779  }
1780 }
1781 
1795 void vpMbEdgeMultiTracker::loadConfigFile(const std::map<std::string, std::string> &mapOfConfigFiles)
1796 {
1797  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
1798  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1799  std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_edge->first);
1800  if (it_config != mapOfConfigFiles.end()) {
1801  it_edge->second->loadConfigFile(it_config->second);
1802  } else {
1803  std::stringstream ss;
1804  ss << "Missing configuration file for camera: " << it_edge->first << " !";
1806  }
1807  }
1808 
1809  // Set the reference camera parameters
1810  std::map<std::string, vpMbEdgeTracker *>::iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1811  if (it != m_mapOfEdgeTrackers.end()) {
1812  it->second->getCameraParameters(cam);
1813 
1814  // Set Moving Edge parameters
1815  this->me = it->second->getMovingEdge();
1816 
1817  // Set clipping
1818  this->clippingFlag = it->second->getClipping();
1819  this->angleAppears = it->second->getAngleAppear();
1820  this->angleDisappears = it->second->getAngleDisappear();
1821  } else {
1822  std::stringstream ss;
1823  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
1825  }
1826 }
1827 
1853 void vpMbEdgeMultiTracker::loadModel(const std::string &modelFile, const bool verbose)
1854 {
1855  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
1856  it != m_mapOfEdgeTrackers.end(); ++it) {
1857  it->second->loadModel(modelFile, verbose);
1858  }
1859 
1860  modelInitialised = true;
1861 }
1862 
1872 void vpMbEdgeMultiTracker::reInitModel(const vpImage<unsigned char> &I, const std::string &cad_name,
1873  const vpHomogeneousMatrix &cMo_, const bool verbose)
1874 {
1875  if (m_mapOfEdgeTrackers.size() != 1) {
1876  std::stringstream ss;
1877  ss << "This method requires exactly one camera, there are " << m_mapOfEdgeTrackers.size() << " cameras !";
1879  }
1880 
1881  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1882  if (it_edge != m_mapOfEdgeTrackers.end()) {
1883  it_edge->second->reInitModel(I, cad_name, cMo_, verbose);
1884 
1885  // Set reference pose
1886  it_edge->second->getPose(cMo);
1887 
1888  modelInitialised = true;
1889  }
1890 }
1891 
1906  const std::string &cad_name, const vpHomogeneousMatrix &c1Mo,
1907  const vpHomogeneousMatrix &c2Mo, const bool verbose,
1908  const bool firstCameraIsReference)
1909 {
1910  if (m_mapOfEdgeTrackers.size() == 2) {
1911  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
1912 
1913  it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1914 
1915  if (firstCameraIsReference) {
1916  // Set reference pose
1917  it_edge->second->getPose(cMo);
1918  }
1919 
1920  ++it_edge;
1921 
1922  it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1923 
1924  if (!firstCameraIsReference) {
1925  // Set reference pose
1926  it_edge->second->getPose(cMo);
1927  }
1928  } else {
1929  throw vpException(vpTrackingException::fatalError, "This method requires exactly two cameras !");
1930  }
1931 }
1932 
1943 void vpMbEdgeMultiTracker::reInitModel(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
1944  const std::string &cad_name,
1945  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1946  const bool verbose)
1947 {
1948  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
1949  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1950  mapOfImages.find(m_referenceCameraName);
1951  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(m_referenceCameraName);
1952 
1953  if (it_edge != m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1954  it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1955  modelInitialised = true;
1956 
1957  // Set reference pose
1958  it_edge->second->getPose(cMo);
1959  } else {
1960  throw vpException(vpTrackingException::fatalError, "Cannot reInitModel for reference camera !");
1961  }
1962 
1963  std::vector<std::string> vectorOfMissingCameras;
1964  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
1965  if (it_edge->first != m_referenceCameraName) {
1966  it_img = mapOfImages.find(it_edge->first);
1967  it_camPose = mapOfCameraPoses.find(it_edge->first);
1968 
1969  if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1970  it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1971  } else {
1972  vectorOfMissingCameras.push_back(it_edge->first);
1973  }
1974  }
1975  }
1976 
1977  for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1978  ++it) {
1979  it_img = mapOfImages.find(*it);
1980  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1982 
1983  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
1984  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
1985  m_mapOfEdgeTrackers[*it]->reInitModel(*it_img->second, cad_name, cCurrentMo, verbose);
1986  }
1987  }
1988 }
1989 
1995 {
1996  this->cMo.eye();
1997 
1998  // Reset all internal trackers
1999  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2000  it != m_mapOfEdgeTrackers.end(); ++it) {
2001  it->second->resetTracker();
2002  }
2003 
2004  useScanLine = false;
2005 
2006 #ifdef VISP_HAVE_OGRE
2007  useOgre = false;
2008 #endif
2009 
2010  m_computeInteraction = true;
2011  // nline = 0; //Not used in vpMbEdgeMultiTracker class
2012  // ncylinder = 0; //Not used in vpMbEdgeMultiTracker class
2013  m_lambda = 1.0;
2014  // nbvisiblepolygone = 0; //Not used in vpMbEdgeMultiTracker class
2015  percentageGdPt = 0.4;
2016 
2017  angleAppears = vpMath::rad(89);
2020 
2022 
2023  // reinitialization of the scales.
2024  this->setScales(scales);
2025 }
2026 
2037 {
2039 
2040  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2041  it != m_mapOfEdgeTrackers.end(); ++it) {
2042  it->second->setAngleAppear(a);
2043  }
2044 }
2045 
2056 {
2058 
2059  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2060  it != m_mapOfEdgeTrackers.end(); ++it) {
2061  it->second->setAngleDisappear(a);
2062  }
2063 }
2064 
2071 {
2072  if (m_mapOfEdgeTrackers.empty()) {
2073  throw vpException(vpTrackingException::fatalError, "There is no camera !");
2074  } else if (m_mapOfEdgeTrackers.size() > 1) {
2075  throw vpException(vpTrackingException::fatalError, "There is more than one camera !");
2076  } else {
2077  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2078  if (it != m_mapOfEdgeTrackers.end()) {
2079  it->second->setCameraParameters(camera);
2080 
2081  // Set reference camera parameters
2082  this->cam = camera;
2083  } else {
2084  std::stringstream ss;
2085  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
2087  }
2088  }
2089 }
2090 
2100  const bool firstCameraIsReference)
2101 {
2102  if (m_mapOfEdgeTrackers.empty()) {
2103  throw vpException(vpTrackingException::fatalError, "There is no camera !");
2104  } else if (m_mapOfEdgeTrackers.size() == 2) {
2105  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2106  it->second->setCameraParameters(camera1);
2107 
2108  ++it;
2109  it->second->setCameraParameters(camera2);
2110 
2111  if (firstCameraIsReference) {
2112  this->cam = camera1;
2113  } else {
2114  this->cam = camera2;
2115  }
2116  } else {
2117  std::stringstream ss;
2118  ss << "Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !";
2120  }
2121 }
2122 
2129 void vpMbEdgeMultiTracker::setCameraParameters(const std::string &cameraName, const vpCameraParameters &camera)
2130 {
2131  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2132  if (it != m_mapOfEdgeTrackers.end()) {
2133  it->second->setCameraParameters(camera);
2134 
2135  if (it->first == m_referenceCameraName) {
2136  this->cam = camera;
2137  }
2138  } else {
2139  std::stringstream ss;
2140  ss << "The camera: " << cameraName << " does not exist !";
2142  }
2143 }
2144 
2150 void vpMbEdgeMultiTracker::setCameraParameters(const std::map<std::string, vpCameraParameters> &mapOfCameraParameters)
2151 {
2152  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
2153  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2154  std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_edge->first);
2155  if (it_cam != mapOfCameraParameters.end()) {
2156  it_edge->second->setCameraParameters(it_cam->second);
2157 
2158  if (it_edge->first == m_referenceCameraName) {
2159  this->cam = it_cam->second;
2160  }
2161  } else {
2162  std::stringstream ss;
2163  ss << "Missing camera parameters for camera: " << it_edge->first << " !";
2165  }
2166  }
2167 }
2168 
2177 void vpMbEdgeMultiTracker::setCameraTransformationMatrix(const std::string &cameraName,
2178  const vpHomogeneousMatrix &cameraTransformationMatrix)
2179 {
2180  std::map<std::string, vpHomogeneousMatrix>::iterator it = m_mapOfCameraTransformationMatrix.find(cameraName);
2181  if (it != m_mapOfCameraTransformationMatrix.end()) {
2182  it->second = cameraTransformationMatrix;
2183  } else {
2184  std::stringstream ss;
2185  ss << "Cannot find camera: " << cameraName << " !";
2187  }
2188 }
2189 
2198  const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2199 {
2200  // Check if all cameras have a transformation matrix
2201  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
2202  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2203  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2204  mapOfTransformationMatrix.find(it_edge->first);
2205 
2206  if (it_camTrans == mapOfTransformationMatrix.end()) {
2207  throw vpException(vpTrackingException::initializationError, "Missing camera transformation matrix !");
2208  }
2209  }
2210 
2211  m_mapOfCameraTransformationMatrix = mapOfTransformationMatrix;
2212 }
2213 
2221 void vpMbEdgeMultiTracker::setClipping(const unsigned int &flags)
2222 {
2223  // Set clipping for vpMbEdgeMultiTracker class
2224  vpMbTracker::setClipping(flags);
2225 
2226  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2227  it != m_mapOfEdgeTrackers.end(); ++it) {
2228  it->second->setClipping(flags);
2229  }
2230 }
2231 
2240 void vpMbEdgeMultiTracker::setClipping(const std::string &cameraName, const unsigned int &flags)
2241 {
2242  // Set clipping for the given camera, do not change the clipping for
2243  // vpMbEdgeMultiTracker class
2244  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2245  if (it != m_mapOfEdgeTrackers.end()) {
2246  it->second->setClipping(flags);
2247  } else {
2248  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2249  }
2250 }
2251 
2258 {
2260 
2261  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2262  it != m_mapOfEdgeTrackers.end(); ++it) {
2263  it->second->setCovarianceComputation(flag);
2264  }
2265 }
2266 
2284 {
2285  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2286  it != m_mapOfEdgeTrackers.end(); ++it) {
2287  it->second->setDisplayFeatures(displayF);
2288  }
2289 
2290  displayFeatures = displayF;
2291 }
2292 
2299 {
2301 
2302  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2303  it != m_mapOfEdgeTrackers.end(); ++it) {
2304  it->second->setFarClippingDistance(dist);
2305  }
2306 }
2307 
2314 void vpMbEdgeMultiTracker::setFarClippingDistance(const std::string &cameraName, const double &dist)
2315 {
2316  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2317  if (it != m_mapOfEdgeTrackers.end()) {
2318  it->second->setFarClippingDistance(dist);
2319  } else {
2320  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2321  }
2322 }
2323 
2338 {
2339  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2340  it != m_mapOfEdgeTrackers.end(); ++it) {
2341  it->second->setGoodMovingEdgesRatioThreshold(threshold);
2342  }
2343 
2344  percentageGdPt = threshold;
2345 }
2346 
2347 #ifdef VISP_HAVE_OGRE
2348 
2358 {
2359  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2360  it != m_mapOfEdgeTrackers.end(); ++it) {
2361  it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2362  }
2363 }
2364 
2375 {
2376  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2377  it != m_mapOfEdgeTrackers.end(); ++it) {
2378  it->second->setNbRayCastingAttemptsForVisibility(attempts);
2379  }
2380 }
2381 #endif
2382 
2394 void vpMbEdgeMultiTracker::setLod(const bool useLod, const std::string &name)
2395 {
2396  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2397  it != m_mapOfEdgeTrackers.end(); ++it) {
2398  it->second->setLod(useLod, name);
2399  }
2400 }
2401 
2414 void vpMbEdgeMultiTracker::setLod(const bool useLod, const std::string &cameraName, const std::string &name)
2415 {
2416  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(cameraName);
2417 
2418  if (it_edge != m_mapOfEdgeTrackers.end()) {
2419  it_edge->second->setLod(useLod, name);
2420  } else {
2421  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
2422  }
2423 }
2424 
2434 void vpMbEdgeMultiTracker::setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name)
2435 {
2436  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2437  it != m_mapOfEdgeTrackers.end(); ++it) {
2438  it->second->setMinLineLengthThresh(minLineLengthThresh, name);
2439  }
2440 }
2441 
2453 void vpMbEdgeMultiTracker::setMinLineLengthThresh(const double minLineLengthThresh, const std::string &cameraName,
2454  const std::string &name)
2455 {
2456  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(cameraName);
2457 
2458  if (it_edge != m_mapOfEdgeTrackers.end()) {
2459  it_edge->second->setMinLineLengthThresh(minLineLengthThresh, name);
2460  } else {
2461  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
2462  }
2463 }
2464 
2473 void vpMbEdgeMultiTracker::setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name)
2474 {
2475  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2476  it != m_mapOfEdgeTrackers.end(); ++it) {
2477  it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2478  }
2479 }
2480 
2491 void vpMbEdgeMultiTracker::setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &cameraName,
2492  const std::string &name)
2493 {
2494  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(cameraName);
2495 
2496  if (it_edge != m_mapOfEdgeTrackers.end()) {
2497  it_edge->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2498  } else {
2499  std::cerr << "The camera: " << cameraName << " cannot be found !" << std::endl;
2500  }
2501 }
2502 
2509 {
2510  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2511  it != m_mapOfEdgeTrackers.end(); ++it) {
2512  it->second->setMovingEdge(me);
2513  }
2514 }
2515 
2522 void vpMbEdgeMultiTracker::setMovingEdge(const std::string &cameraName, const vpMe &me)
2523 {
2524  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2525  if (it != m_mapOfEdgeTrackers.end()) {
2526  it->second->setMovingEdge(me);
2527  } else {
2528  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2529  }
2530 }
2531 
2538 {
2540 
2541  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2542  it != m_mapOfEdgeTrackers.end(); ++it) {
2543  it->second->setNearClippingDistance(dist);
2544  }
2545 }
2546 
2553 void vpMbEdgeMultiTracker::setNearClippingDistance(const std::string &cameraName, const double &dist)
2554 {
2555  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(cameraName);
2556  if (it != m_mapOfEdgeTrackers.end()) {
2557  it->second->setNearClippingDistance(dist);
2558  } else {
2559  std::cerr << "Camera: " << cameraName << " does not exist !" << std::endl;
2560  }
2561 }
2562 
2573 void vpMbEdgeMultiTracker::setOgreShowConfigDialog(const bool showConfigDialog)
2574 {
2575  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2576  it != m_mapOfEdgeTrackers.end(); ++it) {
2577  it->second->setOgreShowConfigDialog(showConfigDialog);
2578  }
2579 }
2580 
2590 {
2591  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2592  it != m_mapOfEdgeTrackers.end(); ++it) {
2593  it->second->setOgreVisibilityTest(v);
2594  }
2595 
2596 #ifdef VISP_HAVE_OGRE
2597  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2598  it != m_mapOfEdgeTrackers.end(); ++it) {
2599  it->second->faces.getOgreContext()->setWindowName("Multi MBT Edge (" + it->first + ")");
2600  }
2601 #endif
2602 
2603  useOgre = v;
2604 }
2605 
2612 {
2613  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2614  it != m_mapOfEdgeTrackers.end(); ++it) {
2615  it->second->setOptimizationMethod(opt);
2616  }
2617 
2618  m_optimizationMethod = opt;
2619 }
2620 
2629 {
2630  if (m_mapOfEdgeTrackers.size() == 1) {
2631  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2632  if (it != m_mapOfEdgeTrackers.end()) {
2633  it->second->setPose(I, cMo_);
2634  this->cMo = cMo_;
2635  } else {
2636  std::stringstream ss;
2637  ss << "Cannot find the reference camera: " << m_referenceCameraName << " !";
2639  }
2640  } else {
2641  std::stringstream ss;
2642  ss << "You are trying to set the pose with only one image and cMo but "
2643  "there are multiple cameras !";
2645  }
2646 }
2647 
2660  const vpHomogeneousMatrix &c1Mo, const vpHomogeneousMatrix &c2Mo,
2661  const bool firstCameraIsReference)
2662 {
2663  if (m_mapOfEdgeTrackers.size() == 2) {
2664  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2665  it->second->setPose(I1, c1Mo);
2666 
2667  ++it;
2668 
2669  it->second->setPose(I2, c2Mo);
2670 
2671  if (firstCameraIsReference) {
2672  this->cMo = c1Mo;
2673  } else {
2674  this->cMo = c2Mo;
2675  }
2676  } else {
2677  std::stringstream ss;
2678  ss << "This method requires 2 cameras but there are " << m_mapOfEdgeTrackers.size() << " cameras !";
2680  }
2681 }
2682 
2691 void vpMbEdgeMultiTracker::setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
2692  const vpHomogeneousMatrix &cMo_)
2693 {
2694  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2695  if (it_edge != m_mapOfEdgeTrackers.end()) {
2696  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2697  mapOfImages.find(m_referenceCameraName);
2698 
2699  if (it_img != mapOfImages.end()) {
2700  // Set pose on reference camera
2701  it_edge->second->setPose(*it_img->second, cMo_);
2702 
2703  // Set the reference cMo
2704  cMo = cMo_;
2705 
2706  // Set the pose for the others cameras
2707  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2708  if (it_edge->first != m_referenceCameraName) {
2709  it_img = mapOfImages.find(it_edge->first);
2710  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2711  m_mapOfCameraTransformationMatrix.find(it_edge->first);
2712 
2713  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
2714  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
2715  it_edge->second->setPose(*it_img->second, cCurrentMo);
2716  } else {
2717  throw vpException(vpTrackingException::fatalError, "Missing image or camera transformation matrix !");
2718  }
2719  }
2720  }
2721  } else {
2722  std::stringstream ss;
2723  ss << "Missing image for camera: " << m_referenceCameraName << " !";
2725  }
2726  } else {
2727  std::stringstream ss;
2728  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
2730  }
2731 }
2732 
2743 void vpMbEdgeMultiTracker::setPose(const std::map<std::string, const vpImage<unsigned char> *> &mapOfImages,
2744  const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2745 {
2746  // Set the reference cMo
2747  std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2748  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2749  mapOfImages.find(m_referenceCameraName);
2750  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(m_referenceCameraName);
2751 
2752  if (it_edge != m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2753  it_edge->second->setPose(*it_img->second, it_camPose->second);
2754  it_edge->second->getPose(cMo);
2755  } else {
2756  throw vpException(vpTrackingException::fatalError, "Cannot set pose for the reference camera !");
2757  }
2758 
2759  // Vector of missing pose matrices for cameras
2760  std::vector<std::string> vectorOfMissingCameraPoses;
2761 
2762  // Set pose for the specified cameras
2763  for (it_edge = m_mapOfEdgeTrackers.begin(); it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2764  if (it_edge->first != m_referenceCameraName) {
2765  it_img = mapOfImages.find(it_edge->first);
2766  it_camPose = mapOfCameraPoses.find(it_edge->first);
2767 
2768  if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2769  // Set pose
2770  it_edge->second->setPose(*it_img->second, it_camPose->second);
2771  } else {
2772  vectorOfMissingCameraPoses.push_back(it_edge->first);
2773  }
2774  }
2775  }
2776 
2777  for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2778  it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2779  it_img = mapOfImages.find(*it1);
2780  std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2782 
2783  if (it_img != mapOfImages.end() && it_camTrans != m_mapOfCameraTransformationMatrix.end()) {
2784  vpHomogeneousMatrix cCurrentMo = it_camTrans->second * cMo;
2785  m_mapOfEdgeTrackers[*it1]->setPose(*it_img->second, cCurrentMo);
2786  } else {
2787  std::stringstream ss;
2788  ss << "Missing image or missing camera transformation matrix ! Cannot "
2789  "set the pose for camera: "
2790  << (*it1) << " !";
2792  }
2793  }
2794 }
2795 
2803 {
2804  // Set the flag in the current class
2806 
2807  // Set the flag for each camera
2808  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2809  it != m_mapOfEdgeTrackers.end(); ++it) {
2810  it->second->setProjectionErrorComputation(flag);
2811  }
2812 }
2813 
2819 void vpMbEdgeMultiTracker::setReferenceCameraName(const std::string &referenceCameraName)
2820 {
2821  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(referenceCameraName);
2822  if (it != m_mapOfEdgeTrackers.end()) {
2823  m_referenceCameraName = referenceCameraName;
2824  } else {
2825  std::stringstream ss;
2826  ss << "The reference camera: " << referenceCameraName << " does not exist !";
2828  }
2829 }
2830 
2852 void vpMbEdgeMultiTracker::setScales(const std::vector<bool> &scale)
2853 {
2855  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2856  it != m_mapOfEdgeTrackers.end(); ++it) {
2857  it->second->setScales(scale);
2858  }
2859 }
2860 
2867 {
2868  // Set general setScanLineVisibilityTest
2870 
2871  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2872  it != m_mapOfEdgeTrackers.end(); ++it) {
2873  it->second->setScanLineVisibilityTest(v);
2874  }
2875 }
2876 
2884 void vpMbEdgeMultiTracker::setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
2885 {
2886  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2887  it != m_mapOfEdgeTrackers.end(); ++it) {
2888  it->second->setUseEdgeTracking(name, useEdgeTracking);
2889  }
2890 }
2891 
2900 {
2901  // Track only with reference camera
2902  // Get the reference camera parameters
2903  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.find(m_referenceCameraName);
2904 
2905  if (it != m_mapOfEdgeTrackers.end()) {
2906  it->second->track(I);
2907  it->second->getPose(cMo);
2908  } else {
2909  std::stringstream ss;
2910  ss << "The reference camera: " << m_referenceCameraName << " does not exist !";
2912  }
2913 
2914  if (computeProjError) {
2915  // Use the projection error computed by the single vpMbEdgeTracker in
2916  // m_mapOfEdgeTrackers
2917  projectionError = it->second->getProjectionError();
2918  }
2919 }
2920 
2930 {
2931  // Track with the special case of stereo cameras
2932  if (m_mapOfEdgeTrackers.size() == 2) {
2933  std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
2934  std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2935  mapOfImages[it->first] = &I1;
2936  ++it;
2937 
2938  mapOfImages[it->first] = &I2;
2939  track(mapOfImages);
2940  } else {
2941  std::stringstream ss;
2942  ss << "Require two cameras ! There are " << m_mapOfEdgeTrackers.size() << " cameras !";
2944  }
2945 }
2946 
2954 void vpMbEdgeMultiTracker::track(std::map<std::string, const vpImage<unsigned char> *> &mapOfImages)
2955 {
2956  // Check if there is an image for each camera
2957  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge = m_mapOfEdgeTrackers.begin();
2958  it_edge != m_mapOfEdgeTrackers.end(); ++it_edge) {
2959  std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_edge->first);
2960 
2961  if (it_img == mapOfImages.end()) {
2962  throw vpException(vpTrackingException::fatalError, "Missing images !");
2963  }
2964  }
2965 
2966  initPyramid(mapOfImages, m_mapOfPyramidalImages);
2967 
2968  unsigned int lvl = (unsigned int)scales.size();
2969  do {
2970  lvl--;
2971 
2972  projectionError = 90.0;
2973 
2974  if (scales[lvl]) {
2975  vpHomogeneousMatrix cMo_1 = cMo;
2976  try {
2977  downScale(lvl);
2978  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it1 = m_mapOfEdgeTrackers.begin();
2979  it1 != m_mapOfEdgeTrackers.end(); ++it1) {
2980  // Downscale for each camera
2981  it1->second->downScale(lvl);
2982 
2983  // Track moving edges
2984  try {
2985  it1->second->trackMovingEdge(*m_mapOfPyramidalImages[it1->first][lvl]);
2986  } catch (...) {
2987  vpTRACE("Error in moving edge tracking");
2988  throw;
2989  }
2990  }
2991 
2992  try {
2993  std::map<std::string, const vpImage<unsigned char> *> mapOfPyramidImages;
2994  for (std::map<std::string, std::vector<const vpImage<unsigned char> *> >::const_iterator it =
2995  m_mapOfPyramidalImages.begin();
2996  it != m_mapOfPyramidalImages.end(); ++it) {
2997  mapOfPyramidImages[it->first] = it->second[lvl];
2998  }
2999 
3000  computeVVS(mapOfPyramidImages, lvl);
3001  } catch (...) {
3002  covarianceMatrix = -1;
3003  throw; // throw the original exception
3004  }
3005 
3006  // Test tracking failed only if all testTracking failed
3007  bool isOneTestTrackingOk = false;
3008  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3009  it != m_mapOfEdgeTrackers.end(); ++it) {
3010  // Set the camera pose
3011  it->second->cMo = m_mapOfCameraTransformationMatrix[it->first] * cMo;
3012 
3013  try {
3014  it->second->testTracking();
3015  isOneTestTrackingOk = true;
3016  } catch (/*vpException &e*/...) {
3017  // throw e;
3018  }
3019  }
3020 
3021  if (!isOneTestTrackingOk) {
3022  std::ostringstream oss;
3023  oss << "Not enough moving edges to track the object. Try to reduce "
3024  "the threshold="
3025  << percentageGdPt << " using setGoodMovingEdgesRatioThreshold()";
3027  }
3028 
3029  if (displayFeatures) {
3030  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3031  it != m_mapOfEdgeTrackers.end(); ++it) {
3032  it->second->displayFeaturesOnImage(*mapOfImages[it->first], lvl);
3033  }
3034  }
3035 
3036  // Looking for new visible face
3037  bool newvisibleface = false;
3038  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3039  it != m_mapOfEdgeTrackers.end(); ++it) {
3040  it->second->visibleFace(*mapOfImages[it->first], it->second->cMo, newvisibleface);
3041  }
3042 
3043  if (useScanLine) {
3044  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3045  it != m_mapOfEdgeTrackers.end(); ++it) {
3046  it->second->faces.computeClippedPolygons(it->second->cMo, it->second->cam);
3047  it->second->faces.computeScanLineRender(it->second->cam, mapOfImages[it->first]->getWidth(),
3048  mapOfImages[it->first]->getHeight());
3049  }
3050  }
3051 
3052  try {
3053  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3054  it != m_mapOfEdgeTrackers.end(); ++it) {
3055  it->second->updateMovingEdge(*mapOfImages[it->first]);
3056  }
3057  } catch (...) {
3058  throw; // throw the original exception
3059  }
3060 
3061  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3062  it != m_mapOfEdgeTrackers.end(); ++it) {
3063  it->second->initMovingEdge(*mapOfImages[it->first], it->second->cMo);
3064 
3065  // Reinit the moving edge for the lines which need it.
3066  it->second->reinitMovingEdge(*mapOfImages[it->first], it->second->cMo);
3067 
3068  if (computeProjError) {
3069  // Compute the projection error
3070  it->second->computeProjectionError(*mapOfImages[it->first]);
3071  }
3072  }
3073 
3075 
3076  upScale(lvl);
3077  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3078  it != m_mapOfEdgeTrackers.end(); ++it) {
3079  it->second->upScale(lvl);
3080  }
3081  } catch (vpException &e) {
3082  if (lvl != 0) {
3083  cMo = cMo_1;
3084  reInitLevel(lvl);
3085  upScale(lvl);
3086 
3087  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3088  it != m_mapOfEdgeTrackers.end(); ++it) {
3089  it->second->cMo = cMo_1;
3090  it->second->reInitLevel(lvl);
3091  it->second->upScale(lvl);
3092  }
3093  } else {
3094  upScale(lvl);
3095  for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it = m_mapOfEdgeTrackers.begin();
3096  it != m_mapOfEdgeTrackers.end(); ++it) {
3097  it->second->upScale(lvl);
3098  }
3099  throw(e);
3100  }
3101  }
3102  }
3103  } while (lvl != 0);
3104 
3106 }
virtual unsigned int getClipping() const
Definition: vpMbTracker.h:223
bool m_computeInteraction
Definition: vpMbTracker.h:187
bool computeProjError
Definition: vpMbTracker.h:135
std::string m_referenceCameraName
Name of the reference camera.
virtual void setCovarianceComputation(const bool &flag)
Definition: vpMbTracker.h:452
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Definition: vpMatrix.cpp:1931
vpMatrix covarianceMatrix
Covariance matrix.
Definition: vpMbTracker.h:132
virtual void loadModel(const std::string &modelFile, const bool verbose=false)
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*)
void upScale(const unsigned int _scale)
virtual void setAngleDisappear(const double &a)
Definition: vpMbTracker.h:433
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
Definition: vpMbTracker.h:145
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.
void getLline(std::list< vpMbtDistanceLine *> &linesList, const unsigned int level=0) const
vpMatrix AtA() const
Definition: vpMatrix.cpp:524
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
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:115
virtual void setProjectionErrorComputation(const bool &flag)
virtual void loadConfigFile(const std::string &configFile)
vpColVector m_w_edgeMulti
Robust weights.
bool modelInitialised
Definition: vpMbTracker.h:125
virtual void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_)
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 void setClipping(const unsigned int &flags)
unsigned int getRows() const
Definition: vpArray2D.h:156
Definition: vpMe.h:60
vpHomogeneousMatrix inverse() const
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:157
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:130
vpMe me
The moving edges parameters.
virtual void setReferenceCameraName(const std::string &referenceCameraName)
virtual std::map< std::string, unsigned int > getMultiNbPolygon() const
virtual void setNearClippingDistance(const double &dist)
void downScale(const unsigned int _scale)
vpCameraParameters cam
The camera parameters.
Definition: vpMbTracker.h:113
virtual void computeVVSWeights()
double projectionError
Definition: vpMbTracker.h:138
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &cam_, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual vpHomogeneousMatrix getPose() const
Definition: vpMbTracker.h:390
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
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.
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()
virtual vpMe getMovingEdge() const
virtual void setOgreVisibilityTest(const bool &v)
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
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.
Generic class defining intrinsic camera parameters.
virtual void setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
void getLcylinder(std::list< vpMbtDistanceCylinder *> &cylindersList, const unsigned int level=0) const
virtual void computeVVSInteractionMatrixAndResidu()
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
Definition: vpMbTracker.h:195
double m_lambda
Gain of the virtual visual servoing stage.
Definition: vpMbTracker.h:189
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
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 getLcircle(std::list< vpMbtDistanceCircle *> &circlesList, const unsigned int level=0) const
virtual void setAngleAppear(const double &a)
Definition: vpMbTracker.h:422
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
Definition: vpMbTracker.h:142
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:147
virtual void setCovarianceComputation(const bool &flag)
virtual unsigned int getNbPoints(const unsigned int level=0) const
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
Definition: vpMbTracker.h:191
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:140
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
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:149
virtual void computeVVSInit()
virtual unsigned int getNbPolygon() const
virtual void setScanLineVisibilityTest(const bool &v)
Definition: vpMbTracker.h:533
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:155
vpMatrix m_L_edge
Interaction matrix.
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > *> &_pyramid)
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 getCameraParameters(vpCameraParameters &camera) const
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, const unsigned int lvl)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
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:119
virtual std::vector< std::string > getCameraNames() const
virtual void setAngleAppear(const double &a)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:241
virtual void cleanPyramid(std::map< std::string, std::vector< const vpImage< unsigned char > *> > &pyramid)
virtual void setProjectionErrorComputation(const bool &flag)
Definition: vpMbTracker.h:531
virtual void setNearClippingDistance(const double &dist)