Visual Servoing Platform  version 3.5.1 under development (2022-07-05)
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 <clocale>
38 #include <iostream>
39 #include <map>
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),
67  m_depthNormalSamplingStepY(2),
68  //<depth_dense>
69  m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
70  //<projection_error>
71  m_projectionErrorMe(), m_projectionErrorKernelSize(2), // 5x5
72  m_nodeMap(), 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)"
171  << std::endl;
172  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
173  << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
174  }
175  } else {
176  if (!camera_node) {
177  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
178  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
179  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
180  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
181  }
182 
183  if (!face_node) {
184  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
185  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
186  }
187 
188  if (!lod_node) {
189  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
190  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
191  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
192  }
193 
194  if (!ecm_node && (m_parserType & EDGE_PARSER)) {
195  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
196  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
197  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
198  std::cout << "ecm : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
199  std::cout << "ecm : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
200  std::cout << "ecm : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
201  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
202  }
203 
204  if (!klt_node && (m_parserType & KLT_PARSER)) {
205  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
206  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
207  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
208  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
209  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
210  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
211  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
212  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
213  }
214 
215  if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
216  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
217  << " (default)" << std::endl;
218  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
219  << " (default)" << std::endl;
220  std::cout << "depth normal : PCL_plane_estimation : max_iter : "
221  << m_depthNormalPclPlaneEstimationRansacMaxIter << " (default)" << std::endl;
222  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
223  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
224  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
225  << std::endl;
226  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
227  << std::endl;
228  }
229 
230  if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
231  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)"
232  << std::endl;
233  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)"
234  << std::endl;
235  }
236  }
237  }
238  }
239 
245  void read_camera(const pugi::xml_node &node)
246  {
247  bool u0_node = false;
248  bool v0_node = false;
249  bool px_node = false;
250  bool py_node = false;
251 
252  // current data values.
253  double d_u0 = m_cam.get_u0();
254  double d_v0 = m_cam.get_v0();
255  double d_px = m_cam.get_px();
256  double d_py = m_cam.get_py();
257 
258  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
259  if (dataNode.type() == pugi::node_element) {
260  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
261  if (iter_data != m_nodeMap.end()) {
262  switch (iter_data->second) {
263  case u0:
264  d_u0 = dataNode.text().as_double();
265  u0_node = true;
266  break;
267 
268  case v0:
269  d_v0 = dataNode.text().as_double();
270  v0_node = true;
271  break;
272 
273  case px:
274  d_px = dataNode.text().as_double();
275  px_node = true;
276  break;
277 
278  case py:
279  d_py = dataNode.text().as_double();
280  py_node = true;
281  break;
282 
283  default:
284  break;
285  }
286  }
287  }
288  }
289 
290  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
291 
292  if (m_verbose) {
293  if (!u0_node)
294  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
295  else
296  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
297 
298  if (!v0_node)
299  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
300  else
301  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
302 
303  if (!px_node)
304  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
305  else
306  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
307 
308  if (!py_node)
309  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
310  else
311  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
312  }
313  }
314 
320  void read_depth_normal(const pugi::xml_node &node)
321  {
322  bool feature_estimation_method_node = false;
323  bool PCL_plane_estimation_node = false;
324  bool sampling_step_node = false;
325 
326  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
327  if (dataNode.type() == pugi::node_element) {
328  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
329  if (iter_data != m_nodeMap.end()) {
330  switch (iter_data->second) {
331  case feature_estimation_method:
332  m_depthNormalFeatureEstimationMethod =
333  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
334  feature_estimation_method_node = true;
335  break;
336 
337  case PCL_plane_estimation:
338  read_depth_normal_PCL(dataNode);
339  PCL_plane_estimation_node = true;
340  break;
341 
342  case depth_sampling_step:
343  read_depth_normal_sampling_step(dataNode);
344  sampling_step_node = true;
345  break;
346 
347  default:
348  break;
349  }
350  }
351  }
352  }
353 
354  if (m_verbose) {
355  if (!feature_estimation_method_node)
356  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
357  << " (default)" << std::endl;
358  else
359  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
360 
361  if (!PCL_plane_estimation_node) {
362  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
363  << " (default)" << std::endl;
364  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
365  << " (default)" << std::endl;
366  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
367  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
368  }
369 
370  if (!sampling_step_node) {
371  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
372  << std::endl;
373  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
374  << std::endl;
375  }
376  }
377  }
378 
384  void read_depth_normal_PCL(const pugi::xml_node &node)
385  {
386  bool PCL_plane_estimation_method_node = false;
387  bool PCL_plane_estimation_ransac_max_iter_node = false;
388  bool PCL_plane_estimation_ransac_threshold_node = false;
389 
390  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
391  if (dataNode.type() == pugi::node_element) {
392  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
393  if (iter_data != m_nodeMap.end()) {
394  switch (iter_data->second) {
395  case PCL_plane_estimation_method:
396  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
397  PCL_plane_estimation_method_node = true;
398  break;
399 
400  case PCL_plane_estimation_ransac_max_iter:
401  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
402  PCL_plane_estimation_ransac_max_iter_node = true;
403  break;
404 
405  case PCL_plane_estimation_ransac_threshold:
406  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
407  PCL_plane_estimation_ransac_threshold_node = true;
408  break;
409 
410  default:
411  break;
412  }
413  }
414  }
415  }
416 
417  if (m_verbose) {
418  if (!PCL_plane_estimation_method_node)
419  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
420  << " (default)" << std::endl;
421  else
422  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
423  << std::endl;
424 
425  if (!PCL_plane_estimation_ransac_max_iter_node)
426  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
427  << " (default)" << std::endl;
428  else
429  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
430  << std::endl;
431 
432  if (!PCL_plane_estimation_ransac_threshold_node)
433  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
434  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
435  else
436  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
437  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
438  }
439  }
440 
446  void read_depth_normal_sampling_step(const pugi::xml_node &node)
447  {
448  bool sampling_step_X_node = false;
449  bool sampling_step_Y_node = false;
450 
451  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
452  if (dataNode.type() == pugi::node_element) {
453  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
454  if (iter_data != m_nodeMap.end()) {
455  switch (iter_data->second) {
456  case depth_sampling_step_X:
457  m_depthNormalSamplingStepX = dataNode.text().as_uint();
458  sampling_step_X_node = true;
459  break;
460 
461  case depth_sampling_step_Y:
462  m_depthNormalSamplingStepY = dataNode.text().as_uint();
463  sampling_step_Y_node = true;
464  break;
465 
466  default:
467  break;
468  }
469  }
470  }
471  }
472 
473  if (m_verbose) {
474  if (!sampling_step_X_node)
475  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)"
476  << std::endl;
477  else
478  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
479 
480  if (!sampling_step_Y_node)
481  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)"
482  << std::endl;
483  else
484  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
485  }
486  }
487 
493  void read_depth_dense(const pugi::xml_node &node)
494  {
495  bool sampling_step_node = false;
496 
497  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
498  if (dataNode.type() == pugi::node_element) {
499  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
500  if (iter_data != m_nodeMap.end()) {
501  switch (iter_data->second) {
502  case depth_dense_sampling_step:
503  read_depth_dense_sampling_step(dataNode);
504  sampling_step_node = true;
505  break;
506 
507  default:
508  break;
509  }
510  }
511  }
512  }
513 
514  if (!sampling_step_node && m_verbose) {
515  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
516  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
517  }
518  }
519 
525  void read_depth_dense_sampling_step(const pugi::xml_node &node)
526  {
527  bool sampling_step_X_node = false;
528  bool sampling_step_Y_node = false;
529 
530  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
531  if (dataNode.type() == pugi::node_element) {
532  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
533  if (iter_data != m_nodeMap.end()) {
534  switch (iter_data->second) {
535  case depth_dense_sampling_step_X:
536  m_depthDenseSamplingStepX = dataNode.text().as_uint();
537  sampling_step_X_node = true;
538  break;
539 
540  case depth_dense_sampling_step_Y:
541  m_depthDenseSamplingStepY = dataNode.text().as_uint();
542  sampling_step_Y_node = true;
543  break;
544 
545  default:
546  break;
547  }
548  }
549  }
550  }
551 
552  if (m_verbose) {
553  if (!sampling_step_X_node)
554  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)"
555  << std::endl;
556  else
557  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
558 
559  if (!sampling_step_Y_node)
560  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)"
561  << std::endl;
562  else
563  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
564  }
565  }
566 
572  void read_ecm(const pugi::xml_node &node)
573  {
574  bool mask_node = false;
575  bool range_node = false;
576  bool contrast_node = false;
577  bool sample_node = false;
578 
579  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
580  if (dataNode.type() == pugi::node_element) {
581  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
582  if (iter_data != m_nodeMap.end()) {
583  switch (iter_data->second) {
584  case mask:
585  read_ecm_mask(dataNode);
586  mask_node = true;
587  break;
588 
589  case range:
590  read_ecm_range(dataNode);
591  range_node = true;
592  break;
593 
594  case contrast:
595  read_ecm_contrast(dataNode);
596  contrast_node = true;
597  break;
598 
599  case sample:
600  read_ecm_sample(dataNode);
601  sample_node = true;
602  break;
603 
604  default:
605  break;
606  }
607  }
608  }
609  }
610 
611  if (m_verbose) {
612  if (!mask_node) {
613  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
614  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
615  }
616 
617  if (!range_node) {
618  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
619  }
620 
621  if (!contrast_node) {
622  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
623  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
624  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
625  }
626 
627  if (!sample_node) {
628  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
629  }
630  }
631  }
632 
638  void read_ecm_contrast(const pugi::xml_node &node)
639  {
640  bool edge_threshold_node = false;
641  bool mu1_node = false;
642  bool mu2_node = false;
643 
644  // current data values.
645  double d_edge_threshold = m_ecm.getThreshold();
646  double d_mu1 = m_ecm.getMu1();
647  double d_mu2 = m_ecm.getMu2();
648 
649  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
650  if (dataNode.type() == pugi::node_element) {
651  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
652  if (iter_data != m_nodeMap.end()) {
653  switch (iter_data->second) {
654  case edge_threshold:
655  d_edge_threshold = dataNode.text().as_double();
656  edge_threshold_node = true;
657  break;
658 
659  case mu1:
660  d_mu1 = dataNode.text().as_double();
661  mu1_node = true;
662  break;
663 
664  case mu2:
665  d_mu2 = dataNode.text().as_double();
666  mu2_node = true;
667  break;
668 
669  default:
670  break;
671  }
672  }
673  }
674  }
675 
676  m_ecm.setMu1(d_mu1);
677  m_ecm.setMu2(d_mu2);
678  m_ecm.setThreshold(d_edge_threshold);
679 
680  if (m_verbose) {
681  if (!edge_threshold_node)
682  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
683  else
684  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
685 
686  if (!mu1_node)
687  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
688  else
689  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
690 
691  if (!mu2_node)
692  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
693  else
694  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
695  }
696  }
697 
703  void read_ecm_mask(const pugi::xml_node &node)
704  {
705  bool size_node = false;
706  bool nb_mask_node = false;
707 
708  // current data values.
709  unsigned int d_size = m_ecm.getMaskSize();
710  unsigned int d_nb_mask = m_ecm.getMaskNumber();
711 
712  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
713  if (dataNode.type() == pugi::node_element) {
714  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
715  if (iter_data != m_nodeMap.end()) {
716  switch (iter_data->second) {
717  case size:
718  d_size = dataNode.text().as_uint();
719  size_node = true;
720  break;
721 
722  case nb_mask:
723  d_nb_mask = dataNode.text().as_uint();
724  nb_mask_node = true;
725  break;
726 
727  default:
728  break;
729  }
730  }
731  }
732  }
733 
734  m_ecm.setMaskSize(d_size);
735 
736  // Check to ensure that d_nb_mask > 0
737  if (d_nb_mask == 0)
738  throw(vpException(vpException::badValue, "Model-based tracker mask size "
739  "parameter should be different "
740  "from zero in xml file"));
741  m_ecm.setMaskNumber(d_nb_mask);
742 
743  if (m_verbose) {
744  if (!size_node)
745  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
746  else
747  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
748 
749  if (!nb_mask_node)
750  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
751  else
752  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
753  }
754  }
755 
761  void read_ecm_range(const pugi::xml_node &node)
762  {
763  bool tracking_node = false;
764 
765  // current data values.
766  unsigned int m_range_tracking = m_ecm.getRange();
767 
768  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
769  if (dataNode.type() == pugi::node_element) {
770  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
771  if (iter_data != m_nodeMap.end()) {
772  switch (iter_data->second) {
773  case tracking:
774  m_range_tracking = dataNode.text().as_uint();
775  tracking_node = true;
776  break;
777 
778  default:
779  break;
780  }
781  }
782  }
783  }
784 
785  m_ecm.setRange(m_range_tracking);
786 
787  if (m_verbose) {
788  if (!tracking_node)
789  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
790  else
791  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << std::endl;
792  }
793  }
794 
800  void read_ecm_sample(const pugi::xml_node &node)
801  {
802  bool step_node = false;
803 
804  // current data values.
805  double d_stp = m_ecm.getSampleStep();
806 
807  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
808  if (dataNode.type() == pugi::node_element) {
809  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
810  if (iter_data != m_nodeMap.end()) {
811  switch (iter_data->second) {
812  case step:
813  d_stp = dataNode.text().as_int();
814  step_node = true;
815  break;
816 
817  default:
818  break;
819  }
820  }
821  }
822  }
823 
824  m_ecm.setSampleStep(d_stp);
825 
826  if (m_verbose) {
827  if (!step_node)
828  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
829  else
830  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
831  }
832  }
833 
839  void read_face(const pugi::xml_node &node)
840  {
841  bool angle_appear_node = false;
842  bool angle_disappear_node = false;
843  bool near_clipping_node = false;
844  bool far_clipping_node = false;
845  bool fov_clipping_node = false;
846  m_hasNearClipping = false;
847  m_hasFarClipping = false;
848 
849  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
850  if (dataNode.type() == pugi::node_element) {
851  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
852  if (iter_data != m_nodeMap.end()) {
853  switch (iter_data->second) {
854  case angle_appear:
855  m_angleAppear = dataNode.text().as_double();
856  angle_appear_node = true;
857  break;
858 
859  case angle_disappear:
860  m_angleDisappear = dataNode.text().as_double();
861  angle_disappear_node = true;
862  break;
863 
864  case near_clipping:
865  m_nearClipping = dataNode.text().as_double();
866  m_hasNearClipping = true;
867  near_clipping_node = true;
868  break;
869 
870  case far_clipping:
871  m_farClipping = dataNode.text().as_double();
872  m_hasFarClipping = true;
873  far_clipping_node = true;
874  break;
875 
876  case fov_clipping:
877  if (dataNode.text().as_int())
878  m_fovClipping = true;
879  else
880  m_fovClipping = false;
881  fov_clipping_node = true;
882  break;
883 
884  default:
885  break;
886  }
887  }
888  }
889  }
890 
891  if (m_verbose) {
892  if (!angle_appear_node)
893  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
894  else
895  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
896 
897  if (!angle_disappear_node)
898  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
899  else
900  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
901 
902  if (near_clipping_node)
903  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
904 
905  if (far_clipping_node)
906  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
907 
908  if (fov_clipping_node) {
909  if (m_fovClipping)
910  std::cout << "face : Fov Clipping : True" << std::endl;
911  else
912  std::cout << "face : Fov Clipping : False" << std::endl;
913  }
914  }
915  }
916 
922  void read_klt(const pugi::xml_node &node)
923  {
924  bool mask_border_node = false;
925  bool max_features_node = false;
926  bool window_size_node = false;
927  bool quality_node = false;
928  bool min_distance_node = false;
929  bool harris_node = false;
930  bool size_block_node = false;
931  bool pyramid_lvl_node = false;
932 
933  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
934  if (dataNode.type() == pugi::node_element) {
935  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
936  if (iter_data != m_nodeMap.end()) {
937  switch (iter_data->second) {
938  case mask_border:
939  m_kltMaskBorder = dataNode.text().as_uint();
940  mask_border_node = true;
941  break;
942 
943  case max_features:
944  m_kltMaxFeatures = dataNode.text().as_uint();
945  max_features_node = true;
946  break;
947 
948  case window_size:
949  m_kltWinSize = dataNode.text().as_uint();
950  window_size_node = true;
951  break;
952 
953  case quality:
954  m_kltQualityValue = dataNode.text().as_double();
955  quality_node = true;
956  break;
957 
958  case min_distance:
959  m_kltMinDist = dataNode.text().as_double();
960  min_distance_node = true;
961  break;
962 
963  case harris:
964  m_kltHarrisParam = dataNode.text().as_double();
965  harris_node = true;
966  break;
967 
968  case size_block:
969  m_kltBlockSize = dataNode.text().as_uint();
970  size_block_node = true;
971  break;
972 
973  case pyramid_lvl:
974  m_kltPyramidLevels = dataNode.text().as_uint();
975  pyramid_lvl_node = true;
976  break;
977 
978  default:
979  break;
980  }
981  }
982  }
983  }
984 
985  if (m_verbose) {
986  if (!mask_border_node)
987  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
988  else
989  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
990 
991  if (!max_features_node)
992  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
993  else
994  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
995 
996  if (!window_size_node)
997  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
998  else
999  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
1000 
1001  if (!quality_node)
1002  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
1003  else
1004  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
1005 
1006  if (!min_distance_node)
1007  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
1008  else
1009  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
1010 
1011  if (!harris_node)
1012  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
1013  else
1014  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1015 
1016  if (!size_block_node)
1017  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
1018  else
1019  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
1020 
1021  if (!pyramid_lvl_node)
1022  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
1023  else
1024  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1025  }
1026  }
1027 
1028  void read_lod(const pugi::xml_node &node)
1029  {
1030  bool use_lod_node = false;
1031  bool min_line_length_threshold_node = false;
1032  bool min_polygon_area_threshold_node = false;
1033 
1034  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1035  if (dataNode.type() == pugi::node_element) {
1036  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1037  if (iter_data != m_nodeMap.end()) {
1038  switch (iter_data->second) {
1039  case use_lod:
1040  m_useLod = (dataNode.text().as_int() != 0);
1041  use_lod_node = true;
1042  break;
1043 
1044  case min_line_length_threshold:
1045  m_minLineLengthThreshold = dataNode.text().as_double();
1046  min_line_length_threshold_node = true;
1047  break;
1048 
1049  case min_polygon_area_threshold:
1050  m_minPolygonAreaThreshold = dataNode.text().as_double();
1051  min_polygon_area_threshold_node = true;
1052  break;
1053 
1054  default:
1055  break;
1056  }
1057  }
1058  }
1059  }
1060 
1061  if (m_verbose) {
1062  if (!use_lod_node)
1063  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1064  else
1065  std::cout << "lod : use lod : " << m_useLod << std::endl;
1066 
1067  if (!min_line_length_threshold_node)
1068  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1069  else
1070  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1071 
1072  if (!min_polygon_area_threshold_node)
1073  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1074  else
1075  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1076  }
1077  }
1078 
1079  void read_projection_error(const pugi::xml_node &node)
1080  {
1081  bool step_node = false;
1082  bool kernel_size_node = false;
1083 
1084  // current data values.
1085  double d_stp = m_projectionErrorMe.getSampleStep();
1086  std::string kernel_size_str;
1087 
1088  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1089  if (dataNode.type() == pugi::node_element) {
1090  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1091  if (iter_data != m_nodeMap.end()) {
1092  switch (iter_data->second) {
1093  case projection_error_sample_step:
1094  d_stp = dataNode.text().as_int();
1095  step_node = true;
1096  break;
1097 
1098  case projection_error_kernel_size:
1099  kernel_size_str = dataNode.text().as_string();
1100  kernel_size_node = true;
1101  break;
1102 
1103  default:
1104  break;
1105  }
1106  }
1107  }
1108  }
1109 
1110  m_projectionErrorMe.setSampleStep(d_stp);
1111 
1112  if (kernel_size_str == "3x3") {
1113  m_projectionErrorKernelSize = 1;
1114  } else if (kernel_size_str == "5x5") {
1115  m_projectionErrorKernelSize = 2;
1116  } else if (kernel_size_str == "7x7") {
1117  m_projectionErrorKernelSize = 3;
1118  } else if (kernel_size_str == "9x9") {
1119  m_projectionErrorKernelSize = 4;
1120  } else if (kernel_size_str == "11x11") {
1121  m_projectionErrorKernelSize = 5;
1122  } else if (kernel_size_str == "13x13") {
1123  m_projectionErrorKernelSize = 6;
1124  } else if (kernel_size_str == "15x15") {
1125  m_projectionErrorKernelSize = 7;
1126  } else {
1127  std::cerr << "Unsupported kernel size." << std::endl;
1128  }
1129 
1130  if (m_verbose) {
1131  if (!step_node)
1132  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
1133  << std::endl;
1134  else
1135  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1136 
1137  if (!kernel_size_node)
1138  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
1139  << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
1140  else
1141  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1142  }
1143  }
1144 
1150  void read_sample_deprecated(const pugi::xml_node &node)
1151  {
1152  bool step_node = false;
1153  // bool nb_sample_node = false;
1154 
1155  // current data values.
1156  double d_stp = m_ecm.getSampleStep();
1157 
1158  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1159  if (dataNode.type() == pugi::node_element) {
1160  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1161  if (iter_data != m_nodeMap.end()) {
1162  switch (iter_data->second) {
1163  case step:
1164  d_stp = dataNode.text().as_int();
1165  step_node = true;
1166  break;
1167 
1168  default:
1169  break;
1170  }
1171  }
1172  }
1173  }
1174 
1175  m_ecm.setSampleStep(d_stp);
1176 
1177  if (m_verbose) {
1178  if (!step_node)
1179  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1180  else
1181  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1182 
1183  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1184  std::cout << " It should be moved in the ecm node (ecm : sample)." << std::endl;
1185  }
1186  }
1187 
1188  double getAngleAppear() const { return m_angleAppear; }
1189  double getAngleDisappear() const { return m_angleDisappear; }
1190 
1191  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1192 
1193  void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1194 
1195  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1196  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1197 
1199  {
1200  return m_depthNormalFeatureEstimationMethod;
1201  }
1202  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1203  int getDepthNormalPclPlaneEstimationRansacMaxIter() const { return m_depthNormalPclPlaneEstimationRansacMaxIter; }
1205  {
1206  return m_depthNormalPclPlaneEstimationRansacThreshold;
1207  }
1208  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1209  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1210 
1211  double getFarClippingDistance() const { return m_farClipping; }
1212  bool getFovClipping() const { return m_fovClipping; }
1213 
1214  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1215  double getKltHarrisParam() const { return m_kltHarrisParam; }
1216  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1217  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1218  double getKltMinDistance() const { return m_kltMinDist; }
1219  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1220  double getKltQuality() const { return m_kltQualityValue; }
1221  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1222 
1223  bool getLodState() const { return m_useLod; }
1224  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1225  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1226 
1227  double getNearClippingDistance() const { return m_nearClipping; }
1228 
1229  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1230  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1231 
1232  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1233  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1234 
1235  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1236  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1237 
1238  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1239 
1240  void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1241  void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1243  {
1244  m_depthNormalFeatureEstimationMethod = method;
1245  }
1246  void setDepthNormalPclPlaneEstimationMethod(int method) { m_depthNormalPclPlaneEstimationMethod = method; }
1248  {
1249  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1250  }
1252  {
1253  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1254  }
1255  void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1256  void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1257 
1258  void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1259 
1260  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1261 
1262  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1263  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1264  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1265  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1266  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1267  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1268  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1269  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1270 
1271  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1272 
1273  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1274  void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1275 
1276  void setVerbose(bool verbose) { m_verbose = verbose; }
1277 
1278 protected:
1280  int m_parserType;
1282  vpCameraParameters m_cam;
1284  double m_angleAppear;
1286  double m_angleDisappear;
1288  bool m_hasNearClipping;
1290  double m_nearClipping;
1292  bool m_hasFarClipping;
1294  double m_farClipping;
1296  bool m_fovClipping;
1297  // LOD
1299  bool m_useLod;
1301  double m_minLineLengthThreshold;
1303  double m_minPolygonAreaThreshold;
1304  // Edge
1306  vpMe m_ecm;
1307  // KLT
1309  unsigned int m_kltMaskBorder;
1311  unsigned int m_kltMaxFeatures;
1313  unsigned int m_kltWinSize;
1315  double m_kltQualityValue;
1317  double m_kltMinDist;
1319  double m_kltHarrisParam;
1321  unsigned int m_kltBlockSize;
1323  unsigned int m_kltPyramidLevels;
1324  // Depth normal
1326  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1328  int m_depthNormalPclPlaneEstimationMethod;
1330  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1332  double m_depthNormalPclPlaneEstimationRansacThreshold;
1334  unsigned int m_depthNormalSamplingStepX;
1336  unsigned int m_depthNormalSamplingStepY;
1337  // Depth dense
1339  unsigned int m_depthDenseSamplingStepX;
1341  unsigned int m_depthDenseSamplingStepY;
1342  // Projection error
1344  vpMe m_projectionErrorMe;
1346  unsigned int m_projectionErrorKernelSize;
1347  std::map<std::string, int> m_nodeMap;
1349  bool m_verbose;
1350 
1351  enum vpDataToParseMb {
1352  //<conf>
1353  conf,
1354  //<face>
1355  face,
1356  angle_appear,
1357  angle_disappear,
1358  near_clipping,
1359  far_clipping,
1360  fov_clipping,
1361  //<camera>
1362  camera,
1363  height,
1364  width,
1365  u0,
1366  v0,
1367  px,
1368  py,
1369  lod,
1370  use_lod,
1371  min_line_length_threshold,
1372  min_polygon_area_threshold,
1373  //<ecm>
1374  ecm,
1375  mask,
1376  size,
1377  nb_mask,
1378  range,
1379  tracking,
1380  contrast,
1381  edge_threshold,
1382  mu1,
1383  mu2,
1384  sample,
1385  step,
1386  //<klt>
1387  klt,
1388  mask_border,
1389  max_features,
1390  window_size,
1391  quality,
1392  min_distance,
1393  harris,
1394  size_block,
1395  pyramid_lvl,
1396  //<depth_normal>
1397  depth_normal,
1398  feature_estimation_method,
1399  PCL_plane_estimation,
1400  PCL_plane_estimation_method,
1401  PCL_plane_estimation_ransac_max_iter,
1402  PCL_plane_estimation_ransac_threshold,
1403  depth_sampling_step,
1404  depth_sampling_step_X,
1405  depth_sampling_step_Y,
1406  //<depth_dense>
1407  depth_dense,
1408  depth_dense_sampling_step,
1409  depth_dense_sampling_step_X,
1410  depth_dense_sampling_step_Y,
1411  //<projection_error>
1412  projection_error,
1413  projection_error_sample_step,
1414  projection_error_kernel_size
1415  };
1416 
1420  void init()
1421  {
1422  //<conf>
1423  m_nodeMap["conf"] = conf;
1424  //<face>
1425  m_nodeMap["face"] = face;
1426  m_nodeMap["angle_appear"] = angle_appear;
1427  m_nodeMap["angle_disappear"] = angle_disappear;
1428  m_nodeMap["near_clipping"] = near_clipping;
1429  m_nodeMap["far_clipping"] = far_clipping;
1430  m_nodeMap["fov_clipping"] = fov_clipping;
1431  //<camera>
1432  m_nodeMap["camera"] = camera;
1433  m_nodeMap["height"] = height;
1434  m_nodeMap["width"] = width;
1435  m_nodeMap["u0"] = u0;
1436  m_nodeMap["v0"] = v0;
1437  m_nodeMap["px"] = px;
1438  m_nodeMap["py"] = py;
1439  //<lod>
1440  m_nodeMap["lod"] = lod;
1441  m_nodeMap["use_lod"] = use_lod;
1442  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1443  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1444  //<ecm>
1445  m_nodeMap["ecm"] = ecm;
1446  m_nodeMap["mask"] = mask;
1447  m_nodeMap["size"] = size;
1448  m_nodeMap["nb_mask"] = nb_mask;
1449  m_nodeMap["range"] = range;
1450  m_nodeMap["tracking"] = tracking;
1451  m_nodeMap["contrast"] = contrast;
1452  m_nodeMap["edge_threshold"] = edge_threshold;
1453  m_nodeMap["mu1"] = mu1;
1454  m_nodeMap["mu2"] = mu2;
1455  m_nodeMap["sample"] = sample;
1456  m_nodeMap["step"] = step;
1457  //<klt>
1458  m_nodeMap["klt"] = klt;
1459  m_nodeMap["mask_border"] = mask_border;
1460  m_nodeMap["max_features"] = max_features;
1461  m_nodeMap["window_size"] = window_size;
1462  m_nodeMap["quality"] = quality;
1463  m_nodeMap["min_distance"] = min_distance;
1464  m_nodeMap["harris"] = harris;
1465  m_nodeMap["size_block"] = size_block;
1466  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1467  //<depth_normal>
1468  m_nodeMap["depth_normal"] = depth_normal;
1469  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1470  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1471  m_nodeMap["method"] = PCL_plane_estimation_method;
1472  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1473  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1474  m_nodeMap["sampling_step"] = depth_sampling_step;
1475  m_nodeMap["step_X"] = depth_sampling_step_X;
1476  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1477  //<depth_dense>
1478  m_nodeMap["depth_dense"] = depth_dense;
1479  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1480  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1481  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1482  //<projection_error>
1483  m_nodeMap["projection_error"] = projection_error;
1484  m_nodeMap["sample_step"] = projection_error_sample_step;
1485  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1486  }
1487 };
1488 #endif // DOXYGEN_SHOULD_SKIP_THIS
1489 
1490 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1491 {
1492  // https://pugixml.org/docs/manual.html#access.attrdata
1493  // https://en.cppreference.com/w/cpp/locale/setlocale
1494  // When called from Java binding, the locale seems to be changed to the default system locale
1495  // It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
1496  if (std::setlocale(LC_ALL, "C") == NULL) {
1497  std::cerr << "Cannot set locale to C" << std::endl;
1498  }
1499 }
1500 
1502 
1508 void vpMbtXmlGenericParser::parse(const std::string &filename) { m_impl->parse(filename); }
1509 
1513 double vpMbtXmlGenericParser::getAngleAppear() const { return m_impl->getAngleAppear(); }
1514 
1518 double vpMbtXmlGenericParser::getAngleDisappear() const { return m_impl->getAngleDisappear(); }
1519 
1520 void vpMbtXmlGenericParser::getCameraParameters(vpCameraParameters &cam) const { m_impl->getCameraParameters(cam); }
1521 
1525 void vpMbtXmlGenericParser::getEdgeMe(vpMe &ecm) const { m_impl->getEdgeMe(ecm); }
1526 
1530 unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepX() const { return m_impl->getDepthDenseSamplingStepX(); }
1531 
1535 unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepY() const { return m_impl->getDepthDenseSamplingStepY(); }
1536 
1541 {
1542  return m_impl->getDepthNormalFeatureEstimationMethod();
1543 }
1544 
1549 {
1550  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1551 }
1552 
1557 {
1558  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1559 }
1560 
1565 {
1566  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1567 }
1568 
1573 {
1574  return m_impl->getDepthNormalSamplingStepX();
1575 }
1576 
1581 {
1582  return m_impl->getDepthNormalSamplingStepY();
1583 }
1584 
1588 double vpMbtXmlGenericParser::getFarClippingDistance() const { return m_impl->getFarClippingDistance(); }
1589 
1593 bool vpMbtXmlGenericParser::getFovClipping() const { return m_impl->getFovClipping(); }
1594 
1598 unsigned int vpMbtXmlGenericParser::getKltBlockSize() const { return m_impl->getKltBlockSize(); }
1599 
1603 double vpMbtXmlGenericParser::getKltHarrisParam() const { return m_impl->getKltHarrisParam(); }
1604 
1608 unsigned int vpMbtXmlGenericParser::getKltMaskBorder() const { return m_impl->getKltMaskBorder(); }
1609 
1613 unsigned int vpMbtXmlGenericParser::getKltMaxFeatures() const { return m_impl->getKltMaxFeatures(); }
1614 
1618 double vpMbtXmlGenericParser::getKltMinDistance() const { return m_impl->getKltMinDistance(); }
1619 
1623 unsigned int vpMbtXmlGenericParser::getKltPyramidLevels() const { return m_impl->getKltPyramidLevels(); }
1624 
1628 double vpMbtXmlGenericParser::getKltQuality() const { return m_impl->getKltQuality(); }
1629 
1633 unsigned int vpMbtXmlGenericParser::getKltWindowSize() const { return m_impl->getKltWindowSize(); }
1634 
1638 bool vpMbtXmlGenericParser::getLodState() const { return m_impl->getLodState(); }
1639 
1643 double vpMbtXmlGenericParser::getLodMinLineLengthThreshold() const { return m_impl->getLodMinLineLengthThreshold(); }
1644 
1648 double vpMbtXmlGenericParser::getLodMinPolygonAreaThreshold() const { return m_impl->getLodMinPolygonAreaThreshold(); }
1649 
1653 double vpMbtXmlGenericParser::getNearClippingDistance() const { return m_impl->getNearClippingDistance(); }
1654 
1658 void vpMbtXmlGenericParser::getProjectionErrorMe(vpMe &me) const { m_impl->getProjectionErrorMe(me); }
1659 
1661 {
1662  return m_impl->getProjectionErrorKernelSize();
1663 }
1664 
1670 bool vpMbtXmlGenericParser::hasFarClippingDistance() const { return m_impl->hasFarClippingDistance(); }
1671 
1677 bool vpMbtXmlGenericParser::hasNearClippingDistance() const { return m_impl->hasNearClippingDistance(); }
1678 
1684 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear) { m_impl->setAngleAppear(aappear); }
1685 
1691 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear) { m_impl->setAngleDisappear(adisappear); }
1692 
1698 void vpMbtXmlGenericParser::setCameraParameters(const vpCameraParameters &cam) { m_impl->setCameraParameters(cam); }
1699 
1706 {
1707  m_impl->setDepthDenseSamplingStepX(stepX);
1708 }
1709 
1716 {
1717  m_impl->setDepthDenseSamplingStepY(stepY);
1718 }
1719 
1727 {
1728  m_impl->setDepthNormalFeatureEstimationMethod(method);
1729 }
1730 
1737 {
1738  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1739 }
1740 
1747 {
1748  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1749 }
1750 
1757 {
1758  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1759 }
1760 
1767 {
1768  m_impl->setDepthNormalSamplingStepX(stepX);
1769 }
1770 
1777 {
1778  m_impl->setDepthNormalSamplingStepY(stepY);
1779 }
1780 
1786 void vpMbtXmlGenericParser::setEdgeMe(const vpMe &ecm) { m_impl->setEdgeMe(ecm); }
1787 
1793 void vpMbtXmlGenericParser::setFarClippingDistance(const double &fclip) { m_impl->setFarClippingDistance(fclip); }
1794 
1800 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs) { m_impl->setKltBlockSize(bs); }
1801 
1807 void vpMbtXmlGenericParser::setKltHarrisParam(const double &hp) { m_impl->setKltHarrisParam(hp); }
1808 
1814 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb) { m_impl->setKltMaskBorder(mb); }
1815 
1821 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF) { m_impl->setKltMaxFeatures(mF); }
1822 
1828 void vpMbtXmlGenericParser::setKltMinDistance(const double &mD) { m_impl->setKltMinDistance(mD); }
1829 
1835 void vpMbtXmlGenericParser::setKltPyramidLevels(const unsigned int &pL) { m_impl->setKltPyramidLevels(pL); }
1836 
1842 void vpMbtXmlGenericParser::setKltQuality(const double &q) { m_impl->setKltQuality(q); }
1843 
1849 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w) { m_impl->setKltWindowSize(w); }
1850 
1856 void vpMbtXmlGenericParser::setNearClippingDistance(const double &nclip) { m_impl->setNearClippingDistance(nclip); }
1857 
1863 void vpMbtXmlGenericParser::setProjectionErrorMe(const vpMe &me) { m_impl->setProjectionErrorMe(me); }
1864 
1871 {
1872  m_impl->setProjectionErrorKernelSize(size);
1873 }
1874 
1880 void vpMbtXmlGenericParser::setVerbose(bool verbose) { m_impl->setVerbose(verbose); }
Generic class defining intrinsic camera parameters.
error that can be emited by ViSP classes.
Definition: vpException.h:72
@ ioError
I/O error.
Definition: vpException.h:91
@ badValue
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
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:61