Visual Servoing Platform  version 3.6.1 under development (2024-02-13)
vpMbtXmlGenericParser.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 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  * Load XML Parameter for Model Based Tracker.
33  *
34 *****************************************************************************/
35 #include <visp3/core/vpConfig.h>
36 
37 #include <clocale>
38 #include <iostream>
39 #include <map>
40 
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
42 
43 #if defined(VISP_HAVE_PUGIXML)
44 #include <pugixml.hpp>
45 
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 
48 class vpMbtXmlGenericParser::Impl
49 {
50 public:
51  Impl(int type = EDGE_PARSER)
52  : m_parserType(type),
53  //<camera>
54  m_cam(),
55  //<face>
56  m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
57  m_farClipping(false), m_fovClipping(false),
58  //<lod>
59  m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
60  //<ecm>
61  m_ecm(),
62  //<klt>
63  m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
64  m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
65  //<depth_normal>
66  m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
67  m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
68  m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2),
69  m_depthNormalSamplingStepY(2),
70  //<depth_dense>
71  m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
72  //<projection_error>
73  m_projectionErrorMe(), m_projectionErrorKernelSize(2), // 5x5
74  m_nodeMap(), m_verbose(true)
75  {
76  // std::setlocale() is not thread safe and need to be called once
77  // https://stackoverflow.com/questions/41117179/undefined-behavior-with-setlocale-and-multithreading
78  if (m_call_setlocale) {
79  // https://pugixml.org/docs/manual.html#access.attrdata
80  // https://en.cppreference.com/w/cpp/locale/setlocale
81  // When called from Java binding, the locale seems to be changed to the default system locale
82  // It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
83  if (std::setlocale(LC_ALL, "C") == nullptr) {
84  std::cerr << "Cannot set locale to C" << std::endl;
85  }
86  m_call_setlocale = false;
87  }
88  init();
89  }
90 
91  void parse(const std::string &filename)
92  {
93  pugi::xml_document doc;
94  if (!doc.load_file(filename.c_str())) {
95  throw vpException(vpException::ioError, "Cannot open file: %s", filename.c_str());
96  }
97 
98  bool camera_node = false;
99  bool face_node = false;
100  bool ecm_node = false;
101  bool klt_node = false;
102  bool lod_node = false;
103  bool depth_normal_node = false;
104  bool depth_dense_node = false;
105  bool projection_error_node = false;
106 
107  pugi::xml_node root_node = doc.document_element();
108  for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
109  if (dataNode.type() == pugi::node_element) {
110  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
111  if (iter_data != m_nodeMap.end()) {
112  switch (iter_data->second) {
113  case camera:
114  if (m_parserType != PROJECTION_ERROR_PARSER) {
115  read_camera(dataNode);
116  camera_node = true;
117  }
118  break;
119 
120  case face:
121  if (m_parserType != PROJECTION_ERROR_PARSER) {
122  read_face(dataNode);
123  face_node = true;
124  }
125  break;
126 
127  case lod:
128  if (m_parserType != PROJECTION_ERROR_PARSER) {
129  read_lod(dataNode);
130  lod_node = true;
131  }
132  break;
133 
134  case ecm:
135  if (m_parserType & EDGE_PARSER) {
136  read_ecm(dataNode);
137  ecm_node = true;
138  }
139  break;
140 
141  case sample:
142  if (m_parserType & EDGE_PARSER)
143  read_sample_deprecated(dataNode);
144  break;
145 
146  case klt:
147  if (m_parserType & KLT_PARSER) {
148  read_klt(dataNode);
149  klt_node = true;
150  }
151  break;
152 
153  case depth_normal:
154  if (m_parserType & DEPTH_NORMAL_PARSER) {
155  read_depth_normal(dataNode);
156  depth_normal_node = true;
157  }
158  break;
159 
160  case depth_dense:
161  if (m_parserType & DEPTH_DENSE_PARSER) {
162  read_depth_dense(dataNode);
163  depth_dense_node = true;
164  }
165  break;
166 
167  case projection_error:
168  if (m_parserType == PROJECTION_ERROR_PARSER) {
169  read_projection_error(dataNode);
170  projection_error_node = true;
171  }
172  break;
173 
174  default:
175  break;
176  }
177  }
178  }
179  }
180 
181  if (m_verbose) {
182  if (m_parserType == PROJECTION_ERROR_PARSER) {
183  if (!projection_error_node) {
184  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
185  << std::endl;
186  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
187  << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
188  }
189  }
190  else {
191  if (!camera_node) {
192  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
193  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
194  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
195  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
196  }
197 
198  if (!face_node) {
199  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
200  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
201  }
202 
203  if (!lod_node) {
204  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
205  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
206  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
207  }
208 
209  if (!ecm_node && (m_parserType & EDGE_PARSER)) {
210  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
211  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
212  std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
213  std::cout << "me : contrast : threshold type : " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
214  std::cout << "me : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
215  std::cout << "me : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
216  std::cout << "me : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
217  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
218  }
219 
220  if (!klt_node && (m_parserType & KLT_PARSER)) {
221  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
222  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
223  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
224  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
225  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
226  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
227  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
228  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
229  }
230 
231  if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
232  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
233  << " (default)" << std::endl;
234  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
235  << " (default)" << std::endl;
236  std::cout << "depth normal : PCL_plane_estimation : max_iter : "
237  << m_depthNormalPclPlaneEstimationRansacMaxIter << " (default)" << std::endl;
238  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
239  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
240  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
241  << std::endl;
242  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
243  << std::endl;
244  }
245 
246  if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
247  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)"
248  << std::endl;
249  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)"
250  << std::endl;
251  }
252  }
253  }
254  }
255 
261  void read_camera(const pugi::xml_node &node)
262  {
263  bool u0_node = false;
264  bool v0_node = false;
265  bool px_node = false;
266  bool py_node = false;
267 
268  // current data values.
269  double d_u0 = m_cam.get_u0();
270  double d_v0 = m_cam.get_v0();
271  double d_px = m_cam.get_px();
272  double d_py = m_cam.get_py();
273 
274  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
275  if (dataNode.type() == pugi::node_element) {
276  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
277  if (iter_data != m_nodeMap.end()) {
278  switch (iter_data->second) {
279  case u0:
280  d_u0 = dataNode.text().as_double();
281  u0_node = true;
282  break;
283 
284  case v0:
285  d_v0 = dataNode.text().as_double();
286  v0_node = true;
287  break;
288 
289  case px:
290  d_px = dataNode.text().as_double();
291  px_node = true;
292  break;
293 
294  case py:
295  d_py = dataNode.text().as_double();
296  py_node = true;
297  break;
298 
299  default:
300  break;
301  }
302  }
303  }
304  }
305 
306  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
307 
308  if (m_verbose) {
309  if (!u0_node)
310  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
311  else
312  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
313 
314  if (!v0_node)
315  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
316  else
317  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
318 
319  if (!px_node)
320  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
321  else
322  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
323 
324  if (!py_node)
325  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
326  else
327  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
328  }
329  }
330 
336  void read_depth_normal(const pugi::xml_node &node)
337  {
338  bool feature_estimation_method_node = false;
339  bool PCL_plane_estimation_node = false;
340  bool sampling_step_node = false;
341 
342  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
343  if (dataNode.type() == pugi::node_element) {
344  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
345  if (iter_data != m_nodeMap.end()) {
346  switch (iter_data->second) {
347  case feature_estimation_method:
348  m_depthNormalFeatureEstimationMethod =
349  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
350  feature_estimation_method_node = true;
351  break;
352 
353  case PCL_plane_estimation:
354  read_depth_normal_PCL(dataNode);
355  PCL_plane_estimation_node = true;
356  break;
357 
358  case depth_sampling_step:
359  read_depth_normal_sampling_step(dataNode);
360  sampling_step_node = true;
361  break;
362 
363  default:
364  break;
365  }
366  }
367  }
368  }
369 
370  if (m_verbose) {
371  if (!feature_estimation_method_node)
372  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
373  << " (default)" << std::endl;
374  else
375  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
376 
377  if (!PCL_plane_estimation_node) {
378  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
379  << " (default)" << std::endl;
380  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
381  << " (default)" << std::endl;
382  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
383  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
384  }
385 
386  if (!sampling_step_node) {
387  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
388  << std::endl;
389  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
390  << std::endl;
391  }
392  }
393  }
394 
400  void read_depth_normal_PCL(const pugi::xml_node &node)
401  {
402  bool PCL_plane_estimation_method_node = false;
403  bool PCL_plane_estimation_ransac_max_iter_node = false;
404  bool PCL_plane_estimation_ransac_threshold_node = false;
405 
406  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
407  if (dataNode.type() == pugi::node_element) {
408  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
409  if (iter_data != m_nodeMap.end()) {
410  switch (iter_data->second) {
411  case PCL_plane_estimation_method:
412  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
413  PCL_plane_estimation_method_node = true;
414  break;
415 
416  case PCL_plane_estimation_ransac_max_iter:
417  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
418  PCL_plane_estimation_ransac_max_iter_node = true;
419  break;
420 
421  case PCL_plane_estimation_ransac_threshold:
422  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
423  PCL_plane_estimation_ransac_threshold_node = true;
424  break;
425 
426  default:
427  break;
428  }
429  }
430  }
431  }
432 
433  if (m_verbose) {
434  if (!PCL_plane_estimation_method_node)
435  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
436  << " (default)" << std::endl;
437  else
438  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
439  << std::endl;
440 
441  if (!PCL_plane_estimation_ransac_max_iter_node)
442  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
443  << " (default)" << std::endl;
444  else
445  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
446  << std::endl;
447 
448  if (!PCL_plane_estimation_ransac_threshold_node)
449  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
450  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
451  else
452  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
453  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
454  }
455  }
456 
462  void read_depth_normal_sampling_step(const pugi::xml_node &node)
463  {
464  bool sampling_step_X_node = false;
465  bool sampling_step_Y_node = false;
466 
467  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
468  if (dataNode.type() == pugi::node_element) {
469  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
470  if (iter_data != m_nodeMap.end()) {
471  switch (iter_data->second) {
472  case depth_sampling_step_X:
473  m_depthNormalSamplingStepX = dataNode.text().as_uint();
474  sampling_step_X_node = true;
475  break;
476 
477  case depth_sampling_step_Y:
478  m_depthNormalSamplingStepY = dataNode.text().as_uint();
479  sampling_step_Y_node = true;
480  break;
481 
482  default:
483  break;
484  }
485  }
486  }
487  }
488 
489  if (m_verbose) {
490  if (!sampling_step_X_node)
491  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)"
492  << std::endl;
493  else
494  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
495 
496  if (!sampling_step_Y_node)
497  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)"
498  << std::endl;
499  else
500  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
501  }
502  }
503 
509  void read_depth_dense(const pugi::xml_node &node)
510  {
511  bool sampling_step_node = false;
512 
513  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
514  if (dataNode.type() == pugi::node_element) {
515  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
516  if (iter_data != m_nodeMap.end()) {
517  switch (iter_data->second) {
518  case depth_dense_sampling_step:
519  read_depth_dense_sampling_step(dataNode);
520  sampling_step_node = true;
521  break;
522 
523  default:
524  break;
525  }
526  }
527  }
528  }
529 
530  if (!sampling_step_node && m_verbose) {
531  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
532  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
533  }
534  }
535 
541  void read_depth_dense_sampling_step(const pugi::xml_node &node)
542  {
543  bool sampling_step_X_node = false;
544  bool sampling_step_Y_node = false;
545 
546  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
547  if (dataNode.type() == pugi::node_element) {
548  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
549  if (iter_data != m_nodeMap.end()) {
550  switch (iter_data->second) {
551  case depth_dense_sampling_step_X:
552  m_depthDenseSamplingStepX = dataNode.text().as_uint();
553  sampling_step_X_node = true;
554  break;
555 
556  case depth_dense_sampling_step_Y:
557  m_depthDenseSamplingStepY = dataNode.text().as_uint();
558  sampling_step_Y_node = true;
559  break;
560 
561  default:
562  break;
563  }
564  }
565  }
566  }
567 
568  if (m_verbose) {
569  if (!sampling_step_X_node)
570  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)"
571  << std::endl;
572  else
573  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
574 
575  if (!sampling_step_Y_node)
576  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)"
577  << std::endl;
578  else
579  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
580  }
581  }
582 
588  void read_ecm(const pugi::xml_node &node)
589  {
590  bool mask_node = false;
591  bool range_node = false;
592  bool contrast_node = false;
593  bool sample_node = false;
594 
595  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
596  if (dataNode.type() == pugi::node_element) {
597  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
598  if (iter_data != m_nodeMap.end()) {
599  switch (iter_data->second) {
600  case mask:
601  read_ecm_mask(dataNode);
602  mask_node = true;
603  break;
604 
605  case range:
606  read_ecm_range(dataNode);
607  range_node = true;
608  break;
609 
610  case contrast:
611  read_ecm_contrast(dataNode);
612  contrast_node = true;
613  break;
614 
615  case sample:
616  read_ecm_sample(dataNode);
617  sample_node = true;
618  break;
619 
620  default:
621  break;
622  }
623  }
624  }
625  }
626 
627  if (m_verbose) {
628  if (!mask_node) {
629  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
630  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
631  }
632 
633  if (!range_node) {
634  std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
635  }
636 
637  if (!contrast_node) {
638  std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
639  std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
640  std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
641  std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
642  }
643 
644  if (!sample_node) {
645  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
646  }
647  }
648  }
649 
655  void read_ecm_contrast(const pugi::xml_node &node)
656  {
657  bool edge_threshold_type_node = false;
658  bool edge_threshold_node = false;
659  bool mu1_node = false;
660  bool mu2_node = false;
661 
662  // current data values.
663  vpMe::vpLikelihoodThresholdType d_edge_threshold_type = m_ecm.getLikelihoodThresholdType();
664  double d_edge_threshold = m_ecm.getThreshold();
665  double d_mu1 = m_ecm.getMu1();
666  double d_mu2 = m_ecm.getMu2();
667 
668  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
669  if (dataNode.type() == pugi::node_element) {
670  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
671  if (iter_data != m_nodeMap.end()) {
672  switch (iter_data->second) {
673  case edge_threshold_type:
674  d_edge_threshold_type = static_cast<vpMe::vpLikelihoodThresholdType>(dataNode.text().as_int());
675  edge_threshold_type_node = true;
676  break;
677 
678  case edge_threshold:
679  d_edge_threshold = dataNode.text().as_int();
680  edge_threshold_node = true;
681  break;
682 
683  case mu1:
684  d_mu1 = dataNode.text().as_double();
685  mu1_node = true;
686  break;
687 
688  case mu2:
689  d_mu2 = dataNode.text().as_double();
690  mu2_node = true;
691  break;
692 
693  default:
694  break;
695  }
696  }
697  }
698  }
699 
700  m_ecm.setMu1(d_mu1);
701  m_ecm.setMu2(d_mu2);
702  m_ecm.setLikelihoodThresholdType(d_edge_threshold_type);
703  m_ecm.setThreshold(d_edge_threshold);
704 
705  if (m_verbose) {
706  if (!edge_threshold_type_node)
707  std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
708  else
709  std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << std::endl;
710 
711  if (!edge_threshold_node)
712  std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
713  else
714  std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << std::endl;
715 
716  if (!mu1_node)
717  std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
718  else
719  std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << std::endl;
720 
721  if (!mu2_node)
722  std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
723  else
724  std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << std::endl;
725  }
726  }
727 
733  void read_ecm_mask(const pugi::xml_node &node)
734  {
735  bool size_node = false;
736  bool nb_mask_node = false;
737 
738  // current data values.
739  unsigned int d_size = m_ecm.getMaskSize();
740  unsigned int d_nb_mask = m_ecm.getMaskNumber();
741 
742  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
743  if (dataNode.type() == pugi::node_element) {
744  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
745  if (iter_data != m_nodeMap.end()) {
746  switch (iter_data->second) {
747  case size:
748  d_size = dataNode.text().as_uint();
749  size_node = true;
750  break;
751 
752  case nb_mask:
753  d_nb_mask = dataNode.text().as_uint();
754  nb_mask_node = true;
755  break;
756 
757  default:
758  break;
759  }
760  }
761  }
762  }
763 
764  m_ecm.setMaskSize(d_size);
765 
766  // Check to ensure that d_nb_mask > 0
767  if (d_nb_mask == 0)
768  throw(vpException(vpException::badValue, "Model-based tracker mask size "
769  "parameter should be different "
770  "from zero in xml file"));
771  m_ecm.setMaskNumber(d_nb_mask);
772 
773  if (m_verbose) {
774  if (!size_node)
775  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
776  else
777  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << std::endl;
778 
779  if (!nb_mask_node)
780  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
781  else
782  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
783  }
784  }
785 
791  void read_ecm_range(const pugi::xml_node &node)
792  {
793  bool tracking_node = false;
794 
795  // current data values.
796  unsigned int m_range_tracking = m_ecm.getRange();
797 
798  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
799  if (dataNode.type() == pugi::node_element) {
800  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
801  if (iter_data != m_nodeMap.end()) {
802  switch (iter_data->second) {
803  case tracking:
804  m_range_tracking = dataNode.text().as_uint();
805  tracking_node = true;
806  break;
807 
808  default:
809  break;
810  }
811  }
812  }
813  }
814 
815  m_ecm.setRange(m_range_tracking);
816 
817  if (m_verbose) {
818  if (!tracking_node)
819  std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
820  else
821  std::cout << "me : range : tracking : " << m_ecm.getRange() << std::endl;
822  }
823  }
824 
830  void read_ecm_sample(const pugi::xml_node &node)
831  {
832  bool step_node = false;
833 
834  // current data values.
835  double d_stp = m_ecm.getSampleStep();
836 
837  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
838  if (dataNode.type() == pugi::node_element) {
839  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
840  if (iter_data != m_nodeMap.end()) {
841  switch (iter_data->second) {
842  case step:
843  d_stp = dataNode.text().as_int();
844  step_node = true;
845  break;
846 
847  default:
848  break;
849  }
850  }
851  }
852  }
853 
854  m_ecm.setSampleStep(d_stp);
855 
856  if (m_verbose) {
857  if (!step_node)
858  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
859  else
860  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
861  }
862  }
863 
869  void read_face(const pugi::xml_node &node)
870  {
871  bool angle_appear_node = false;
872  bool angle_disappear_node = false;
873  bool near_clipping_node = false;
874  bool far_clipping_node = false;
875  bool fov_clipping_node = false;
876  m_hasNearClipping = false;
877  m_hasFarClipping = false;
878 
879  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
880  if (dataNode.type() == pugi::node_element) {
881  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
882  if (iter_data != m_nodeMap.end()) {
883  switch (iter_data->second) {
884  case angle_appear:
885  m_angleAppear = dataNode.text().as_double();
886  angle_appear_node = true;
887  break;
888 
889  case angle_disappear:
890  m_angleDisappear = dataNode.text().as_double();
891  angle_disappear_node = true;
892  break;
893 
894  case near_clipping:
895  m_nearClipping = dataNode.text().as_double();
896  m_hasNearClipping = true;
897  near_clipping_node = true;
898  break;
899 
900  case far_clipping:
901  m_farClipping = dataNode.text().as_double();
902  m_hasFarClipping = true;
903  far_clipping_node = true;
904  break;
905 
906  case fov_clipping:
907  if (dataNode.text().as_int())
908  m_fovClipping = true;
909  else
910  m_fovClipping = false;
911  fov_clipping_node = true;
912  break;
913 
914  default:
915  break;
916  }
917  }
918  }
919  }
920 
921  if (m_verbose) {
922  if (!angle_appear_node)
923  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
924  else
925  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
926 
927  if (!angle_disappear_node)
928  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
929  else
930  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
931 
932  if (near_clipping_node)
933  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
934 
935  if (far_clipping_node)
936  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
937 
938  if (fov_clipping_node) {
939  if (m_fovClipping)
940  std::cout << "face : Fov Clipping : True" << std::endl;
941  else
942  std::cout << "face : Fov Clipping : False" << std::endl;
943  }
944  }
945  }
946 
952  void read_klt(const pugi::xml_node &node)
953  {
954  bool mask_border_node = false;
955  bool max_features_node = false;
956  bool window_size_node = false;
957  bool quality_node = false;
958  bool min_distance_node = false;
959  bool harris_node = false;
960  bool size_block_node = false;
961  bool pyramid_lvl_node = false;
962 
963  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
964  if (dataNode.type() == pugi::node_element) {
965  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
966  if (iter_data != m_nodeMap.end()) {
967  switch (iter_data->second) {
968  case mask_border:
969  m_kltMaskBorder = dataNode.text().as_uint();
970  mask_border_node = true;
971  break;
972 
973  case max_features:
974  m_kltMaxFeatures = dataNode.text().as_uint();
975  max_features_node = true;
976  break;
977 
978  case window_size:
979  m_kltWinSize = dataNode.text().as_uint();
980  window_size_node = true;
981  break;
982 
983  case quality:
984  m_kltQualityValue = dataNode.text().as_double();
985  quality_node = true;
986  break;
987 
988  case min_distance:
989  m_kltMinDist = dataNode.text().as_double();
990  min_distance_node = true;
991  break;
992 
993  case harris:
994  m_kltHarrisParam = dataNode.text().as_double();
995  harris_node = true;
996  break;
997 
998  case size_block:
999  m_kltBlockSize = dataNode.text().as_uint();
1000  size_block_node = true;
1001  break;
1002 
1003  case pyramid_lvl:
1004  m_kltPyramidLevels = dataNode.text().as_uint();
1005  pyramid_lvl_node = true;
1006  break;
1007 
1008  default:
1009  break;
1010  }
1011  }
1012  }
1013  }
1014 
1015  if (m_verbose) {
1016  if (!mask_border_node)
1017  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
1018  else
1019  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
1020 
1021  if (!max_features_node)
1022  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
1023  else
1024  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
1025 
1026  if (!window_size_node)
1027  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
1028  else
1029  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
1030 
1031  if (!quality_node)
1032  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
1033  else
1034  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
1035 
1036  if (!min_distance_node)
1037  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
1038  else
1039  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
1040 
1041  if (!harris_node)
1042  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
1043  else
1044  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1045 
1046  if (!size_block_node)
1047  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
1048  else
1049  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
1050 
1051  if (!pyramid_lvl_node)
1052  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
1053  else
1054  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1055  }
1056  }
1057 
1058  void read_lod(const pugi::xml_node &node)
1059  {
1060  bool use_lod_node = false;
1061  bool min_line_length_threshold_node = false;
1062  bool min_polygon_area_threshold_node = false;
1063 
1064  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1065  if (dataNode.type() == pugi::node_element) {
1066  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1067  if (iter_data != m_nodeMap.end()) {
1068  switch (iter_data->second) {
1069  case use_lod:
1070  m_useLod = (dataNode.text().as_int() != 0);
1071  use_lod_node = true;
1072  break;
1073 
1074  case min_line_length_threshold:
1075  m_minLineLengthThreshold = dataNode.text().as_double();
1076  min_line_length_threshold_node = true;
1077  break;
1078 
1079  case min_polygon_area_threshold:
1080  m_minPolygonAreaThreshold = dataNode.text().as_double();
1081  min_polygon_area_threshold_node = true;
1082  break;
1083 
1084  default:
1085  break;
1086  }
1087  }
1088  }
1089  }
1090 
1091  if (m_verbose) {
1092  if (!use_lod_node)
1093  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1094  else
1095  std::cout << "lod : use lod : " << m_useLod << std::endl;
1096 
1097  if (!min_line_length_threshold_node)
1098  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1099  else
1100  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1101 
1102  if (!min_polygon_area_threshold_node)
1103  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1104  else
1105  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1106  }
1107  }
1108 
1109  void read_projection_error(const pugi::xml_node &node)
1110  {
1111  bool step_node = false;
1112  bool kernel_size_node = false;
1113 
1114  // current data values.
1115  double d_stp = m_projectionErrorMe.getSampleStep();
1116  std::string kernel_size_str;
1117 
1118  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1119  if (dataNode.type() == pugi::node_element) {
1120  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1121  if (iter_data != m_nodeMap.end()) {
1122  switch (iter_data->second) {
1123  case projection_error_sample_step:
1124  d_stp = dataNode.text().as_int();
1125  step_node = true;
1126  break;
1127 
1128  case projection_error_kernel_size:
1129  kernel_size_str = dataNode.text().as_string();
1130  kernel_size_node = true;
1131  break;
1132 
1133  default:
1134  break;
1135  }
1136  }
1137  }
1138  }
1139 
1140  m_projectionErrorMe.setSampleStep(d_stp);
1141 
1142  if (kernel_size_str == "3x3") {
1143  m_projectionErrorKernelSize = 1;
1144  }
1145  else if (kernel_size_str == "5x5") {
1146  m_projectionErrorKernelSize = 2;
1147  }
1148  else if (kernel_size_str == "7x7") {
1149  m_projectionErrorKernelSize = 3;
1150  }
1151  else if (kernel_size_str == "9x9") {
1152  m_projectionErrorKernelSize = 4;
1153  }
1154  else if (kernel_size_str == "11x11") {
1155  m_projectionErrorKernelSize = 5;
1156  }
1157  else if (kernel_size_str == "13x13") {
1158  m_projectionErrorKernelSize = 6;
1159  }
1160  else if (kernel_size_str == "15x15") {
1161  m_projectionErrorKernelSize = 7;
1162  }
1163  else {
1164  std::cerr << "Unsupported kernel size." << std::endl;
1165  }
1166 
1167  if (m_verbose) {
1168  if (!step_node)
1169  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
1170  << std::endl;
1171  else
1172  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1173 
1174  if (!kernel_size_node)
1175  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
1176  << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
1177  else
1178  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1179  }
1180  }
1181 
1187  void read_sample_deprecated(const pugi::xml_node &node)
1188  {
1189  bool step_node = false;
1190  // bool nb_sample_node = false;
1191 
1192  // current data values.
1193  double d_stp = m_ecm.getSampleStep();
1194 
1195  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1196  if (dataNode.type() == pugi::node_element) {
1197  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1198  if (iter_data != m_nodeMap.end()) {
1199  switch (iter_data->second) {
1200  case step:
1201  d_stp = dataNode.text().as_int();
1202  step_node = true;
1203  break;
1204 
1205  default:
1206  break;
1207  }
1208  }
1209  }
1210  }
1211 
1212  m_ecm.setSampleStep(d_stp);
1213 
1214  if (m_verbose) {
1215  if (!step_node)
1216  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1217  else
1218  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1219 
1220  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1221  std::cout << " It should be moved in the ecm node (me : sample)." << std::endl;
1222  }
1223  }
1224 
1225  double getAngleAppear() const { return m_angleAppear; }
1226  double getAngleDisappear() const { return m_angleDisappear; }
1227 
1228  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1229 
1230  void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1231 
1232  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1233  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1234 
1236  {
1237  return m_depthNormalFeatureEstimationMethod;
1238  }
1239  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1240  int getDepthNormalPclPlaneEstimationRansacMaxIter() const { return m_depthNormalPclPlaneEstimationRansacMaxIter; }
1242  {
1243  return m_depthNormalPclPlaneEstimationRansacThreshold;
1244  }
1245  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1246  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1247 
1248  double getFarClippingDistance() const { return m_farClipping; }
1249  bool getFovClipping() const { return m_fovClipping; }
1250 
1251  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1252  double getKltHarrisParam() const { return m_kltHarrisParam; }
1253  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1254  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1255  double getKltMinDistance() const { return m_kltMinDist; }
1256  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1257  double getKltQuality() const { return m_kltQualityValue; }
1258  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1259 
1260  bool getLodState() const { return m_useLod; }
1261  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1262  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1263 
1264  double getNearClippingDistance() const { return m_nearClipping; }
1265 
1266  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1267  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1268 
1269  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1270  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1271 
1272  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1273  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1274 
1275  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1276 
1277  void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1278  void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1280  {
1281  m_depthNormalFeatureEstimationMethod = method;
1282  }
1283  void setDepthNormalPclPlaneEstimationMethod(int method) { m_depthNormalPclPlaneEstimationMethod = method; }
1285  {
1286  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1287  }
1289  {
1290  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1291  }
1292  void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1293  void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1294 
1295  void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1296 
1297  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1298 
1299  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1300  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1301  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1302  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1303  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1304  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1305  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1306  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1307 
1308  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1309 
1310  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1311  void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1312 
1313  void setVerbose(bool verbose) { m_verbose = verbose; }
1314 
1315 protected:
1317  int m_parserType;
1319  vpCameraParameters m_cam;
1321  double m_angleAppear;
1323  double m_angleDisappear;
1325  bool m_hasNearClipping;
1327  double m_nearClipping;
1329  bool m_hasFarClipping;
1331  double m_farClipping;
1333  bool m_fovClipping;
1334  // LOD
1336  bool m_useLod;
1338  double m_minLineLengthThreshold;
1340  double m_minPolygonAreaThreshold;
1341  // Edge
1343  vpMe m_ecm;
1344  // KLT
1346  unsigned int m_kltMaskBorder;
1348  unsigned int m_kltMaxFeatures;
1350  unsigned int m_kltWinSize;
1352  double m_kltQualityValue;
1354  double m_kltMinDist;
1356  double m_kltHarrisParam;
1358  unsigned int m_kltBlockSize;
1360  unsigned int m_kltPyramidLevels;
1361  // Depth normal
1363  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1365  int m_depthNormalPclPlaneEstimationMethod;
1367  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1369  double m_depthNormalPclPlaneEstimationRansacThreshold;
1371  unsigned int m_depthNormalSamplingStepX;
1373  unsigned int m_depthNormalSamplingStepY;
1374  // Depth dense
1376  unsigned int m_depthDenseSamplingStepX;
1378  unsigned int m_depthDenseSamplingStepY;
1379  // Projection error
1381  vpMe m_projectionErrorMe;
1383  unsigned int m_projectionErrorKernelSize;
1384  std::map<std::string, int> m_nodeMap;
1386  bool m_verbose;
1387 
1388  enum vpDataToParseMb
1389  {
1390  //<conf>
1391  conf,
1392  //<face>
1393  face,
1394  angle_appear,
1395  angle_disappear,
1396  near_clipping,
1397  far_clipping,
1398  fov_clipping,
1399  //<camera>
1400  camera,
1401  height,
1402  width,
1403  u0,
1404  v0,
1405  px,
1406  py,
1407  lod,
1408  use_lod,
1409  min_line_length_threshold,
1410  min_polygon_area_threshold,
1411  //<ecm>
1412  ecm,
1413  mask,
1414  size,
1415  nb_mask,
1416  range,
1417  tracking,
1418  contrast,
1419  edge_threshold,
1420  edge_threshold_type,
1421  mu1,
1422  mu2,
1423  sample,
1424  step,
1425  //<klt>
1426  klt,
1427  mask_border,
1428  max_features,
1429  window_size,
1430  quality,
1431  min_distance,
1432  harris,
1433  size_block,
1434  pyramid_lvl,
1435  //<depth_normal>
1436  depth_normal,
1437  feature_estimation_method,
1438  PCL_plane_estimation,
1439  PCL_plane_estimation_method,
1440  PCL_plane_estimation_ransac_max_iter,
1441  PCL_plane_estimation_ransac_threshold,
1442  depth_sampling_step,
1443  depth_sampling_step_X,
1444  depth_sampling_step_Y,
1445  //<depth_dense>
1446  depth_dense,
1447  depth_dense_sampling_step,
1448  depth_dense_sampling_step_X,
1449  depth_dense_sampling_step_Y,
1450  //<projection_error>
1451  projection_error,
1452  projection_error_sample_step,
1453  projection_error_kernel_size
1454  };
1455 
1459  void init()
1460  {
1461  //<conf>
1462  m_nodeMap["conf"] = conf;
1463  //<face>
1464  m_nodeMap["face"] = face;
1465  m_nodeMap["angle_appear"] = angle_appear;
1466  m_nodeMap["angle_disappear"] = angle_disappear;
1467  m_nodeMap["near_clipping"] = near_clipping;
1468  m_nodeMap["far_clipping"] = far_clipping;
1469  m_nodeMap["fov_clipping"] = fov_clipping;
1470  //<camera>
1471  m_nodeMap["camera"] = camera;
1472  m_nodeMap["height"] = height;
1473  m_nodeMap["width"] = width;
1474  m_nodeMap["u0"] = u0;
1475  m_nodeMap["v0"] = v0;
1476  m_nodeMap["px"] = px;
1477  m_nodeMap["py"] = py;
1478  //<lod>
1479  m_nodeMap["lod"] = lod;
1480  m_nodeMap["use_lod"] = use_lod;
1481  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1482  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1483  //<ecm>
1484  m_nodeMap["ecm"] = ecm;
1485  m_nodeMap["mask"] = mask;
1486  m_nodeMap["size"] = size;
1487  m_nodeMap["nb_mask"] = nb_mask;
1488  m_nodeMap["range"] = range;
1489  m_nodeMap["tracking"] = tracking;
1490  m_nodeMap["contrast"] = contrast;
1491  m_nodeMap["edge_threshold_type"] = edge_threshold_type;
1492  m_nodeMap["edge_threshold"] = edge_threshold;
1493  m_nodeMap["mu1"] = mu1;
1494  m_nodeMap["mu2"] = mu2;
1495  m_nodeMap["sample"] = sample;
1496  m_nodeMap["step"] = step;
1497  //<klt>
1498  m_nodeMap["klt"] = klt;
1499  m_nodeMap["mask_border"] = mask_border;
1500  m_nodeMap["max_features"] = max_features;
1501  m_nodeMap["window_size"] = window_size;
1502  m_nodeMap["quality"] = quality;
1503  m_nodeMap["min_distance"] = min_distance;
1504  m_nodeMap["harris"] = harris;
1505  m_nodeMap["size_block"] = size_block;
1506  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1507  //<depth_normal>
1508  m_nodeMap["depth_normal"] = depth_normal;
1509  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1510  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1511  m_nodeMap["method"] = PCL_plane_estimation_method;
1512  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1513  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1514  m_nodeMap["sampling_step"] = depth_sampling_step;
1515  m_nodeMap["step_X"] = depth_sampling_step_X;
1516  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1517  //<depth_dense>
1518  m_nodeMap["depth_dense"] = depth_dense;
1519  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1520  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1521  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1522  //<projection_error>
1523  m_nodeMap["projection_error"] = projection_error;
1524  m_nodeMap["sample_step"] = projection_error_sample_step;
1525  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1526  }
1527 
1528 private:
1529  static bool m_call_setlocale;
1530 };
1531 
1532 bool vpMbtXmlGenericParser::Impl::m_call_setlocale = true;
1533 
1534 #endif // DOXYGEN_SHOULD_SKIP_THIS
1535 
1536 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1537 { }
1538 
1540 
1546 void vpMbtXmlGenericParser::parse(const std::string &filename) { m_impl->parse(filename); }
1547 
1551 double vpMbtXmlGenericParser::getAngleAppear() const { return m_impl->getAngleAppear(); }
1552 
1556 double vpMbtXmlGenericParser::getAngleDisappear() const { return m_impl->getAngleDisappear(); }
1557 
1558 void vpMbtXmlGenericParser::getCameraParameters(vpCameraParameters &cam) const { m_impl->getCameraParameters(cam); }
1559 
1563 void vpMbtXmlGenericParser::getEdgeMe(vpMe &ecm) const { m_impl->getEdgeMe(ecm); }
1564 
1568 unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepX() const { return m_impl->getDepthDenseSamplingStepX(); }
1569 
1573 unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepY() const { return m_impl->getDepthDenseSamplingStepY(); }
1574 
1579 {
1580  return m_impl->getDepthNormalFeatureEstimationMethod();
1581 }
1582 
1587 {
1588  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1589 }
1590 
1595 {
1596  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1597 }
1598 
1603 {
1604  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1605 }
1606 
1611 {
1612  return m_impl->getDepthNormalSamplingStepX();
1613 }
1614 
1619 {
1620  return m_impl->getDepthNormalSamplingStepY();
1621 }
1622 
1626 double vpMbtXmlGenericParser::getFarClippingDistance() const { return m_impl->getFarClippingDistance(); }
1627 
1631 bool vpMbtXmlGenericParser::getFovClipping() const { return m_impl->getFovClipping(); }
1632 
1636 unsigned int vpMbtXmlGenericParser::getKltBlockSize() const { return m_impl->getKltBlockSize(); }
1637 
1641 double vpMbtXmlGenericParser::getKltHarrisParam() const { return m_impl->getKltHarrisParam(); }
1642 
1646 unsigned int vpMbtXmlGenericParser::getKltMaskBorder() const { return m_impl->getKltMaskBorder(); }
1647 
1651 unsigned int vpMbtXmlGenericParser::getKltMaxFeatures() const { return m_impl->getKltMaxFeatures(); }
1652 
1656 double vpMbtXmlGenericParser::getKltMinDistance() const { return m_impl->getKltMinDistance(); }
1657 
1661 unsigned int vpMbtXmlGenericParser::getKltPyramidLevels() const { return m_impl->getKltPyramidLevels(); }
1662 
1666 double vpMbtXmlGenericParser::getKltQuality() const { return m_impl->getKltQuality(); }
1667 
1671 unsigned int vpMbtXmlGenericParser::getKltWindowSize() const { return m_impl->getKltWindowSize(); }
1672 
1676 bool vpMbtXmlGenericParser::getLodState() const { return m_impl->getLodState(); }
1677 
1681 double vpMbtXmlGenericParser::getLodMinLineLengthThreshold() const { return m_impl->getLodMinLineLengthThreshold(); }
1682 
1686 double vpMbtXmlGenericParser::getLodMinPolygonAreaThreshold() const { return m_impl->getLodMinPolygonAreaThreshold(); }
1687 
1691 double vpMbtXmlGenericParser::getNearClippingDistance() const { return m_impl->getNearClippingDistance(); }
1692 
1696 void vpMbtXmlGenericParser::getProjectionErrorMe(vpMe &me) const { m_impl->getProjectionErrorMe(me); }
1697 
1699 {
1700  return m_impl->getProjectionErrorKernelSize();
1701 }
1702 
1708 bool vpMbtXmlGenericParser::hasFarClippingDistance() const { return m_impl->hasFarClippingDistance(); }
1709 
1715 bool vpMbtXmlGenericParser::hasNearClippingDistance() const { return m_impl->hasNearClippingDistance(); }
1716 
1722 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear) { m_impl->setAngleAppear(aappear); }
1723 
1729 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear) { m_impl->setAngleDisappear(adisappear); }
1730 
1736 void vpMbtXmlGenericParser::setCameraParameters(const vpCameraParameters &cam) { m_impl->setCameraParameters(cam); }
1737 
1744 {
1745  m_impl->setDepthDenseSamplingStepX(stepX);
1746 }
1747 
1754 {
1755  m_impl->setDepthDenseSamplingStepY(stepY);
1756 }
1757 
1765 {
1766  m_impl->setDepthNormalFeatureEstimationMethod(method);
1767 }
1768 
1775 {
1776  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1777 }
1778 
1785 {
1786  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1787 }
1788 
1795 {
1796  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1797 }
1798 
1805 {
1806  m_impl->setDepthNormalSamplingStepX(stepX);
1807 }
1808 
1815 {
1816  m_impl->setDepthNormalSamplingStepY(stepY);
1817 }
1818 
1824 void vpMbtXmlGenericParser::setEdgeMe(const vpMe &moving_edge) { m_impl->setEdgeMe(moving_edge); }
1825 
1831 void vpMbtXmlGenericParser::setFarClippingDistance(const double &fclip) { m_impl->setFarClippingDistance(fclip); }
1832 
1838 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs) { m_impl->setKltBlockSize(bs); }
1839 
1845 void vpMbtXmlGenericParser::setKltHarrisParam(const double &hp) { m_impl->setKltHarrisParam(hp); }
1846 
1852 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb) { m_impl->setKltMaskBorder(mb); }
1853 
1859 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF) { m_impl->setKltMaxFeatures(mF); }
1860 
1866 void vpMbtXmlGenericParser::setKltMinDistance(const double &mD) { m_impl->setKltMinDistance(mD); }
1867 
1873 void vpMbtXmlGenericParser::setKltPyramidLevels(const unsigned int &pL) { m_impl->setKltPyramidLevels(pL); }
1874 
1880 void vpMbtXmlGenericParser::setKltQuality(const double &q) { m_impl->setKltQuality(q); }
1881 
1887 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w) { m_impl->setKltWindowSize(w); }
1888 
1894 void vpMbtXmlGenericParser::setNearClippingDistance(const double &nclip) { m_impl->setNearClippingDistance(nclip); }
1895 
1901 void vpMbtXmlGenericParser::setProjectionErrorMe(const vpMe &me) { m_impl->setProjectionErrorMe(me); }
1902 
1909 {
1910  m_impl->setProjectionErrorKernelSize(size);
1911 }
1912 
1918 void vpMbtXmlGenericParser::setVerbose(bool verbose) { m_impl->setVerbose(verbose); }
1919 
1920 #elif !defined(VISP_BUILD_SHARED_LIBS)
1921 // Work around to avoid warning: libvisp_core.a(vpMbtXmlGenericParser.cpp.o) has no symbols
1922 void dummy_vpMbtXmlGenericParser() { };
1923 
1924 #endif
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
Definition: vpException.h:59
@ ioError
I/O error.
Definition: vpException.h:79
@ badValue
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:85
void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter)
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
unsigned int getKltMaxFeatures() const
void setProjectionErrorMe(const vpMe &me)
unsigned int getDepthNormalSamplingStepX() const
unsigned int getProjectionErrorKernelSize() const
void setKltMinDistance(const double &mD)
unsigned int getKltBlockSize() const
void getCameraParameters(vpCameraParameters &cam) const
void setDepthDenseSamplingStepY(unsigned int stepY)
void setEdgeMe(const vpMe &ecm)
unsigned int getDepthNormalSamplingStepY() const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
void setKltMaskBorder(const unsigned int &mb)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
void getEdgeMe(vpMe &ecm) const
double getLodMinLineLengthThreshold() const
void setDepthNormalPclPlaneEstimationMethod(int method)
void setDepthNormalSamplingStepX(unsigned int stepX)
unsigned int getKltMaskBorder() const
void setAngleDisappear(const double &adisappear)
void setDepthDenseSamplingStepX(unsigned int stepX)
void setProjectionErrorKernelSize(const unsigned int &size)
void setKltPyramidLevels(const unsigned int &pL)
void setKltWindowSize(const unsigned int &w)
void setKltMaxFeatures(const unsigned int &mF)
int getDepthNormalPclPlaneEstimationMethod() const
void setAngleAppear(const double &aappear)
void setKltBlockSize(const unsigned int &bs)
void setKltHarrisParam(const double &hp)
vpMbtXmlGenericParser(int type=EDGE_PARSER)
unsigned int getDepthDenseSamplingStepY() const
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void parse(const std::string &filename)
void setNearClippingDistance(const double &nclip)
void setKltQuality(const double &q)
void getProjectionErrorMe(vpMe &me) const
unsigned int getKltPyramidLevels() const
void setFarClippingDistance(const double &fclip)
unsigned int getKltWindowSize() const
void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
unsigned int getDepthDenseSamplingStepX() const
void setCameraParameters(const vpCameraParameters &cam)
double getLodMinPolygonAreaThreshold() const
void setDepthNormalSamplingStepY(unsigned int stepY)
Definition: vpMe.h:124
vpLikelihoodThresholdType
Definition: vpMe.h:130
void init(vpImage< unsigned char > &Iinput, vpImage< unsigned char > &IcannyVisp, vpImage< unsigned char > *p_dIx, vpImage< unsigned char > *p_dIy, vpImage< unsigned char > *p_IcannyimgFilter)
Initialize the different displays.