Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
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 #ifdef VISP_HAVE_PUGIXML
38 
39 #include <iostream>
40 #include <map>
41 #include <clocale>
42 
43 #include <visp3/mbt/vpMbtXmlGenericParser.h>
44 
45 #include <pugixml.hpp>
46 
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 class vpMbtXmlGenericParser::Impl
49 {
50 public:
51  Impl(int type = EDGE_PARSER) :
52  m_parserType(type),
53  //<camera>
54  m_cam(),
55  //<face>
56  m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
57  m_farClipping(false), m_fovClipping(false),
58  //<lod>
59  m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
60  //<ecm>
61  m_ecm(),
62  //<klt>
63  m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
64  m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
65  //<depth_normal>
66  m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
67  m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
68  m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2), m_depthNormalSamplingStepY(2),
69  //<depth_dense>
70  m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
71  //<projection_error>
72  m_projectionErrorMe(), m_projectionErrorKernelSize(2), //5x5
73  m_nodeMap()
74  {
75  init();
76  }
77 
78  void parse(const std::string &filename)
79  {
80  pugi::xml_document doc;
81  if (!doc.load_file(filename.c_str())) {
82  throw vpException(vpException::ioError, "Cannot open file: %s", filename.c_str());
83  }
84 
85  bool camera_node = false;
86  bool face_node = false;
87  bool ecm_node = false;
88  bool klt_node = false;
89  bool lod_node = false;
90  bool depth_normal_node = false;
91  bool depth_dense_node = false;
92  bool projection_error_node = false;
93 
94  pugi::xml_node root_node = doc.document_element();
95  for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
96  if (dataNode.type() == pugi::node_element) {
97  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
98  if (iter_data != m_nodeMap.end()) {
99  switch (iter_data->second) {
100  case camera:
101  if (m_parserType != PROJECTION_ERROR_PARSER) {
102  read_camera(dataNode);
103  camera_node = true;
104  }
105  break;
106 
107  case face:
108  if (m_parserType != PROJECTION_ERROR_PARSER) {
109  read_face(dataNode);
110  face_node = true;
111  }
112  break;
113 
114  case lod:
115  if (m_parserType != PROJECTION_ERROR_PARSER) {
116  read_lod(dataNode);
117  lod_node = true;
118  }
119  break;
120 
121  case ecm:
122  if (m_parserType & EDGE_PARSER) {
123  read_ecm(dataNode);
124  ecm_node = true;
125  }
126  break;
127 
128  case sample:
129  if (m_parserType & EDGE_PARSER)
130  read_sample_deprecated(dataNode);
131  break;
132 
133  case klt:
134  if (m_parserType & KLT_PARSER) {
135  read_klt(dataNode);
136  klt_node = true;
137  }
138  break;
139 
140  case depth_normal:
141  if (m_parserType & DEPTH_NORMAL_PARSER) {
142  read_depth_normal(dataNode);
143  depth_normal_node = true;
144  }
145  break;
146 
147  case depth_dense:
148  if (m_parserType & DEPTH_DENSE_PARSER) {
149  read_depth_dense(dataNode);
150  depth_dense_node = true;
151  }
152  break;
153 
154  case projection_error:
155  if (m_parserType == PROJECTION_ERROR_PARSER) {
156  read_projection_error(dataNode);
157  projection_error_node = true;
158  }
159  break;
160 
161  default:
162  break;
163  }
164  }
165  }
166  }
167 
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 
239  void read_camera(const pugi::xml_node &node)
240  {
241  bool u0_node = false;
242  bool v0_node = false;
243  bool px_node = false;
244  bool py_node = false;
245 
246  // current data values.
247  double d_u0 = m_cam.get_u0();
248  double d_v0 = m_cam.get_v0();
249  double d_px = m_cam.get_px();
250  double d_py = m_cam.get_py();
251 
252  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
253  if (dataNode.type() == pugi::node_element) {
254  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
255  if (iter_data != m_nodeMap.end()) {
256  switch (iter_data->second) {
257  case u0:
258  d_u0 = dataNode.text().as_double();
259  u0_node = true;
260  break;
261 
262  case v0:
263  d_v0 = dataNode.text().as_double();
264  v0_node = true;
265  break;
266 
267  case px:
268  d_px = dataNode.text().as_double();
269  px_node = true;
270  break;
271 
272  case py:
273  d_py = dataNode.text().as_double();
274  py_node = true;
275  break;
276 
277  default:
278  break;
279  }
280  }
281  }
282  }
283 
284  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
285 
286  if (!u0_node)
287  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
288  else
289  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
290 
291  if (!v0_node)
292  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
293  else
294  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
295 
296  if (!px_node)
297  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
298  else
299  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
300 
301  if (!py_node)
302  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
303  else
304  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
305  }
306 
312  void read_depth_normal(const pugi::xml_node &node)
313  {
314  bool feature_estimation_method_node = false;
315  bool PCL_plane_estimation_node = false;
316  bool sampling_step_node = false;
317 
318  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
319  if (dataNode.type() == pugi::node_element) {
320  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
321  if (iter_data != m_nodeMap.end()) {
322  switch (iter_data->second) {
323  case feature_estimation_method:
324  m_depthNormalFeatureEstimationMethod =
325  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
326  feature_estimation_method_node = true;
327  break;
328 
329  case PCL_plane_estimation:
330  read_depth_normal_PCL(dataNode);
331  PCL_plane_estimation_node = true;
332  break;
333 
334  case depth_sampling_step:
335  read_depth_normal_sampling_step(dataNode);
336  sampling_step_node = true;
337  break;
338 
339  default:
340  break;
341  }
342  }
343  }
344  }
345 
346  if (!feature_estimation_method_node)
347  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
348  << std::endl;
349  else
350  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
351 
352  if (!PCL_plane_estimation_node) {
353  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
354  << " (default)" << std::endl;
355  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
356  << " (default)" << std::endl;
357  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
358  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
359  }
360 
361  if (!sampling_step_node) {
362  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
363  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
364  }
365  }
366 
372  void read_depth_normal_PCL(const pugi::xml_node &node)
373  {
374  bool PCL_plane_estimation_method_node = false;
375  bool PCL_plane_estimation_ransac_max_iter_node = false;
376  bool PCL_plane_estimation_ransac_threshold_node = false;
377 
378  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
379  if (dataNode.type() == pugi::node_element) {
380  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
381  if (iter_data != m_nodeMap.end()) {
382  switch (iter_data->second) {
383  case PCL_plane_estimation_method:
384  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
385  PCL_plane_estimation_method_node = true;
386  break;
387 
388  case PCL_plane_estimation_ransac_max_iter:
389  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
390  PCL_plane_estimation_ransac_max_iter_node = true;
391  break;
392 
393  case PCL_plane_estimation_ransac_threshold:
394  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
395  PCL_plane_estimation_ransac_threshold_node = true;
396  break;
397 
398  default:
399  break;
400  }
401  }
402  }
403  }
404 
405  if (!PCL_plane_estimation_method_node)
406  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
407  << " (default)" << std::endl;
408  else
409  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
410  << std::endl;
411 
412  if (!PCL_plane_estimation_ransac_max_iter_node)
413  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
414  << " (default)" << std::endl;
415  else
416  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
417  << std::endl;
418 
419  if (!PCL_plane_estimation_ransac_threshold_node)
420  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
421  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
422  else
423  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
424  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
425  }
426 
432  void read_depth_normal_sampling_step(const pugi::xml_node &node)
433  {
434  bool sampling_step_X_node = false;
435  bool sampling_step_Y_node = false;
436 
437  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
438  if (dataNode.type() == pugi::node_element) {
439  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
440  if (iter_data != m_nodeMap.end()) {
441  switch (iter_data->second) {
442  case depth_sampling_step_X:
443  m_depthNormalSamplingStepX = dataNode.text().as_uint();
444  sampling_step_X_node = true;
445  break;
446 
447  case depth_sampling_step_Y:
448  m_depthNormalSamplingStepY = dataNode.text().as_uint();
449  sampling_step_Y_node = true;
450  break;
451 
452  default:
453  break;
454  }
455  }
456  }
457  }
458 
459  if (!sampling_step_X_node)
460  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)" << std::endl;
461  else
462  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
463 
464  if (!sampling_step_Y_node)
465  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)" << std::endl;
466  else
467  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
468  }
469 
475  void read_depth_dense(const pugi::xml_node &node)
476  {
477  bool sampling_step_node = false;
478 
479  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
480  if (dataNode.type() == pugi::node_element) {
481  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
482  if (iter_data != m_nodeMap.end()) {
483  switch (iter_data->second) {
484  case depth_dense_sampling_step:
485  read_depth_dense_sampling_step(dataNode);
486  sampling_step_node = true;
487  break;
488 
489  default:
490  break;
491  }
492  }
493  }
494  }
495 
496  if (!sampling_step_node) {
497  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
498  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
499  }
500  }
501 
507  void read_depth_dense_sampling_step(const pugi::xml_node &node)
508  {
509  bool sampling_step_X_node = false;
510  bool sampling_step_Y_node = false;
511 
512  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
513  if (dataNode.type() == pugi::node_element) {
514  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
515  if (iter_data != m_nodeMap.end()) {
516  switch (iter_data->second) {
517  case depth_dense_sampling_step_X:
518  m_depthDenseSamplingStepX = dataNode.text().as_uint();
519  sampling_step_X_node = true;
520  break;
521 
522  case depth_dense_sampling_step_Y:
523  m_depthDenseSamplingStepY = dataNode.text().as_uint();
524  sampling_step_Y_node = true;
525  break;
526 
527  default:
528  break;
529  }
530  }
531  }
532  }
533 
534  if (!sampling_step_X_node)
535  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)" << std::endl;
536  else
537  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
538 
539  if (!sampling_step_Y_node)
540  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)" << std::endl;
541  else
542  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
543  }
544 
550  void read_ecm(const pugi::xml_node &node)
551  {
552  bool mask_node = false;
553  bool range_node = false;
554  bool contrast_node = false;
555  bool sample_node = false;
556 
557  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
558  if (dataNode.type() == pugi::node_element) {
559  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
560  if (iter_data != m_nodeMap.end()) {
561  switch (iter_data->second) {
562  case mask:
563  read_ecm_mask(dataNode);
564  mask_node = true;
565  break;
566 
567  case range:
568  read_ecm_range(dataNode);
569  range_node = true;
570  break;
571 
572  case contrast:
573  read_ecm_contrast(dataNode);
574  contrast_node = true;
575  break;
576 
577  case sample:
578  read_ecm_sample(dataNode);
579  sample_node = true;
580  break;
581 
582  default:
583  break;
584  }
585  }
586  }
587  }
588 
589  if (!mask_node) {
590  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
591  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
592  }
593 
594  if (!range_node) {
595  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
596  }
597 
598  if (!contrast_node) {
599  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
600  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
601  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
602  }
603 
604  if (!sample_node) {
605  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
606  }
607  }
608 
614  void read_ecm_contrast(const pugi::xml_node &node)
615  {
616  bool edge_threshold_node = false;
617  bool mu1_node = false;
618  bool mu2_node = false;
619 
620  // current data values.
621  double d_edge_threshold = m_ecm.getThreshold();
622  double d_mu1 = m_ecm.getMu1();
623  double d_mu2 = m_ecm.getMu2();
624 
625  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
626  if (dataNode.type() == pugi::node_element) {
627  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
628  if (iter_data != m_nodeMap.end()) {
629  switch (iter_data->second) {
630  case edge_threshold:
631  d_edge_threshold = dataNode.text().as_double();
632  edge_threshold_node = true;
633  break;
634 
635  case mu1:
636  d_mu1 = dataNode.text().as_double();
637  mu1_node = true;
638  break;
639 
640  case mu2:
641  d_mu2 = dataNode.text().as_double();
642  mu2_node = true;
643  break;
644 
645  default:
646  break;
647  }
648  }
649  }
650  }
651 
652  m_ecm.setMu1(d_mu1);
653  m_ecm.setMu2(d_mu2);
654  m_ecm.setThreshold(d_edge_threshold);
655 
656  if (!edge_threshold_node)
657  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
658  else
659  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
660 
661  if (!mu1_node)
662  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
663  else
664  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
665 
666  if (!mu2_node)
667  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
668  else
669  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
670  }
671 
677  void read_ecm_mask(const pugi::xml_node &node)
678  {
679  bool size_node = false;
680  bool nb_mask_node = false;
681 
682  // current data values.
683  unsigned int d_size = m_ecm.getMaskSize();
684  unsigned int d_nb_mask = m_ecm.getMaskNumber();
685 
686  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
687  if (dataNode.type() == pugi::node_element) {
688  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
689  if (iter_data != m_nodeMap.end()) {
690  switch (iter_data->second) {
691  case size:
692  d_size = dataNode.text().as_uint();
693  size_node = true;
694  break;
695 
696  case nb_mask:
697  d_nb_mask = dataNode.text().as_uint();
698  nb_mask_node = true;
699  break;
700 
701  default:
702  break;
703  }
704  }
705  }
706  }
707 
708  m_ecm.setMaskSize(d_size);
709 
710  // Check to ensure that d_nb_mask > 0
711  if (d_nb_mask == 0)
712  throw(vpException(vpException::badValue, "Model-based tracker mask size "
713  "parameter should be different "
714  "from zero in xml file"));
715  m_ecm.setMaskNumber(d_nb_mask);
716 
717  if (!size_node)
718  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
719  else
720  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
721 
722  if (!nb_mask_node)
723  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
724  else
725  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
726  }
727 
733  void read_ecm_range(const pugi::xml_node &node)
734  {
735  bool tracking_node = false;
736 
737  // current data values.
738  unsigned int m_range_tracking = m_ecm.getRange();
739 
740  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
741  if (dataNode.type() == pugi::node_element) {
742  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
743  if (iter_data != m_nodeMap.end()) {
744  switch (iter_data->second) {
745  case tracking:
746  m_range_tracking = dataNode.text().as_uint();
747  tracking_node = true;
748  break;
749 
750  default:
751  break;
752  }
753  }
754  }
755  }
756 
757  m_ecm.setRange(m_range_tracking);
758 
759  if (!tracking_node)
760  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
761  else
762  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << std::endl;
763  }
764 
770  void read_ecm_sample(const pugi::xml_node &node)
771  {
772  bool step_node = false;
773 
774  // current data values.
775  double d_stp = m_ecm.getSampleStep();
776 
777  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
778  if (dataNode.type() == pugi::node_element) {
779  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
780  if (iter_data != m_nodeMap.end()) {
781  switch (iter_data->second) {
782  case step:
783  d_stp = dataNode.text().as_int();
784  step_node = true;
785  break;
786 
787  default:
788  break;
789  }
790  }
791  }
792  }
793 
794  m_ecm.setSampleStep(d_stp);
795 
796  if (!step_node)
797  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
798  else
799  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
800  }
801 
807  void read_face(const pugi::xml_node &node)
808  {
809  bool angle_appear_node = false;
810  bool angle_disappear_node = false;
811  bool near_clipping_node = false;
812  bool far_clipping_node = false;
813  bool fov_clipping_node = false;
814  m_hasNearClipping = false;
815  m_hasFarClipping = false;
816 
817  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
818  if (dataNode.type() == pugi::node_element) {
819  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
820  if (iter_data != m_nodeMap.end()) {
821  switch (iter_data->second) {
822  case angle_appear:
823  m_angleAppear = dataNode.text().as_double();
824  angle_appear_node = true;
825  break;
826 
827  case angle_disappear:
828  m_angleDisappear = dataNode.text().as_double();
829  angle_disappear_node = true;
830  break;
831 
832  case near_clipping:
833  m_nearClipping = dataNode.text().as_double();
834  m_hasNearClipping = true;
835  near_clipping_node = true;
836  break;
837 
838  case far_clipping:
839  m_farClipping = dataNode.text().as_double();
840  m_hasFarClipping = true;
841  far_clipping_node = true;
842  break;
843 
844  case fov_clipping:
845  if (dataNode.text().as_int())
846  m_fovClipping = true;
847  else
848  m_fovClipping = false;
849  fov_clipping_node = true;
850  break;
851 
852  default:
853  break;
854  }
855  }
856  }
857  }
858 
859  if (!angle_appear_node)
860  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
861  else
862  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
863 
864  if (!angle_disappear_node)
865  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
866  else
867  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
868 
869  if (near_clipping_node)
870  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
871 
872  if (far_clipping_node)
873  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
874 
875  if (fov_clipping_node) {
876  if (m_fovClipping)
877  std::cout << "face : Fov Clipping : True" << std::endl;
878  else
879  std::cout << "face : Fov Clipping : False" << std::endl;
880  }
881  }
882 
888  void read_klt(const pugi::xml_node &node)
889  {
890  bool mask_border_node = false;
891  bool max_features_node = false;
892  bool window_size_node = false;
893  bool quality_node = false;
894  bool min_distance_node = false;
895  bool harris_node = false;
896  bool size_block_node = false;
897  bool pyramid_lvl_node = false;
898 
899  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
900  if (dataNode.type() == pugi::node_element) {
901  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
902  if (iter_data != m_nodeMap.end()) {
903  switch (iter_data->second) {
904  case mask_border:
905  m_kltMaskBorder = dataNode.text().as_uint();
906  mask_border_node = true;
907  break;
908 
909  case max_features:
910  m_kltMaxFeatures = dataNode.text().as_uint();
911  max_features_node = true;
912  break;
913 
914  case window_size:
915  m_kltWinSize = dataNode.text().as_uint();
916  window_size_node = true;
917  break;
918 
919  case quality:
920  m_kltQualityValue = dataNode.text().as_double();
921  quality_node = true;
922  break;
923 
924  case min_distance:
925  m_kltMinDist = dataNode.text().as_double();
926  min_distance_node = true;
927  break;
928 
929  case harris:
930  m_kltHarrisParam = dataNode.text().as_double();
931  harris_node = true;
932  break;
933 
934  case size_block:
935  m_kltBlockSize = dataNode.text().as_uint();
936  size_block_node = true;
937  break;
938 
939  case pyramid_lvl:
940  m_kltPyramidLevels = dataNode.text().as_uint();
941  pyramid_lvl_node = true;
942  break;
943 
944  default:
945  break;
946  }
947  }
948  }
949  }
950 
951  if (!mask_border_node)
952  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
953  else
954  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
955 
956  if (!max_features_node)
957  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
958  else
959  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
960 
961  if (!window_size_node)
962  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
963  else
964  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
965 
966  if (!quality_node)
967  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
968  else
969  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
970 
971  if (!min_distance_node)
972  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
973  else
974  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
975 
976  if (!harris_node)
977  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
978  else
979  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
980 
981  if (!size_block_node)
982  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
983  else
984  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
985 
986  if (!pyramid_lvl_node)
987  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
988  else
989  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
990  }
991 
992  void read_lod(const pugi::xml_node &node)
993  {
994  bool use_lod_node = false;
995  bool min_line_length_threshold_node = false;
996  bool min_polygon_area_threshold_node = false;
997 
998  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
999  if (dataNode.type() == pugi::node_element) {
1000  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1001  if (iter_data != m_nodeMap.end()) {
1002  switch (iter_data->second) {
1003  case use_lod:
1004  m_useLod = (dataNode.text().as_int() != 0);
1005  use_lod_node = true;
1006  break;
1007 
1008  case min_line_length_threshold:
1009  m_minLineLengthThreshold = dataNode.text().as_double();
1010  min_line_length_threshold_node = true;
1011  break;
1012 
1013  case min_polygon_area_threshold:
1014  m_minPolygonAreaThreshold = dataNode.text().as_double();
1015  min_polygon_area_threshold_node = true;
1016  break;
1017 
1018  default:
1019  break;
1020  }
1021  }
1022  }
1023  }
1024 
1025  if (!use_lod_node)
1026  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1027  else
1028  std::cout << "lod : use lod : " << m_useLod << std::endl;
1029 
1030  if (!min_line_length_threshold_node)
1031  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1032  else
1033  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1034 
1035  if (!min_polygon_area_threshold_node)
1036  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1037  else
1038  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1039  }
1040 
1041  void read_projection_error(const pugi::xml_node &node)
1042  {
1043  bool step_node = false;
1044  bool kernel_size_node = false;
1045 
1046  // current data values.
1047  double d_stp = m_projectionErrorMe.getSampleStep();
1048  std::string kernel_size_str;
1049 
1050  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1051  if (dataNode.type() == pugi::node_element) {
1052  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1053  if (iter_data != m_nodeMap.end()) {
1054  switch (iter_data->second) {
1055  case projection_error_sample_step:
1056  d_stp = dataNode.text().as_int();
1057  step_node = true;
1058  break;
1059 
1060  case projection_error_kernel_size:
1061  kernel_size_str = dataNode.text().as_string();
1062  kernel_size_node = true;
1063  break;
1064 
1065  default:
1066  break;
1067  }
1068  }
1069  }
1070  }
1071 
1072  m_projectionErrorMe.setSampleStep(d_stp);
1073 
1074  if (kernel_size_str == "3x3") {
1075  m_projectionErrorKernelSize = 1;
1076  } else if (kernel_size_str == "5x5") {
1077  m_projectionErrorKernelSize = 2;
1078  } else if (kernel_size_str == "7x7") {
1079  m_projectionErrorKernelSize = 3;
1080  } else if (kernel_size_str == "9x9") {
1081  m_projectionErrorKernelSize = 4;
1082  } else if (kernel_size_str == "11x11") {
1083  m_projectionErrorKernelSize = 5;
1084  } else if (kernel_size_str == "13x13") {
1085  m_projectionErrorKernelSize = 6;
1086  } else if (kernel_size_str == "15x15") {
1087  m_projectionErrorKernelSize = 7;
1088  } else {
1089  std::cerr << "Unsupported kernel size." << std::endl;
1090  }
1091 
1092  if (!step_node)
1093  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
1094  else
1095  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1096 
1097  if (!kernel_size_node)
1098  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
1099  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
1100  else
1101  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1102  }
1103 
1109  void read_sample_deprecated(const pugi::xml_node &node)
1110  {
1111  bool step_node = false;
1112  // bool nb_sample_node = false;
1113 
1114  // current data values.
1115  double d_stp = m_ecm.getSampleStep();
1116 
1117  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1118  if (dataNode.type() == pugi::node_element) {
1119  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1120  if (iter_data != m_nodeMap.end()) {
1121  switch (iter_data->second) {
1122  case step:
1123  d_stp = dataNode.text().as_int();
1124  step_node = true;
1125  break;
1126 
1127  default:
1128  break;
1129  }
1130  }
1131  }
1132  }
1133 
1134  m_ecm.setSampleStep(d_stp);
1135 
1136  if (!step_node)
1137  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1138  else
1139  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1140 
1141  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1142  std::cout << " It should be moved in the ecm node (ecm : sample)." << std::endl;
1143  }
1144 
1145  double getAngleAppear() const { return m_angleAppear; }
1146  double getAngleDisappear() const { return m_angleDisappear; }
1147 
1148  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1149 
1150  void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1151 
1152  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1153  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1154 
1156  {
1157  return m_depthNormalFeatureEstimationMethod;
1158  }
1159  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1161  {
1162  return m_depthNormalPclPlaneEstimationRansacMaxIter;
1163  }
1165  {
1166  return m_depthNormalPclPlaneEstimationRansacThreshold;
1167  }
1168  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1169  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1170 
1171  double getFarClippingDistance() const { return m_farClipping; }
1172  bool getFovClipping() const { return m_fovClipping; }
1173 
1174  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1175  double getKltHarrisParam() const { return m_kltHarrisParam; }
1176  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1177  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1178  double getKltMinDistance() const { return m_kltMinDist; }
1179  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1180  double getKltQuality() const { return m_kltQualityValue; }
1181  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1182 
1183  bool getLodState() const { return m_useLod; }
1184  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1185  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1186 
1187  double getNearClippingDistance() const { return m_nearClipping; }
1188 
1189  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1190  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1191 
1192  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1193  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1194 
1195  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1196  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1197 
1198  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1199 
1200  void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1201  void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1203  {
1204  m_depthNormalFeatureEstimationMethod = method;
1205  }
1207  {
1208  m_depthNormalPclPlaneEstimationMethod = method;
1209  }
1211  {
1212  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1213  }
1215  {
1216  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1217  }
1218  void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1219  void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1220 
1221  void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1222 
1223  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1224 
1225  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1226  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1227  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1228  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1229  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1230  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1231  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1232  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1233 
1234  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1235 
1236  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1237  void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1238 
1239 protected:
1241  int m_parserType;
1243  vpCameraParameters m_cam;
1245  double m_angleAppear;
1247  double m_angleDisappear;
1249  bool m_hasNearClipping;
1251  double m_nearClipping;
1253  bool m_hasFarClipping;
1255  double m_farClipping;
1257  bool m_fovClipping;
1258  // LOD
1260  bool m_useLod;
1262  double m_minLineLengthThreshold;
1264  double m_minPolygonAreaThreshold;
1265  // Edge
1267  vpMe m_ecm;
1268  // KLT
1270  unsigned int m_kltMaskBorder;
1272  unsigned int m_kltMaxFeatures;
1274  unsigned int m_kltWinSize;
1276  double m_kltQualityValue;
1278  double m_kltMinDist;
1280  double m_kltHarrisParam;
1282  unsigned int m_kltBlockSize;
1284  unsigned int m_kltPyramidLevels;
1285  // Depth normal
1287  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1289  int m_depthNormalPclPlaneEstimationMethod;
1291  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1293  double m_depthNormalPclPlaneEstimationRansacThreshold;
1295  unsigned int m_depthNormalSamplingStepX;
1297  unsigned int m_depthNormalSamplingStepY;
1298  // Depth dense
1300  unsigned int m_depthDenseSamplingStepX;
1302  unsigned int m_depthDenseSamplingStepY;
1303  // Projection error
1305  vpMe m_projectionErrorMe;
1307  unsigned int m_projectionErrorKernelSize;
1308  std::map<std::string, int> m_nodeMap;
1309 
1310  enum vpDataToParseMb {
1311  //<conf>
1312  conf,
1313  //<face>
1314  face,
1315  angle_appear,
1316  angle_disappear,
1317  near_clipping,
1318  far_clipping,
1319  fov_clipping,
1320  //<camera>
1321  camera,
1322  height,
1323  width,
1324  u0,
1325  v0,
1326  px,
1327  py,
1328  lod,
1329  use_lod,
1330  min_line_length_threshold,
1331  min_polygon_area_threshold,
1332  //<ecm>
1333  ecm,
1334  mask,
1335  size,
1336  nb_mask,
1337  range,
1338  tracking,
1339  contrast,
1340  edge_threshold,
1341  mu1,
1342  mu2,
1343  sample,
1344  step,
1345  //<klt>
1346  klt,
1347  mask_border,
1348  max_features,
1349  window_size,
1350  quality,
1351  min_distance,
1352  harris,
1353  size_block,
1354  pyramid_lvl,
1355  //<depth_normal>
1356  depth_normal,
1357  feature_estimation_method,
1358  PCL_plane_estimation,
1359  PCL_plane_estimation_method,
1360  PCL_plane_estimation_ransac_max_iter,
1361  PCL_plane_estimation_ransac_threshold,
1362  depth_sampling_step,
1363  depth_sampling_step_X,
1364  depth_sampling_step_Y,
1365  //<depth_dense>
1366  depth_dense,
1367  depth_dense_sampling_step,
1368  depth_dense_sampling_step_X,
1369  depth_dense_sampling_step_Y,
1370  //<projection_error>
1371  projection_error,
1372  projection_error_sample_step,
1373  projection_error_kernel_size
1374  };
1375 
1379  void init()
1380  {
1381  //<conf>
1382  m_nodeMap["conf"] = conf;
1383  //<face>
1384  m_nodeMap["face"] = face;
1385  m_nodeMap["angle_appear"] = angle_appear;
1386  m_nodeMap["angle_disappear"] = angle_disappear;
1387  m_nodeMap["near_clipping"] = near_clipping;
1388  m_nodeMap["far_clipping"] = far_clipping;
1389  m_nodeMap["fov_clipping"] = fov_clipping;
1390  //<camera>
1391  m_nodeMap["camera"] = camera;
1392  m_nodeMap["height"] = height;
1393  m_nodeMap["width"] = width;
1394  m_nodeMap["u0"] = u0;
1395  m_nodeMap["v0"] = v0;
1396  m_nodeMap["px"] = px;
1397  m_nodeMap["py"] = py;
1398  //<lod>
1399  m_nodeMap["lod"] = lod;
1400  m_nodeMap["use_lod"] = use_lod;
1401  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1402  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1403  //<ecm>
1404  m_nodeMap["ecm"] = ecm;
1405  m_nodeMap["mask"] = mask;
1406  m_nodeMap["size"] = size;
1407  m_nodeMap["nb_mask"] = nb_mask;
1408  m_nodeMap["range"] = range;
1409  m_nodeMap["tracking"] = tracking;
1410  m_nodeMap["contrast"] = contrast;
1411  m_nodeMap["edge_threshold"] = edge_threshold;
1412  m_nodeMap["mu1"] = mu1;
1413  m_nodeMap["mu2"] = mu2;
1414  m_nodeMap["sample"] = sample;
1415  m_nodeMap["step"] = step;
1416  //<klt>
1417  m_nodeMap["klt"] = klt;
1418  m_nodeMap["mask_border"] = mask_border;
1419  m_nodeMap["max_features"] = max_features;
1420  m_nodeMap["window_size"] = window_size;
1421  m_nodeMap["quality"] = quality;
1422  m_nodeMap["min_distance"] = min_distance;
1423  m_nodeMap["harris"] = harris;
1424  m_nodeMap["size_block"] = size_block;
1425  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1426  //<depth_normal>
1427  m_nodeMap["depth_normal"] = depth_normal;
1428  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1429  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1430  m_nodeMap["method"] = PCL_plane_estimation_method;
1431  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1432  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1433  m_nodeMap["sampling_step"] = depth_sampling_step;
1434  m_nodeMap["step_X"] = depth_sampling_step_X;
1435  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1436  //<depth_dense>
1437  m_nodeMap["depth_dense"] = depth_dense;
1438  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1439  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1440  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1441  //<projection_error>
1442  m_nodeMap["projection_error"] = projection_error;
1443  m_nodeMap["sample_step"] = projection_error_sample_step;
1444  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1445  }
1446 };
1447 #endif // DOXYGEN_SHOULD_SKIP_THIS
1448 
1449 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1450 {
1451  //https://pugixml.org/docs/manual.html#access.attrdata
1452  //https://en.cppreference.com/w/cpp/locale/setlocale
1453  //When called from Java binding, the locale seems to be changed to the default system locale
1454  //It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
1455  if (std::setlocale(LC_ALL, "C") == NULL) {
1456  std::cerr << "Cannot set locale to C" << std::endl;
1457  }
1458 }
1459 
1461 {
1462  delete m_impl;
1463 }
1464 
1470 void vpMbtXmlGenericParser::parse(const std::string &filename)
1471 {
1472  m_impl->parse(filename);
1473 }
1474 
1479 {
1480  return m_impl->getAngleAppear();
1481 }
1482 
1487 {
1488  return m_impl->getAngleDisappear();
1489 }
1490 
1492 {
1493  m_impl->getCameraParameters(cam);
1494 }
1495 
1500 {
1501  m_impl->getEdgeMe(ecm);
1502 }
1503 
1508 {
1509  return m_impl->getDepthDenseSamplingStepX();
1510 }
1511 
1516 {
1517  return m_impl->getDepthDenseSamplingStepY();
1518 }
1519 
1524 {
1525  return m_impl->getDepthNormalFeatureEstimationMethod();
1526 }
1527 
1532 {
1533  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1534 }
1535 
1540 {
1541  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1542 }
1543 
1548 {
1549  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1550 }
1551 
1556 {
1557  return m_impl->getDepthNormalSamplingStepX();
1558 }
1559 
1564 {
1565  return m_impl->getDepthNormalSamplingStepY();
1566 }
1567 
1572 {
1573  return m_impl->getFarClippingDistance();
1574 }
1575 
1580 {
1581  return m_impl->getFovClipping();
1582 }
1583 
1588 {
1589  return m_impl->getKltBlockSize();
1590 }
1591 
1596 {
1597  return m_impl->getKltHarrisParam();
1598 }
1599 
1604 {
1605  return m_impl->getKltMaskBorder();
1606 }
1607 
1612 {
1613  return m_impl->getKltMaxFeatures();
1614 }
1615 
1620 {
1621  return m_impl->getKltMinDistance();
1622 }
1623 
1628 {
1629  return m_impl->getKltPyramidLevels();
1630 }
1631 
1636 {
1637  return m_impl->getKltQuality();
1638 }
1639 
1644 {
1645  return m_impl->getKltWindowSize();
1646 }
1647 
1652 {
1653  return m_impl->getLodState();
1654 }
1655 
1660 {
1661  return m_impl->getLodMinLineLengthThreshold();
1662 }
1663 
1668 {
1669  return m_impl->getLodMinPolygonAreaThreshold();
1670 }
1671 
1676 {
1677  return m_impl->getNearClippingDistance();
1678 }
1679 
1684 {
1685  m_impl->getProjectionErrorMe(me);
1686 }
1687 
1689 {
1690  return m_impl->getProjectionErrorKernelSize();
1691 }
1692 
1699 {
1700  return m_impl->hasFarClippingDistance();
1701 }
1702 
1709 {
1710  return m_impl->hasNearClippingDistance();
1711 }
1712 
1718 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear)
1719 {
1720  m_impl->setAngleAppear(aappear);
1721 }
1722 
1728 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear)
1729 {
1730  m_impl->setAngleDisappear(adisappear);
1731 }
1732 
1739 {
1740  m_impl->setCameraParameters(cam);
1741 }
1742 
1749 {
1750  m_impl->setDepthDenseSamplingStepX(stepX);
1751 }
1752 
1759 {
1760  m_impl->setDepthDenseSamplingStepY(stepY);
1761 }
1762 
1769 {
1770  m_impl->setDepthNormalFeatureEstimationMethod(method);
1771 }
1772 
1779 {
1780  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1781 }
1782 
1789 {
1790  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1791 }
1792 
1799 {
1800  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1801 }
1802 
1809 {
1810  m_impl->setDepthNormalSamplingStepX(stepX);
1811 }
1812 
1819 {
1820  m_impl->setDepthNormalSamplingStepY(stepY);
1821 }
1822 
1829 {
1830  m_impl->setEdgeMe(ecm);
1831 }
1832 
1839 {
1840  m_impl->setFarClippingDistance(fclip);
1841 }
1842 
1848 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs)
1849 {
1850  m_impl->setKltBlockSize(bs);
1851 }
1852 
1859 {
1860  m_impl->setKltHarrisParam(hp);
1861 }
1862 
1868 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb)
1869 {
1870  m_impl->setKltMaskBorder(mb);
1871 }
1872 
1878 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF)
1879 {
1880  m_impl->setKltMaxFeatures(mF);
1881 }
1882 
1889 {
1890  m_impl->setKltMinDistance(mD);
1891 }
1892 
1899 {
1900  m_impl->setKltPyramidLevels(pL);
1901 }
1902 
1909 {
1910  m_impl->setKltQuality(q);
1911 }
1912 
1918 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w)
1919 {
1920  m_impl->setKltWindowSize(w);
1921 }
1922 
1929 {
1930  m_impl->setNearClippingDistance(nclip);
1931 }
1932 
1939 {
1940  m_impl->setProjectionErrorMe(me);
1941 }
1942 
1949 {
1950  m_impl->setProjectionErrorKernelSize(size);
1951 }
1952 
1953 #elif !defined(VISP_BUILD_SHARED_LIBS)
1954 // Work arround to avoid warning: libvisp_mbt.a(vpMbtXmlGenericParser.cpp.o)
1955 // has no symbols
1956 void dummy_vpMbtXmlGenericParser(){};
1957 #endif
unsigned int getDepthNormalSamplingStepY() const
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
int getDepthNormalPclPlaneEstimationMethod() const
void setKltQuality(const double &q)
void parse(const std::string &filename)
void getCameraParameters(vpCameraParameters &cam) const
void setKltPyramidLevels(const unsigned int &pL)
void setDepthNormalSamplingStepY(unsigned int stepY)
void setProjectionErrorKernelSize(const unsigned int &size)
double getDepthNormalPclPlaneEstimationRansacThreshold() const
error that can be emited by ViSP classes.
Definition: vpException.h:71
Definition: vpMe.h:60
vpMbtXmlGenericParser(int type=EDGE_PARSER)
unsigned int getKltBlockSize() const
void setKltMaskBorder(const unsigned int &mb)
void setEdgeMe(const vpMe &ecm)
unsigned int getDepthDenseSamplingStepY() const
void setKltHarrisParam(const double &hp)
void setAngleDisappear(const double &adisappear)
void setKltMinDistance(const double &mD)
void setProjectionErrorMe(const vpMe &me)
void setDepthNormalSamplingStepX(unsigned int stepX)
Generic class defining intrinsic camera parameters.
unsigned int getKltWindowSize() const
unsigned int getKltMaxFeatures() const
void setDepthDenseSamplingStepY(unsigned int stepY)
unsigned int getDepthNormalSamplingStepX() const
void setKltWindowSize(const unsigned int &w)
void setAngleAppear(const double &aappear)
void setDepthDenseSamplingStepX(unsigned int stepX)
void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter)
void getEdgeMe(vpMe &ecm) const
double getLodMinLineLengthThreshold() const
void setNearClippingDistance(const double &nclip)
unsigned int getDepthDenseSamplingStepX() const
void setFarClippingDistance(const double &fclip)
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
unsigned int getKltMaskBorder() const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
unsigned int getProjectionErrorKernelSize() const
void setKltBlockSize(const unsigned int &bs)
void setKltMaxFeatures(const unsigned int &mF)
void setCameraParameters(const vpCameraParameters &cam)
void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
void setDepthNormalPclPlaneEstimationMethod(int method)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
double getLodMinPolygonAreaThreshold() const
void getProjectionErrorMe(vpMe &me) const
unsigned int getKltPyramidLevels() const