Visual Servoing Platform  version 3.4.0
vpMbtXmlGenericParser.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Load XML Parameter for Model Based Tracker.
33  *
34  *****************************************************************************/
35 #include <visp3/core/vpConfig.h>
36 
37 #include <iostream>
38 #include <map>
39 #include <clocale>
40 
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
42 
43 #include <pugixml.hpp>
44 
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 class vpMbtXmlGenericParser::Impl
47 {
48 public:
49  Impl(int type = EDGE_PARSER) :
50  m_parserType(type),
51  //<camera>
52  m_cam(),
53  //<face>
54  m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
55  m_farClipping(false), m_fovClipping(false),
56  //<lod>
57  m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
58  //<ecm>
59  m_ecm(),
60  //<klt>
61  m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
62  m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
63  //<depth_normal>
64  m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
65  m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
66  m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2), m_depthNormalSamplingStepY(2),
67  //<depth_dense>
68  m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
69  //<projection_error>
70  m_projectionErrorMe(), m_projectionErrorKernelSize(2), //5x5
71  m_nodeMap(),
72  m_verbose(true)
73  {
74  init();
75  }
76 
77  void parse(const std::string &filename)
78  {
79  pugi::xml_document doc;
80  if (!doc.load_file(filename.c_str())) {
81  throw vpException(vpException::ioError, "Cannot open file: %s", filename.c_str());
82  }
83 
84  bool camera_node = false;
85  bool face_node = false;
86  bool ecm_node = false;
87  bool klt_node = false;
88  bool lod_node = false;
89  bool depth_normal_node = false;
90  bool depth_dense_node = false;
91  bool projection_error_node = false;
92 
93  pugi::xml_node root_node = doc.document_element();
94  for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
95  if (dataNode.type() == pugi::node_element) {
96  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
97  if (iter_data != m_nodeMap.end()) {
98  switch (iter_data->second) {
99  case camera:
100  if (m_parserType != PROJECTION_ERROR_PARSER) {
101  read_camera(dataNode);
102  camera_node = true;
103  }
104  break;
105 
106  case face:
107  if (m_parserType != PROJECTION_ERROR_PARSER) {
108  read_face(dataNode);
109  face_node = true;
110  }
111  break;
112 
113  case lod:
114  if (m_parserType != PROJECTION_ERROR_PARSER) {
115  read_lod(dataNode);
116  lod_node = true;
117  }
118  break;
119 
120  case ecm:
121  if (m_parserType & EDGE_PARSER) {
122  read_ecm(dataNode);
123  ecm_node = true;
124  }
125  break;
126 
127  case sample:
128  if (m_parserType & EDGE_PARSER)
129  read_sample_deprecated(dataNode);
130  break;
131 
132  case klt:
133  if (m_parserType & KLT_PARSER) {
134  read_klt(dataNode);
135  klt_node = true;
136  }
137  break;
138 
139  case depth_normal:
140  if (m_parserType & DEPTH_NORMAL_PARSER) {
141  read_depth_normal(dataNode);
142  depth_normal_node = true;
143  }
144  break;
145 
146  case depth_dense:
147  if (m_parserType & DEPTH_DENSE_PARSER) {
148  read_depth_dense(dataNode);
149  depth_dense_node = true;
150  }
151  break;
152 
153  case projection_error:
154  if (m_parserType == PROJECTION_ERROR_PARSER) {
155  read_projection_error(dataNode);
156  projection_error_node = true;
157  }
158  break;
159 
160  default:
161  break;
162  }
163  }
164  }
165  }
166 
167  if (m_verbose) {
168  if (m_parserType == PROJECTION_ERROR_PARSER) {
169  if (!projection_error_node) {
170  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
171  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
172  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
173  }
174  } else {
175  if (!camera_node) {
176  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
177  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
178  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
179  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
180  }
181 
182  if (!face_node) {
183  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
184  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
185  }
186 
187  if (!lod_node) {
188  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
189  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
190  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
191  }
192 
193  if (!ecm_node && (m_parserType & EDGE_PARSER)) {
194  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
195  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
196  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
197  std::cout << "ecm : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
198  std::cout << "ecm : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
199  std::cout << "ecm : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
200  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
201  }
202 
203  if (!klt_node && (m_parserType & KLT_PARSER)) {
204  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
205  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
206  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
207  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
208  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
209  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
210  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
211  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
212  }
213 
214  if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
215  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
216  << std::endl;
217  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
218  << " (default)" << std::endl;
219  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
220  << " (default)" << std::endl;
221  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
222  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
223  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
224  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
225  }
226 
227  if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
228  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
229  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
230  }
231  }
232  }
233  }
234 
240  void read_camera(const pugi::xml_node &node)
241  {
242  bool u0_node = false;
243  bool v0_node = false;
244  bool px_node = false;
245  bool py_node = false;
246 
247  // current data values.
248  double d_u0 = m_cam.get_u0();
249  double d_v0 = m_cam.get_v0();
250  double d_px = m_cam.get_px();
251  double d_py = m_cam.get_py();
252 
253  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
254  if (dataNode.type() == pugi::node_element) {
255  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
256  if (iter_data != m_nodeMap.end()) {
257  switch (iter_data->second) {
258  case u0:
259  d_u0 = dataNode.text().as_double();
260  u0_node = true;
261  break;
262 
263  case v0:
264  d_v0 = dataNode.text().as_double();
265  v0_node = true;
266  break;
267 
268  case px:
269  d_px = dataNode.text().as_double();
270  px_node = true;
271  break;
272 
273  case py:
274  d_py = dataNode.text().as_double();
275  py_node = true;
276  break;
277 
278  default:
279  break;
280  }
281  }
282  }
283  }
284 
285  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
286 
287  if (m_verbose) {
288  if (!u0_node)
289  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
290  else
291  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
292 
293  if (!v0_node)
294  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
295  else
296  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
297 
298  if (!px_node)
299  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
300  else
301  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
302 
303  if (!py_node)
304  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
305  else
306  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
307  }
308  }
309 
315  void read_depth_normal(const pugi::xml_node &node)
316  {
317  bool feature_estimation_method_node = false;
318  bool PCL_plane_estimation_node = false;
319  bool sampling_step_node = false;
320 
321  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
322  if (dataNode.type() == pugi::node_element) {
323  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
324  if (iter_data != m_nodeMap.end()) {
325  switch (iter_data->second) {
326  case feature_estimation_method:
327  m_depthNormalFeatureEstimationMethod =
328  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
329  feature_estimation_method_node = true;
330  break;
331 
332  case PCL_plane_estimation:
333  read_depth_normal_PCL(dataNode);
334  PCL_plane_estimation_node = true;
335  break;
336 
337  case depth_sampling_step:
338  read_depth_normal_sampling_step(dataNode);
339  sampling_step_node = true;
340  break;
341 
342  default:
343  break;
344  }
345  }
346  }
347  }
348 
349  if (m_verbose) {
350  if (!feature_estimation_method_node)
351  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
352  << std::endl;
353  else
354  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
355 
356  if (!PCL_plane_estimation_node) {
357  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
358  << " (default)" << std::endl;
359  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
360  << " (default)" << std::endl;
361  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
362  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
363  }
364 
365  if (!sampling_step_node) {
366  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
367  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
368  }
369  }
370  }
371 
377  void read_depth_normal_PCL(const pugi::xml_node &node)
378  {
379  bool PCL_plane_estimation_method_node = false;
380  bool PCL_plane_estimation_ransac_max_iter_node = false;
381  bool PCL_plane_estimation_ransac_threshold_node = false;
382 
383  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
384  if (dataNode.type() == pugi::node_element) {
385  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
386  if (iter_data != m_nodeMap.end()) {
387  switch (iter_data->second) {
388  case PCL_plane_estimation_method:
389  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
390  PCL_plane_estimation_method_node = true;
391  break;
392 
393  case PCL_plane_estimation_ransac_max_iter:
394  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
395  PCL_plane_estimation_ransac_max_iter_node = true;
396  break;
397 
398  case PCL_plane_estimation_ransac_threshold:
399  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
400  PCL_plane_estimation_ransac_threshold_node = true;
401  break;
402 
403  default:
404  break;
405  }
406  }
407  }
408  }
409 
410  if (m_verbose) {
411  if (!PCL_plane_estimation_method_node)
412  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
413  << " (default)" << std::endl;
414  else
415  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
416  << std::endl;
417 
418  if (!PCL_plane_estimation_ransac_max_iter_node)
419  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
420  << " (default)" << std::endl;
421  else
422  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
423  << std::endl;
424 
425  if (!PCL_plane_estimation_ransac_threshold_node)
426  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
427  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
428  else
429  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
430  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
431  }
432  }
433 
439  void read_depth_normal_sampling_step(const pugi::xml_node &node)
440  {
441  bool sampling_step_X_node = false;
442  bool sampling_step_Y_node = false;
443 
444  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
445  if (dataNode.type() == pugi::node_element) {
446  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
447  if (iter_data != m_nodeMap.end()) {
448  switch (iter_data->second) {
449  case depth_sampling_step_X:
450  m_depthNormalSamplingStepX = dataNode.text().as_uint();
451  sampling_step_X_node = true;
452  break;
453 
454  case depth_sampling_step_Y:
455  m_depthNormalSamplingStepY = dataNode.text().as_uint();
456  sampling_step_Y_node = true;
457  break;
458 
459  default:
460  break;
461  }
462  }
463  }
464  }
465 
466  if (m_verbose) {
467  if (!sampling_step_X_node)
468  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)" << std::endl;
469  else
470  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
471 
472  if (!sampling_step_Y_node)
473  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)" << std::endl;
474  else
475  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
476  }
477  }
478 
484  void read_depth_dense(const pugi::xml_node &node)
485  {
486  bool sampling_step_node = false;
487 
488  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
489  if (dataNode.type() == pugi::node_element) {
490  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
491  if (iter_data != m_nodeMap.end()) {
492  switch (iter_data->second) {
493  case depth_dense_sampling_step:
494  read_depth_dense_sampling_step(dataNode);
495  sampling_step_node = true;
496  break;
497 
498  default:
499  break;
500  }
501  }
502  }
503  }
504 
505  if (!sampling_step_node && m_verbose) {
506  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
507  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
508  }
509  }
510 
516  void read_depth_dense_sampling_step(const pugi::xml_node &node)
517  {
518  bool sampling_step_X_node = false;
519  bool sampling_step_Y_node = false;
520 
521  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
522  if (dataNode.type() == pugi::node_element) {
523  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
524  if (iter_data != m_nodeMap.end()) {
525  switch (iter_data->second) {
526  case depth_dense_sampling_step_X:
527  m_depthDenseSamplingStepX = dataNode.text().as_uint();
528  sampling_step_X_node = true;
529  break;
530 
531  case depth_dense_sampling_step_Y:
532  m_depthDenseSamplingStepY = dataNode.text().as_uint();
533  sampling_step_Y_node = true;
534  break;
535 
536  default:
537  break;
538  }
539  }
540  }
541  }
542 
543  if (m_verbose) {
544  if (!sampling_step_X_node)
545  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)" << std::endl;
546  else
547  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
548 
549  if (!sampling_step_Y_node)
550  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)" << std::endl;
551  else
552  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
553  }
554  }
555 
561  void read_ecm(const pugi::xml_node &node)
562  {
563  bool mask_node = false;
564  bool range_node = false;
565  bool contrast_node = false;
566  bool sample_node = false;
567 
568  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
569  if (dataNode.type() == pugi::node_element) {
570  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
571  if (iter_data != m_nodeMap.end()) {
572  switch (iter_data->second) {
573  case mask:
574  read_ecm_mask(dataNode);
575  mask_node = true;
576  break;
577 
578  case range:
579  read_ecm_range(dataNode);
580  range_node = true;
581  break;
582 
583  case contrast:
584  read_ecm_contrast(dataNode);
585  contrast_node = true;
586  break;
587 
588  case sample:
589  read_ecm_sample(dataNode);
590  sample_node = true;
591  break;
592 
593  default:
594  break;
595  }
596  }
597  }
598  }
599 
600  if (m_verbose) {
601  if (!mask_node) {
602  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
603  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
604  }
605 
606  if (!range_node) {
607  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
608  }
609 
610  if (!contrast_node) {
611  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
612  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
613  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
614  }
615 
616  if (!sample_node) {
617  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
618  }
619  }
620  }
621 
627  void read_ecm_contrast(const pugi::xml_node &node)
628  {
629  bool edge_threshold_node = false;
630  bool mu1_node = false;
631  bool mu2_node = false;
632 
633  // current data values.
634  double d_edge_threshold = m_ecm.getThreshold();
635  double d_mu1 = m_ecm.getMu1();
636  double d_mu2 = m_ecm.getMu2();
637 
638  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
639  if (dataNode.type() == pugi::node_element) {
640  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
641  if (iter_data != m_nodeMap.end()) {
642  switch (iter_data->second) {
643  case edge_threshold:
644  d_edge_threshold = dataNode.text().as_double();
645  edge_threshold_node = true;
646  break;
647 
648  case mu1:
649  d_mu1 = dataNode.text().as_double();
650  mu1_node = true;
651  break;
652 
653  case mu2:
654  d_mu2 = dataNode.text().as_double();
655  mu2_node = true;
656  break;
657 
658  default:
659  break;
660  }
661  }
662  }
663  }
664 
665  m_ecm.setMu1(d_mu1);
666  m_ecm.setMu2(d_mu2);
667  m_ecm.setThreshold(d_edge_threshold);
668 
669  if (m_verbose) {
670  if (!edge_threshold_node)
671  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
672  else
673  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
674 
675  if (!mu1_node)
676  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
677  else
678  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
679 
680  if (!mu2_node)
681  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
682  else
683  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
684  }
685  }
686 
692  void read_ecm_mask(const pugi::xml_node &node)
693  {
694  bool size_node = false;
695  bool nb_mask_node = false;
696 
697  // current data values.
698  unsigned int d_size = m_ecm.getMaskSize();
699  unsigned int d_nb_mask = m_ecm.getMaskNumber();
700 
701  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
702  if (dataNode.type() == pugi::node_element) {
703  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
704  if (iter_data != m_nodeMap.end()) {
705  switch (iter_data->second) {
706  case size:
707  d_size = dataNode.text().as_uint();
708  size_node = true;
709  break;
710 
711  case nb_mask:
712  d_nb_mask = dataNode.text().as_uint();
713  nb_mask_node = true;
714  break;
715 
716  default:
717  break;
718  }
719  }
720  }
721  }
722 
723  m_ecm.setMaskSize(d_size);
724 
725  // Check to ensure that d_nb_mask > 0
726  if (d_nb_mask == 0)
727  throw(vpException(vpException::badValue, "Model-based tracker mask size "
728  "parameter should be different "
729  "from zero in xml file"));
730  m_ecm.setMaskNumber(d_nb_mask);
731 
732  if (m_verbose) {
733  if (!size_node)
734  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
735  else
736  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
737 
738  if (!nb_mask_node)
739  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
740  else
741  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
742  }
743  }
744 
750  void read_ecm_range(const pugi::xml_node &node)
751  {
752  bool tracking_node = false;
753 
754  // current data values.
755  unsigned int m_range_tracking = m_ecm.getRange();
756 
757  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
758  if (dataNode.type() == pugi::node_element) {
759  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
760  if (iter_data != m_nodeMap.end()) {
761  switch (iter_data->second) {
762  case tracking:
763  m_range_tracking = dataNode.text().as_uint();
764  tracking_node = true;
765  break;
766 
767  default:
768  break;
769  }
770  }
771  }
772  }
773 
774  m_ecm.setRange(m_range_tracking);
775 
776  if (m_verbose) {
777  if (!tracking_node)
778  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
779  else
780  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << std::endl;
781  }
782  }
783 
789  void read_ecm_sample(const pugi::xml_node &node)
790  {
791  bool step_node = false;
792 
793  // current data values.
794  double d_stp = m_ecm.getSampleStep();
795 
796  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
797  if (dataNode.type() == pugi::node_element) {
798  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
799  if (iter_data != m_nodeMap.end()) {
800  switch (iter_data->second) {
801  case step:
802  d_stp = dataNode.text().as_int();
803  step_node = true;
804  break;
805 
806  default:
807  break;
808  }
809  }
810  }
811  }
812 
813  m_ecm.setSampleStep(d_stp);
814 
815  if (m_verbose) {
816  if (!step_node)
817  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
818  else
819  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
820  }
821  }
822 
828  void read_face(const pugi::xml_node &node)
829  {
830  bool angle_appear_node = false;
831  bool angle_disappear_node = false;
832  bool near_clipping_node = false;
833  bool far_clipping_node = false;
834  bool fov_clipping_node = false;
835  m_hasNearClipping = false;
836  m_hasFarClipping = false;
837 
838  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
839  if (dataNode.type() == pugi::node_element) {
840  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
841  if (iter_data != m_nodeMap.end()) {
842  switch (iter_data->second) {
843  case angle_appear:
844  m_angleAppear = dataNode.text().as_double();
845  angle_appear_node = true;
846  break;
847 
848  case angle_disappear:
849  m_angleDisappear = dataNode.text().as_double();
850  angle_disappear_node = true;
851  break;
852 
853  case near_clipping:
854  m_nearClipping = dataNode.text().as_double();
855  m_hasNearClipping = true;
856  near_clipping_node = true;
857  break;
858 
859  case far_clipping:
860  m_farClipping = dataNode.text().as_double();
861  m_hasFarClipping = true;
862  far_clipping_node = true;
863  break;
864 
865  case fov_clipping:
866  if (dataNode.text().as_int())
867  m_fovClipping = true;
868  else
869  m_fovClipping = false;
870  fov_clipping_node = true;
871  break;
872 
873  default:
874  break;
875  }
876  }
877  }
878  }
879 
880  if (m_verbose) {
881  if (!angle_appear_node)
882  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
883  else
884  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
885 
886  if (!angle_disappear_node)
887  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
888  else
889  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
890 
891  if (near_clipping_node)
892  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
893 
894  if (far_clipping_node)
895  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
896 
897  if (fov_clipping_node) {
898  if (m_fovClipping)
899  std::cout << "face : Fov Clipping : True" << std::endl;
900  else
901  std::cout << "face : Fov Clipping : False" << std::endl;
902  }
903  }
904  }
905 
911  void read_klt(const pugi::xml_node &node)
912  {
913  bool mask_border_node = false;
914  bool max_features_node = false;
915  bool window_size_node = false;
916  bool quality_node = false;
917  bool min_distance_node = false;
918  bool harris_node = false;
919  bool size_block_node = false;
920  bool pyramid_lvl_node = false;
921 
922  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
923  if (dataNode.type() == pugi::node_element) {
924  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
925  if (iter_data != m_nodeMap.end()) {
926  switch (iter_data->second) {
927  case mask_border:
928  m_kltMaskBorder = dataNode.text().as_uint();
929  mask_border_node = true;
930  break;
931 
932  case max_features:
933  m_kltMaxFeatures = dataNode.text().as_uint();
934  max_features_node = true;
935  break;
936 
937  case window_size:
938  m_kltWinSize = dataNode.text().as_uint();
939  window_size_node = true;
940  break;
941 
942  case quality:
943  m_kltQualityValue = dataNode.text().as_double();
944  quality_node = true;
945  break;
946 
947  case min_distance:
948  m_kltMinDist = dataNode.text().as_double();
949  min_distance_node = true;
950  break;
951 
952  case harris:
953  m_kltHarrisParam = dataNode.text().as_double();
954  harris_node = true;
955  break;
956 
957  case size_block:
958  m_kltBlockSize = dataNode.text().as_uint();
959  size_block_node = true;
960  break;
961 
962  case pyramid_lvl:
963  m_kltPyramidLevels = dataNode.text().as_uint();
964  pyramid_lvl_node = true;
965  break;
966 
967  default:
968  break;
969  }
970  }
971  }
972  }
973 
974  if (m_verbose) {
975  if (!mask_border_node)
976  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
977  else
978  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
979 
980  if (!max_features_node)
981  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
982  else
983  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
984 
985  if (!window_size_node)
986  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
987  else
988  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
989 
990  if (!quality_node)
991  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
992  else
993  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
994 
995  if (!min_distance_node)
996  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
997  else
998  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
999 
1000  if (!harris_node)
1001  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
1002  else
1003  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1004 
1005  if (!size_block_node)
1006  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
1007  else
1008  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
1009 
1010  if (!pyramid_lvl_node)
1011  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
1012  else
1013  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1014  }
1015  }
1016 
1017  void read_lod(const pugi::xml_node &node)
1018  {
1019  bool use_lod_node = false;
1020  bool min_line_length_threshold_node = false;
1021  bool min_polygon_area_threshold_node = false;
1022 
1023  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1024  if (dataNode.type() == pugi::node_element) {
1025  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1026  if (iter_data != m_nodeMap.end()) {
1027  switch (iter_data->second) {
1028  case use_lod:
1029  m_useLod = (dataNode.text().as_int() != 0);
1030  use_lod_node = true;
1031  break;
1032 
1033  case min_line_length_threshold:
1034  m_minLineLengthThreshold = dataNode.text().as_double();
1035  min_line_length_threshold_node = true;
1036  break;
1037 
1038  case min_polygon_area_threshold:
1039  m_minPolygonAreaThreshold = dataNode.text().as_double();
1040  min_polygon_area_threshold_node = true;
1041  break;
1042 
1043  default:
1044  break;
1045  }
1046  }
1047  }
1048  }
1049 
1050  if (m_verbose) {
1051  if (!use_lod_node)
1052  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1053  else
1054  std::cout << "lod : use lod : " << m_useLod << std::endl;
1055 
1056  if (!min_line_length_threshold_node)
1057  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1058  else
1059  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1060 
1061  if (!min_polygon_area_threshold_node)
1062  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1063  else
1064  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1065  }
1066  }
1067 
1068  void read_projection_error(const pugi::xml_node &node)
1069  {
1070  bool step_node = false;
1071  bool kernel_size_node = false;
1072 
1073  // current data values.
1074  double d_stp = m_projectionErrorMe.getSampleStep();
1075  std::string kernel_size_str;
1076 
1077  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1078  if (dataNode.type() == pugi::node_element) {
1079  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1080  if (iter_data != m_nodeMap.end()) {
1081  switch (iter_data->second) {
1082  case projection_error_sample_step:
1083  d_stp = dataNode.text().as_int();
1084  step_node = true;
1085  break;
1086 
1087  case projection_error_kernel_size:
1088  kernel_size_str = dataNode.text().as_string();
1089  kernel_size_node = true;
1090  break;
1091 
1092  default:
1093  break;
1094  }
1095  }
1096  }
1097  }
1098 
1099  m_projectionErrorMe.setSampleStep(d_stp);
1100 
1101  if (kernel_size_str == "3x3") {
1102  m_projectionErrorKernelSize = 1;
1103  } else if (kernel_size_str == "5x5") {
1104  m_projectionErrorKernelSize = 2;
1105  } else if (kernel_size_str == "7x7") {
1106  m_projectionErrorKernelSize = 3;
1107  } else if (kernel_size_str == "9x9") {
1108  m_projectionErrorKernelSize = 4;
1109  } else if (kernel_size_str == "11x11") {
1110  m_projectionErrorKernelSize = 5;
1111  } else if (kernel_size_str == "13x13") {
1112  m_projectionErrorKernelSize = 6;
1113  } else if (kernel_size_str == "15x15") {
1114  m_projectionErrorKernelSize = 7;
1115  } else {
1116  std::cerr << "Unsupported kernel size." << std::endl;
1117  }
1118 
1119  if (m_verbose) {
1120  if (!step_node)
1121  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
1122  else
1123  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1124 
1125  if (!kernel_size_node)
1126  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
1127  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
1128  else
1129  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1130  }
1131  }
1132 
1138  void read_sample_deprecated(const pugi::xml_node &node)
1139  {
1140  bool step_node = false;
1141  // bool nb_sample_node = false;
1142 
1143  // current data values.
1144  double d_stp = m_ecm.getSampleStep();
1145 
1146  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1147  if (dataNode.type() == pugi::node_element) {
1148  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1149  if (iter_data != m_nodeMap.end()) {
1150  switch (iter_data->second) {
1151  case step:
1152  d_stp = dataNode.text().as_int();
1153  step_node = true;
1154  break;
1155 
1156  default:
1157  break;
1158  }
1159  }
1160  }
1161  }
1162 
1163  m_ecm.setSampleStep(d_stp);
1164 
1165  if (m_verbose) {
1166  if (!step_node)
1167  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1168  else
1169  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1170 
1171  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1172  std::cout << " It should be moved in the ecm node (ecm : sample)." << std::endl;
1173  }
1174  }
1175 
1176  double getAngleAppear() const { return m_angleAppear; }
1177  double getAngleDisappear() const { return m_angleDisappear; }
1178 
1179  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1180 
1181  void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1182 
1183  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1184  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1185 
1187  {
1188  return m_depthNormalFeatureEstimationMethod;
1189  }
1190  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1192  {
1193  return m_depthNormalPclPlaneEstimationRansacMaxIter;
1194  }
1196  {
1197  return m_depthNormalPclPlaneEstimationRansacThreshold;
1198  }
1199  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1200  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1201 
1202  double getFarClippingDistance() const { return m_farClipping; }
1203  bool getFovClipping() const { return m_fovClipping; }
1204 
1205  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1206  double getKltHarrisParam() const { return m_kltHarrisParam; }
1207  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1208  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1209  double getKltMinDistance() const { return m_kltMinDist; }
1210  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1211  double getKltQuality() const { return m_kltQualityValue; }
1212  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1213 
1214  bool getLodState() const { return m_useLod; }
1215  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1216  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1217 
1218  double getNearClippingDistance() const { return m_nearClipping; }
1219 
1220  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1221  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1222 
1223  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1224  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1225 
1226  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1227  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1228 
1229  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1230 
1231  void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1232  void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1234  {
1235  m_depthNormalFeatureEstimationMethod = method;
1236  }
1238  {
1239  m_depthNormalPclPlaneEstimationMethod = method;
1240  }
1242  {
1243  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1244  }
1246  {
1247  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1248  }
1249  void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1250  void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1251 
1252  void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1253 
1254  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1255 
1256  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1257  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1258  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1259  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1260  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1261  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1262  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1263  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1264 
1265  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1266 
1267  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1268  void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1269 
1270  void setVerbose(bool verbose) { m_verbose = verbose; }
1271 
1272 protected:
1274  int m_parserType;
1276  vpCameraParameters m_cam;
1278  double m_angleAppear;
1280  double m_angleDisappear;
1282  bool m_hasNearClipping;
1284  double m_nearClipping;
1286  bool m_hasFarClipping;
1288  double m_farClipping;
1290  bool m_fovClipping;
1291  // LOD
1293  bool m_useLod;
1295  double m_minLineLengthThreshold;
1297  double m_minPolygonAreaThreshold;
1298  // Edge
1300  vpMe m_ecm;
1301  // KLT
1303  unsigned int m_kltMaskBorder;
1305  unsigned int m_kltMaxFeatures;
1307  unsigned int m_kltWinSize;
1309  double m_kltQualityValue;
1311  double m_kltMinDist;
1313  double m_kltHarrisParam;
1315  unsigned int m_kltBlockSize;
1317  unsigned int m_kltPyramidLevels;
1318  // Depth normal
1320  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1322  int m_depthNormalPclPlaneEstimationMethod;
1324  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1326  double m_depthNormalPclPlaneEstimationRansacThreshold;
1328  unsigned int m_depthNormalSamplingStepX;
1330  unsigned int m_depthNormalSamplingStepY;
1331  // Depth dense
1333  unsigned int m_depthDenseSamplingStepX;
1335  unsigned int m_depthDenseSamplingStepY;
1336  // Projection error
1338  vpMe m_projectionErrorMe;
1340  unsigned int m_projectionErrorKernelSize;
1341  std::map<std::string, int> m_nodeMap;
1343  bool m_verbose;
1344 
1345  enum vpDataToParseMb {
1346  //<conf>
1347  conf,
1348  //<face>
1349  face,
1350  angle_appear,
1351  angle_disappear,
1352  near_clipping,
1353  far_clipping,
1354  fov_clipping,
1355  //<camera>
1356  camera,
1357  height,
1358  width,
1359  u0,
1360  v0,
1361  px,
1362  py,
1363  lod,
1364  use_lod,
1365  min_line_length_threshold,
1366  min_polygon_area_threshold,
1367  //<ecm>
1368  ecm,
1369  mask,
1370  size,
1371  nb_mask,
1372  range,
1373  tracking,
1374  contrast,
1375  edge_threshold,
1376  mu1,
1377  mu2,
1378  sample,
1379  step,
1380  //<klt>
1381  klt,
1382  mask_border,
1383  max_features,
1384  window_size,
1385  quality,
1386  min_distance,
1387  harris,
1388  size_block,
1389  pyramid_lvl,
1390  //<depth_normal>
1391  depth_normal,
1392  feature_estimation_method,
1393  PCL_plane_estimation,
1394  PCL_plane_estimation_method,
1395  PCL_plane_estimation_ransac_max_iter,
1396  PCL_plane_estimation_ransac_threshold,
1397  depth_sampling_step,
1398  depth_sampling_step_X,
1399  depth_sampling_step_Y,
1400  //<depth_dense>
1401  depth_dense,
1402  depth_dense_sampling_step,
1403  depth_dense_sampling_step_X,
1404  depth_dense_sampling_step_Y,
1405  //<projection_error>
1406  projection_error,
1407  projection_error_sample_step,
1408  projection_error_kernel_size
1409  };
1410 
1414  void init()
1415  {
1416  //<conf>
1417  m_nodeMap["conf"] = conf;
1418  //<face>
1419  m_nodeMap["face"] = face;
1420  m_nodeMap["angle_appear"] = angle_appear;
1421  m_nodeMap["angle_disappear"] = angle_disappear;
1422  m_nodeMap["near_clipping"] = near_clipping;
1423  m_nodeMap["far_clipping"] = far_clipping;
1424  m_nodeMap["fov_clipping"] = fov_clipping;
1425  //<camera>
1426  m_nodeMap["camera"] = camera;
1427  m_nodeMap["height"] = height;
1428  m_nodeMap["width"] = width;
1429  m_nodeMap["u0"] = u0;
1430  m_nodeMap["v0"] = v0;
1431  m_nodeMap["px"] = px;
1432  m_nodeMap["py"] = py;
1433  //<lod>
1434  m_nodeMap["lod"] = lod;
1435  m_nodeMap["use_lod"] = use_lod;
1436  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1437  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1438  //<ecm>
1439  m_nodeMap["ecm"] = ecm;
1440  m_nodeMap["mask"] = mask;
1441  m_nodeMap["size"] = size;
1442  m_nodeMap["nb_mask"] = nb_mask;
1443  m_nodeMap["range"] = range;
1444  m_nodeMap["tracking"] = tracking;
1445  m_nodeMap["contrast"] = contrast;
1446  m_nodeMap["edge_threshold"] = edge_threshold;
1447  m_nodeMap["mu1"] = mu1;
1448  m_nodeMap["mu2"] = mu2;
1449  m_nodeMap["sample"] = sample;
1450  m_nodeMap["step"] = step;
1451  //<klt>
1452  m_nodeMap["klt"] = klt;
1453  m_nodeMap["mask_border"] = mask_border;
1454  m_nodeMap["max_features"] = max_features;
1455  m_nodeMap["window_size"] = window_size;
1456  m_nodeMap["quality"] = quality;
1457  m_nodeMap["min_distance"] = min_distance;
1458  m_nodeMap["harris"] = harris;
1459  m_nodeMap["size_block"] = size_block;
1460  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1461  //<depth_normal>
1462  m_nodeMap["depth_normal"] = depth_normal;
1463  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1464  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1465  m_nodeMap["method"] = PCL_plane_estimation_method;
1466  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1467  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1468  m_nodeMap["sampling_step"] = depth_sampling_step;
1469  m_nodeMap["step_X"] = depth_sampling_step_X;
1470  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1471  //<depth_dense>
1472  m_nodeMap["depth_dense"] = depth_dense;
1473  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1474  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1475  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1476  //<projection_error>
1477  m_nodeMap["projection_error"] = projection_error;
1478  m_nodeMap["sample_step"] = projection_error_sample_step;
1479  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1480  }
1481 };
1482 #endif // DOXYGEN_SHOULD_SKIP_THIS
1483 
1484 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1485 {
1486  //https://pugixml.org/docs/manual.html#access.attrdata
1487  //https://en.cppreference.com/w/cpp/locale/setlocale
1488  //When called from Java binding, the locale seems to be changed to the default system locale
1489  //It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
1490  if (std::setlocale(LC_ALL, "C") == NULL) {
1491  std::cerr << "Cannot set locale to C" << std::endl;
1492  }
1493 }
1494 
1496 {
1497  delete m_impl;
1498 }
1499 
1505 void vpMbtXmlGenericParser::parse(const std::string &filename)
1506 {
1507  m_impl->parse(filename);
1508 }
1509 
1514 {
1515  return m_impl->getAngleAppear();
1516 }
1517 
1522 {
1523  return m_impl->getAngleDisappear();
1524 }
1525 
1527 {
1528  m_impl->getCameraParameters(cam);
1529 }
1530 
1535 {
1536  m_impl->getEdgeMe(ecm);
1537 }
1538 
1543 {
1544  return m_impl->getDepthDenseSamplingStepX();
1545 }
1546 
1551 {
1552  return m_impl->getDepthDenseSamplingStepY();
1553 }
1554 
1559 {
1560  return m_impl->getDepthNormalFeatureEstimationMethod();
1561 }
1562 
1567 {
1568  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1569 }
1570 
1575 {
1576  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1577 }
1578 
1583 {
1584  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1585 }
1586 
1591 {
1592  return m_impl->getDepthNormalSamplingStepX();
1593 }
1594 
1599 {
1600  return m_impl->getDepthNormalSamplingStepY();
1601 }
1602 
1607 {
1608  return m_impl->getFarClippingDistance();
1609 }
1610 
1615 {
1616  return m_impl->getFovClipping();
1617 }
1618 
1623 {
1624  return m_impl->getKltBlockSize();
1625 }
1626 
1631 {
1632  return m_impl->getKltHarrisParam();
1633 }
1634 
1639 {
1640  return m_impl->getKltMaskBorder();
1641 }
1642 
1647 {
1648  return m_impl->getKltMaxFeatures();
1649 }
1650 
1655 {
1656  return m_impl->getKltMinDistance();
1657 }
1658 
1663 {
1664  return m_impl->getKltPyramidLevels();
1665 }
1666 
1671 {
1672  return m_impl->getKltQuality();
1673 }
1674 
1679 {
1680  return m_impl->getKltWindowSize();
1681 }
1682 
1687 {
1688  return m_impl->getLodState();
1689 }
1690 
1695 {
1696  return m_impl->getLodMinLineLengthThreshold();
1697 }
1698 
1703 {
1704  return m_impl->getLodMinPolygonAreaThreshold();
1705 }
1706 
1711 {
1712  return m_impl->getNearClippingDistance();
1713 }
1714 
1719 {
1720  m_impl->getProjectionErrorMe(me);
1721 }
1722 
1724 {
1725  return m_impl->getProjectionErrorKernelSize();
1726 }
1727 
1734 {
1735  return m_impl->hasFarClippingDistance();
1736 }
1737 
1744 {
1745  return m_impl->hasNearClippingDistance();
1746 }
1747 
1753 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear)
1754 {
1755  m_impl->setAngleAppear(aappear);
1756 }
1757 
1763 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear)
1764 {
1765  m_impl->setAngleDisappear(adisappear);
1766 }
1767 
1774 {
1775  m_impl->setCameraParameters(cam);
1776 }
1777 
1784 {
1785  m_impl->setDepthDenseSamplingStepX(stepX);
1786 }
1787 
1794 {
1795  m_impl->setDepthDenseSamplingStepY(stepY);
1796 }
1797 
1804 {
1805  m_impl->setDepthNormalFeatureEstimationMethod(method);
1806 }
1807 
1814 {
1815  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1816 }
1817 
1824 {
1825  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1826 }
1827 
1834 {
1835  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1836 }
1837 
1844 {
1845  m_impl->setDepthNormalSamplingStepX(stepX);
1846 }
1847 
1854 {
1855  m_impl->setDepthNormalSamplingStepY(stepY);
1856 }
1857 
1864 {
1865  m_impl->setEdgeMe(ecm);
1866 }
1867 
1874 {
1875  m_impl->setFarClippingDistance(fclip);
1876 }
1877 
1883 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs)
1884 {
1885  m_impl->setKltBlockSize(bs);
1886 }
1887 
1894 {
1895  m_impl->setKltHarrisParam(hp);
1896 }
1897 
1903 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb)
1904 {
1905  m_impl->setKltMaskBorder(mb);
1906 }
1907 
1913 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF)
1914 {
1915  m_impl->setKltMaxFeatures(mF);
1916 }
1917 
1924 {
1925  m_impl->setKltMinDistance(mD);
1926 }
1927 
1934 {
1935  m_impl->setKltPyramidLevels(pL);
1936 }
1937 
1944 {
1945  m_impl->setKltQuality(q);
1946 }
1947 
1953 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w)
1954 {
1955  m_impl->setKltWindowSize(w);
1956 }
1957 
1964 {
1965  m_impl->setNearClippingDistance(nclip);
1966 }
1967 
1974 {
1975  m_impl->setProjectionErrorMe(me);
1976 }
1977 
1984 {
1985  m_impl->setProjectionErrorKernelSize(size);
1986 }
1987 
1994 {
1995  m_impl->setVerbose(verbose);
1996 }
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
double getFarClippingDistance() const
void setKltQuality(const double &q)
void parse(const std::string &filename)
double getNearClippingDistance() const
void setKltPyramidLevels(const unsigned int &pL)
void setDepthNormalSamplingStepY(unsigned int stepY)
unsigned int getKltBlockSize() const
void setProjectionErrorKernelSize(const unsigned int &size)
void getCameraParameters(vpCameraParameters &cam) const
error that can be emited by ViSP classes.
Definition: vpException.h:71
Definition: vpMe.h:60
vpMbtXmlGenericParser(int type=EDGE_PARSER)
double getLodMinLineLengthThreshold() const
void setKltMaskBorder(const unsigned int &mb)
unsigned int getProjectionErrorKernelSize() const
void setEdgeMe(const vpMe &ecm)
void setKltHarrisParam(const double &hp)
void setAngleDisappear(const double &adisappear)
void setKltMinDistance(const double &mD)
void setProjectionErrorMe(const vpMe &me)
void getProjectionErrorMe(vpMe &me) const
void setDepthNormalSamplingStepX(unsigned int stepX)
Generic class defining intrinsic camera parameters.
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void setDepthDenseSamplingStepY(unsigned int stepY)
unsigned int getDepthNormalSamplingStepX() const
void setKltWindowSize(const unsigned int &w)
void getEdgeMe(vpMe &ecm) const
void setAngleAppear(const double &aappear)
void setDepthDenseSamplingStepX(unsigned int stepX)
void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
unsigned int getKltPyramidLevels() const
unsigned int getKltMaskBorder() const
unsigned int getDepthDenseSamplingStepX() const
void setNearClippingDistance(const double &nclip)
void setFarClippingDistance(const double &fclip)
unsigned int getDepthDenseSamplingStepY() const
unsigned int getDepthNormalSamplingStepY() const
unsigned int getKltMaxFeatures() const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
void setKltBlockSize(const unsigned int &bs)
void setKltMaxFeatures(const unsigned int &mF)
void setCameraParameters(const vpCameraParameters &cam)
double getLodMinPolygonAreaThreshold() const
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
int getDepthNormalPclPlaneEstimationMethod() const
void setDepthNormalPclPlaneEstimationMethod(int method)
unsigned int getKltWindowSize() const