Visual Servoing Platform  version 3.2.1 under development (2019-08-08)
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 
42 #include <visp3/mbt/vpMbtXmlGenericParser.h>
43 
44 #include <pugixml.hpp>
45 
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 class vpMbtXmlGenericParser::Impl
48 {
49 public:
50  Impl(int type = EDGE_PARSER) :
51  m_parserType(type),
52  //<camera>
53  m_cam(),
54  //<face>
55  m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
56  m_farClipping(false), m_fovClipping(false),
57  //<lod>
58  m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
59  //<ecm>
60  m_ecm(),
61  //<klt>
62  m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
63  m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
64  //<depth_normal>
65  m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
66  m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
67  m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2), 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()
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_parserType == PROJECTION_ERROR_PARSER) {
168  if (!projection_error_node) {
169  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
170  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
171  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
172  }
173  } else {
174  if (!camera_node) {
175  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
176  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
177  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
178  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
179  }
180 
181  if (!face_node) {
182  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
183  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
184  }
185 
186  if (!lod_node) {
187  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
188  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
189  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
190  }
191 
192  if (!ecm_node && (m_parserType & EDGE_PARSER)) {
193  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
194  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
195  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
196  std::cout << "ecm : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
197  std::cout << "ecm : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
198  std::cout << "ecm : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
199  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
200  }
201 
202  if (!klt_node && (m_parserType & KLT_PARSER)) {
203  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
204  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
205  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
206  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
207  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
208  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
209  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
210  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
211  }
212 
213  if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
214  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
215  << std::endl;
216  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
217  << " (default)" << std::endl;
218  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
219  << " (default)" << std::endl;
220  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
221  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
222  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
223  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
224  }
225 
226  if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
227  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
228  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
229  }
230  }
231  }
232 
238  void read_camera(const pugi::xml_node &node)
239  {
240  bool u0_node = false;
241  bool v0_node = false;
242  bool px_node = false;
243  bool py_node = false;
244 
245  // current data values.
246  double d_u0 = m_cam.get_u0();
247  double d_v0 = m_cam.get_v0();
248  double d_px = m_cam.get_px();
249  double d_py = m_cam.get_py();
250 
251  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
252  if (dataNode.type() == pugi::node_element) {
253  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
254  if (iter_data != m_nodeMap.end()) {
255  switch (iter_data->second) {
256  case u0:
257  d_u0 = dataNode.text().as_double();
258  u0_node = true;
259  break;
260 
261  case v0:
262  d_v0 = dataNode.text().as_double();
263  v0_node = true;
264  break;
265 
266  case px:
267  d_px = dataNode.text().as_double();
268  px_node = true;
269  break;
270 
271  case py:
272  d_py = dataNode.text().as_double();
273  py_node = true;
274  break;
275 
276  default:
277  break;
278  }
279  }
280  }
281  }
282 
283  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
284 
285  if (!u0_node)
286  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
287  else
288  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
289 
290  if (!v0_node)
291  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
292  else
293  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
294 
295  if (!px_node)
296  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
297  else
298  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
299 
300  if (!py_node)
301  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
302  else
303  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
304  }
305 
311  void read_depth_normal(const pugi::xml_node &node)
312  {
313  bool feature_estimation_method_node = false;
314  bool PCL_plane_estimation_node = false;
315  bool sampling_step_node = false;
316 
317  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
318  if (dataNode.type() == pugi::node_element) {
319  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
320  if (iter_data != m_nodeMap.end()) {
321  switch (iter_data->second) {
322  case feature_estimation_method:
323  m_depthNormalFeatureEstimationMethod =
324  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
325  feature_estimation_method_node = true;
326  break;
327 
328  case PCL_plane_estimation:
329  read_depth_normal_PCL(dataNode);
330  PCL_plane_estimation_node = true;
331  break;
332 
333  case depth_sampling_step:
334  read_depth_normal_sampling_step(dataNode);
335  sampling_step_node = true;
336  break;
337 
338  default:
339  break;
340  }
341  }
342  }
343  }
344 
345  if (!feature_estimation_method_node)
346  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
347  << std::endl;
348  else
349  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
350 
351  if (!PCL_plane_estimation_node) {
352  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
353  << " (default)" << std::endl;
354  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
355  << " (default)" << std::endl;
356  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
357  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
358  }
359 
360  if (!sampling_step_node) {
361  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
362  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
363  }
364  }
365 
371  void read_depth_normal_PCL(const pugi::xml_node &node)
372  {
373  bool PCL_plane_estimation_method_node = false;
374  bool PCL_plane_estimation_ransac_max_iter_node = false;
375  bool PCL_plane_estimation_ransac_threshold_node = false;
376 
377  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
378  if (dataNode.type() == pugi::node_element) {
379  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
380  if (iter_data != m_nodeMap.end()) {
381  switch (iter_data->second) {
382  case PCL_plane_estimation_method:
383  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
384  PCL_plane_estimation_method_node = true;
385  break;
386 
387  case PCL_plane_estimation_ransac_max_iter:
388  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
389  PCL_plane_estimation_ransac_max_iter_node = true;
390  break;
391 
392  case PCL_plane_estimation_ransac_threshold:
393  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
394  PCL_plane_estimation_ransac_threshold_node = true;
395  break;
396 
397  default:
398  break;
399  }
400  }
401  }
402  }
403 
404  if (!PCL_plane_estimation_method_node)
405  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
406  << " (default)" << std::endl;
407  else
408  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
409  << std::endl;
410 
411  if (!PCL_plane_estimation_ransac_max_iter_node)
412  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
413  << " (default)" << std::endl;
414  else
415  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
416  << std::endl;
417 
418  if (!PCL_plane_estimation_ransac_threshold_node)
419  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
420  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
421  else
422  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
423  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
424  }
425 
431  void read_depth_normal_sampling_step(const pugi::xml_node &node)
432  {
433  bool sampling_step_X_node = false;
434  bool sampling_step_Y_node = false;
435 
436  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
437  if (dataNode.type() == pugi::node_element) {
438  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
439  if (iter_data != m_nodeMap.end()) {
440  switch (iter_data->second) {
441  case depth_sampling_step_X:
442  m_depthNormalSamplingStepX = dataNode.text().as_uint();
443  sampling_step_X_node = true;
444  break;
445 
446  case depth_sampling_step_Y:
447  m_depthNormalSamplingStepY = dataNode.text().as_uint();
448  sampling_step_Y_node = true;
449  break;
450 
451  default:
452  break;
453  }
454  }
455  }
456  }
457 
458  if (!sampling_step_X_node)
459  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)" << std::endl;
460  else
461  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
462 
463  if (!sampling_step_Y_node)
464  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)" << std::endl;
465  else
466  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
467  }
468 
474  void read_depth_dense(const pugi::xml_node &node)
475  {
476  bool sampling_step_node = false;
477 
478  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
479  if (dataNode.type() == pugi::node_element) {
480  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
481  if (iter_data != m_nodeMap.end()) {
482  switch (iter_data->second) {
483  case depth_dense_sampling_step:
484  read_depth_dense_sampling_step(dataNode);
485  sampling_step_node = true;
486  break;
487 
488  default:
489  break;
490  }
491  }
492  }
493  }
494 
495  if (!sampling_step_node) {
496  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
497  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
498  }
499  }
500 
506  void read_depth_dense_sampling_step(const pugi::xml_node &node)
507  {
508  bool sampling_step_X_node = false;
509  bool sampling_step_Y_node = false;
510 
511  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
512  if (dataNode.type() == pugi::node_element) {
513  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
514  if (iter_data != m_nodeMap.end()) {
515  switch (iter_data->second) {
516  case depth_dense_sampling_step_X:
517  m_depthDenseSamplingStepX = dataNode.text().as_uint();
518  sampling_step_X_node = true;
519  break;
520 
521  case depth_dense_sampling_step_Y:
522  m_depthDenseSamplingStepY = dataNode.text().as_uint();
523  sampling_step_Y_node = true;
524  break;
525 
526  default:
527  break;
528  }
529  }
530  }
531  }
532 
533  if (!sampling_step_X_node)
534  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)" << std::endl;
535  else
536  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
537 
538  if (!sampling_step_Y_node)
539  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)" << std::endl;
540  else
541  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
542  }
543 
549  void read_ecm(const pugi::xml_node &node)
550  {
551  bool mask_node = false;
552  bool range_node = false;
553  bool contrast_node = false;
554  bool sample_node = false;
555 
556  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
557  if (dataNode.type() == pugi::node_element) {
558  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
559  if (iter_data != m_nodeMap.end()) {
560  switch (iter_data->second) {
561  case mask:
562  read_ecm_mask(dataNode);
563  mask_node = true;
564  break;
565 
566  case range:
567  read_ecm_range(dataNode);
568  range_node = true;
569  break;
570 
571  case contrast:
572  read_ecm_contrast(dataNode);
573  contrast_node = true;
574  break;
575 
576  case sample:
577  read_ecm_sample(dataNode);
578  sample_node = true;
579  break;
580 
581  default:
582  break;
583  }
584  }
585  }
586  }
587 
588  if (!mask_node) {
589  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
590  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
591  }
592 
593  if (!range_node) {
594  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
595  }
596 
597  if (!contrast_node) {
598  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
599  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
600  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
601  }
602 
603  if (!sample_node) {
604  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
605  }
606  }
607 
613  void read_ecm_contrast(const pugi::xml_node &node)
614  {
615  bool edge_threshold_node = false;
616  bool mu1_node = false;
617  bool mu2_node = false;
618 
619  // current data values.
620  double d_edge_threshold = m_ecm.getThreshold();
621  double d_mu1 = m_ecm.getMu1();
622  double d_mu2 = m_ecm.getMu2();
623 
624  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
625  if (dataNode.type() == pugi::node_element) {
626  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
627  if (iter_data != m_nodeMap.end()) {
628  switch (iter_data->second) {
629  case edge_threshold:
630  d_edge_threshold = dataNode.text().as_double();
631  edge_threshold_node = true;
632  break;
633 
634  case mu1:
635  d_mu1 = dataNode.text().as_double();
636  mu1_node = true;
637  break;
638 
639  case mu2:
640  d_mu2 = dataNode.text().as_double();
641  mu2_node = true;
642  break;
643 
644  default:
645  break;
646  }
647  }
648  }
649  }
650 
651  m_ecm.setMu1(d_mu1);
652  m_ecm.setMu2(d_mu2);
653  m_ecm.setThreshold(d_edge_threshold);
654 
655  if (!edge_threshold_node)
656  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
657  else
658  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
659 
660  if (!mu1_node)
661  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
662  else
663  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
664 
665  if (!mu2_node)
666  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
667  else
668  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
669  }
670 
676  void read_ecm_mask(const pugi::xml_node &node)
677  {
678  bool size_node = false;
679  bool nb_mask_node = false;
680 
681  // current data values.
682  unsigned int d_size = m_ecm.getMaskSize();
683  unsigned int d_nb_mask = m_ecm.getMaskNumber();
684 
685  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
686  if (dataNode.type() == pugi::node_element) {
687  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
688  if (iter_data != m_nodeMap.end()) {
689  switch (iter_data->second) {
690  case size:
691  d_size = dataNode.text().as_uint();
692  size_node = true;
693  break;
694 
695  case nb_mask:
696  d_nb_mask = dataNode.text().as_uint();
697  nb_mask_node = true;
698  break;
699 
700  default:
701  break;
702  }
703  }
704  }
705  }
706 
707  m_ecm.setMaskSize(d_size);
708 
709  // Check to ensure that d_nb_mask > 0
710  if (d_nb_mask == 0)
711  throw(vpException(vpException::badValue, "Model-based tracker mask size "
712  "parameter should be different "
713  "from zero in xml file"));
714  m_ecm.setMaskNumber(d_nb_mask);
715 
716  if (!size_node)
717  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
718  else
719  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
720 
721  if (!nb_mask_node)
722  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
723  else
724  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
725  }
726 
732  void read_ecm_range(const pugi::xml_node &node)
733  {
734  bool tracking_node = false;
735 
736  // current data values.
737  unsigned int m_range_tracking = m_ecm.getRange();
738 
739  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
740  if (dataNode.type() == pugi::node_element) {
741  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
742  if (iter_data != m_nodeMap.end()) {
743  switch (iter_data->second) {
744  case tracking:
745  m_range_tracking = dataNode.text().as_uint();
746  tracking_node = true;
747  break;
748 
749  default:
750  break;
751  }
752  }
753  }
754  }
755 
756  m_ecm.setRange(m_range_tracking);
757 
758  if (!tracking_node)
759  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
760  else
761  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << std::endl;
762  }
763 
769  void read_ecm_sample(const pugi::xml_node &node)
770  {
771  bool step_node = false;
772 
773  // current data values.
774  double d_stp = m_ecm.getSampleStep();
775 
776  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
777  if (dataNode.type() == pugi::node_element) {
778  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
779  if (iter_data != m_nodeMap.end()) {
780  switch (iter_data->second) {
781  case step:
782  d_stp = dataNode.text().as_int();
783  step_node = true;
784  break;
785 
786  default:
787  break;
788  }
789  }
790  }
791  }
792 
793  m_ecm.setSampleStep(d_stp);
794 
795  if (!step_node)
796  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
797  else
798  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
799  }
800 
806  void read_face(const pugi::xml_node &node)
807  {
808  bool angle_appear_node = false;
809  bool angle_disappear_node = false;
810  bool near_clipping_node = false;
811  bool far_clipping_node = false;
812  bool fov_clipping_node = false;
813  m_hasNearClipping = false;
814  m_hasFarClipping = false;
815 
816  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
817  if (dataNode.type() == pugi::node_element) {
818  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
819  if (iter_data != m_nodeMap.end()) {
820  switch (iter_data->second) {
821  case angle_appear:
822  m_angleAppear = dataNode.text().as_double();
823  angle_appear_node = true;
824  break;
825 
826  case angle_disappear:
827  m_angleDisappear = dataNode.text().as_double();
828  angle_disappear_node = true;
829  break;
830 
831  case near_clipping:
832  m_nearClipping = dataNode.text().as_double();
833  m_hasNearClipping = true;
834  near_clipping_node = true;
835  break;
836 
837  case far_clipping:
838  m_farClipping = dataNode.text().as_double();
839  m_hasFarClipping = true;
840  far_clipping_node = true;
841  break;
842 
843  case fov_clipping:
844  if (dataNode.text().as_int())
845  m_fovClipping = true;
846  else
847  m_fovClipping = false;
848  fov_clipping_node = true;
849  break;
850 
851  default:
852  break;
853  }
854  }
855  }
856  }
857 
858  if (!angle_appear_node)
859  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
860  else
861  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
862 
863  if (!angle_disappear_node)
864  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
865  else
866  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
867 
868  if (near_clipping_node)
869  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
870 
871  if (far_clipping_node)
872  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
873 
874  if (fov_clipping_node) {
875  if (m_fovClipping)
876  std::cout << "face : Fov Clipping : True" << std::endl;
877  else
878  std::cout << "face : Fov Clipping : False" << std::endl;
879  }
880  }
881 
887  void read_klt(const pugi::xml_node &node)
888  {
889  bool mask_border_node = false;
890  bool max_features_node = false;
891  bool window_size_node = false;
892  bool quality_node = false;
893  bool min_distance_node = false;
894  bool harris_node = false;
895  bool size_block_node = false;
896  bool pyramid_lvl_node = false;
897 
898  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
899  if (dataNode.type() == pugi::node_element) {
900  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
901  if (iter_data != m_nodeMap.end()) {
902  switch (iter_data->second) {
903  case mask_border:
904  m_kltMaskBorder = dataNode.text().as_uint();
905  mask_border_node = true;
906  break;
907 
908  case max_features:
909  m_kltMaxFeatures = dataNode.text().as_uint();
910  max_features_node = true;
911  break;
912 
913  case window_size:
914  m_kltWinSize = dataNode.text().as_uint();
915  window_size_node = true;
916  break;
917 
918  case quality:
919  m_kltQualityValue = dataNode.text().as_double();
920  quality_node = true;
921  break;
922 
923  case min_distance:
924  m_kltMinDist = dataNode.text().as_double();
925  min_distance_node = true;
926  break;
927 
928  case harris:
929  m_kltHarrisParam = dataNode.text().as_double();
930  harris_node = true;
931  break;
932 
933  case size_block:
934  m_kltBlockSize = dataNode.text().as_uint();
935  size_block_node = true;
936  break;
937 
938  case pyramid_lvl:
939  m_kltPyramidLevels = dataNode.text().as_uint();
940  pyramid_lvl_node = true;
941  break;
942 
943  default:
944  break;
945  }
946  }
947  }
948  }
949 
950  if (!mask_border_node)
951  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
952  else
953  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
954 
955  if (!max_features_node)
956  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
957  else
958  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
959 
960  if (!window_size_node)
961  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
962  else
963  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
964 
965  if (!quality_node)
966  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
967  else
968  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
969 
970  if (!min_distance_node)
971  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
972  else
973  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
974 
975  if (!harris_node)
976  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
977  else
978  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
979 
980  if (!size_block_node)
981  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
982  else
983  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
984 
985  if (!pyramid_lvl_node)
986  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
987  else
988  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
989  }
990 
991  void read_lod(const pugi::xml_node &node)
992  {
993  bool use_lod_node = false;
994  bool min_line_length_threshold_node = false;
995  bool min_polygon_area_threshold_node = false;
996 
997  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
998  if (dataNode.type() == pugi::node_element) {
999  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1000  if (iter_data != m_nodeMap.end()) {
1001  switch (iter_data->second) {
1002  case use_lod:
1003  m_useLod = (dataNode.text().as_int() != 0);
1004  use_lod_node = true;
1005  break;
1006 
1007  case min_line_length_threshold:
1008  m_minLineLengthThreshold = dataNode.text().as_double();
1009  min_line_length_threshold_node = true;
1010  break;
1011 
1012  case min_polygon_area_threshold:
1013  m_minPolygonAreaThreshold = dataNode.text().as_double();
1014  min_polygon_area_threshold_node = true;
1015  break;
1016 
1017  default:
1018  break;
1019  }
1020  }
1021  }
1022  }
1023 
1024  if (!use_lod_node)
1025  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1026  else
1027  std::cout << "lod : use lod : " << m_useLod << std::endl;
1028 
1029  if (!min_line_length_threshold_node)
1030  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1031  else
1032  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1033 
1034  if (!min_polygon_area_threshold_node)
1035  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1036  else
1037  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1038  }
1039 
1040  void read_projection_error(const pugi::xml_node &node)
1041  {
1042  bool step_node = false;
1043  bool kernel_size_node = false;
1044 
1045  // current data values.
1046  double d_stp = m_projectionErrorMe.getSampleStep();
1047  std::string kernel_size_str;
1048 
1049  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1050  if (dataNode.type() == pugi::node_element) {
1051  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1052  if (iter_data != m_nodeMap.end()) {
1053  switch (iter_data->second) {
1054  case projection_error_sample_step:
1055  d_stp = dataNode.text().as_int();
1056  step_node = true;
1057  break;
1058 
1059  case projection_error_kernel_size:
1060  kernel_size_str = dataNode.text().as_string();
1061  kernel_size_node = true;
1062  break;
1063 
1064  default:
1065  break;
1066  }
1067  }
1068  }
1069  }
1070 
1071  m_projectionErrorMe.setSampleStep(d_stp);
1072 
1073  if (kernel_size_str == "3x3") {
1074  m_projectionErrorKernelSize = 1;
1075  } else if (kernel_size_str == "5x5") {
1076  m_projectionErrorKernelSize = 2;
1077  } else if (kernel_size_str == "7x7") {
1078  m_projectionErrorKernelSize = 3;
1079  } else if (kernel_size_str == "9x9") {
1080  m_projectionErrorKernelSize = 4;
1081  } else if (kernel_size_str == "11x11") {
1082  m_projectionErrorKernelSize = 5;
1083  } else if (kernel_size_str == "13x13") {
1084  m_projectionErrorKernelSize = 6;
1085  } else if (kernel_size_str == "15x15") {
1086  m_projectionErrorKernelSize = 7;
1087  } else {
1088  std::cerr << "Unsupported kernel size." << std::endl;
1089  }
1090 
1091  if (!step_node)
1092  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
1093  else
1094  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1095 
1096  if (!kernel_size_node)
1097  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
1098  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
1099  else
1100  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1101  }
1102 
1108  void read_sample_deprecated(const pugi::xml_node &node)
1109  {
1110  bool step_node = false;
1111  // bool nb_sample_node = false;
1112 
1113  // current data values.
1114  double d_stp = m_ecm.getSampleStep();
1115 
1116  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1117  if (dataNode.type() == pugi::node_element) {
1118  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1119  if (iter_data != m_nodeMap.end()) {
1120  switch (iter_data->second) {
1121  case step:
1122  d_stp = dataNode.text().as_int();
1123  step_node = true;
1124  break;
1125 
1126  default:
1127  break;
1128  }
1129  }
1130  }
1131  }
1132 
1133  m_ecm.setSampleStep(d_stp);
1134 
1135  if (!step_node)
1136  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1137  else
1138  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1139 
1140  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1141  std::cout << " It should be moved in the ecm node (ecm : sample)." << std::endl;
1142  }
1143 
1144  double getAngleAppear() const { return m_angleAppear; }
1145  double getAngleDisappear() const { return m_angleDisappear; }
1146 
1147  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1148 
1149  void getEdgeMe(vpMe &ecm) const { ecm = m_ecm; }
1150 
1151  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1152  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1153 
1155  {
1156  return m_depthNormalFeatureEstimationMethod;
1157  }
1158  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1160  {
1161  return m_depthNormalPclPlaneEstimationRansacMaxIter;
1162  }
1164  {
1165  return m_depthNormalPclPlaneEstimationRansacThreshold;
1166  }
1167  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1168  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1169 
1170  double getFarClippingDistance() const { return m_farClipping; }
1171  bool getFovClipping() const { return m_fovClipping; }
1172 
1173  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1174  double getKltHarrisParam() const { return m_kltHarrisParam; }
1175  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1176  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1177  double getKltMinDistance() const { return m_kltMinDist; }
1178  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1179  double getKltQuality() const { return m_kltQualityValue; }
1180  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1181 
1182  bool getLodState() const { return m_useLod; }
1183  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1184  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1185 
1186  double getNearClippingDistance() const { return m_nearClipping; }
1187 
1188  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1189  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1190 
1191  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1192  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1193 
1194  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1195  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1196 
1197  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1198 
1199  void setDepthDenseSamplingStepX(const unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1200  void setDepthDenseSamplingStepY(const unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1202  {
1203  m_depthNormalFeatureEstimationMethod = method;
1204  }
1205  void setDepthNormalPclPlaneEstimationMethod(const int method)
1206  {
1207  m_depthNormalPclPlaneEstimationMethod = method;
1208  }
1209  void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
1210  {
1211  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1212  }
1213  void setDepthNormalPclPlaneEstimationRansacThreshold(const double threshold)
1214  {
1215  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1216  }
1217  void setDepthNormalSamplingStepX(const unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1218  void setDepthNormalSamplingStepY(const unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1219 
1220  void setEdgeMe(const vpMe &ecm) { m_ecm = ecm; }
1221 
1222  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1223 
1224  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1225  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1226  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1227  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1228  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1229  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1230  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1231  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1232 
1233  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1234 
1235  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1236  void setProjectionErrorKernelSize(const unsigned int &size) { m_projectionErrorKernelSize = size; }
1237 
1238 protected:
1240  int m_parserType;
1242  vpCameraParameters m_cam;
1244  double m_angleAppear;
1246  double m_angleDisappear;
1248  bool m_hasNearClipping;
1250  double m_nearClipping;
1252  bool m_hasFarClipping;
1254  double m_farClipping;
1256  bool m_fovClipping;
1257  // LOD
1259  bool m_useLod;
1261  double m_minLineLengthThreshold;
1263  double m_minPolygonAreaThreshold;
1264  // Edge
1266  vpMe m_ecm;
1267  // KLT
1269  unsigned int m_kltMaskBorder;
1271  unsigned int m_kltMaxFeatures;
1273  unsigned int m_kltWinSize;
1275  double m_kltQualityValue;
1277  double m_kltMinDist;
1279  double m_kltHarrisParam;
1281  unsigned int m_kltBlockSize;
1283  unsigned int m_kltPyramidLevels;
1284  // Depth normal
1286  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1288  int m_depthNormalPclPlaneEstimationMethod;
1290  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1292  double m_depthNormalPclPlaneEstimationRansacThreshold;
1294  unsigned int m_depthNormalSamplingStepX;
1296  unsigned int m_depthNormalSamplingStepY;
1297  // Depth dense
1299  unsigned int m_depthDenseSamplingStepX;
1301  unsigned int m_depthDenseSamplingStepY;
1302  // Projection error
1304  vpMe m_projectionErrorMe;
1306  unsigned int m_projectionErrorKernelSize;
1307  std::map<std::string, int> m_nodeMap;
1308 
1309  enum vpDataToParseMb {
1310  //<conf>
1311  conf,
1312  //<face>
1313  face,
1314  angle_appear,
1315  angle_disappear,
1316  near_clipping,
1317  far_clipping,
1318  fov_clipping,
1319  //<camera>
1320  camera,
1321  height,
1322  width,
1323  u0,
1324  v0,
1325  px,
1326  py,
1327  lod,
1328  use_lod,
1329  min_line_length_threshold,
1330  min_polygon_area_threshold,
1331  //<ecm>
1332  ecm,
1333  mask,
1334  size,
1335  nb_mask,
1336  range,
1337  tracking,
1338  contrast,
1339  edge_threshold,
1340  mu1,
1341  mu2,
1342  sample,
1343  step,
1344  //<klt>
1345  klt,
1346  mask_border,
1347  max_features,
1348  window_size,
1349  quality,
1350  min_distance,
1351  harris,
1352  size_block,
1353  pyramid_lvl,
1354  //<depth_normal>
1355  depth_normal,
1356  feature_estimation_method,
1357  PCL_plane_estimation,
1358  PCL_plane_estimation_method,
1359  PCL_plane_estimation_ransac_max_iter,
1360  PCL_plane_estimation_ransac_threshold,
1361  depth_sampling_step,
1362  depth_sampling_step_X,
1363  depth_sampling_step_Y,
1364  //<depth_dense>
1365  depth_dense,
1366  depth_dense_sampling_step,
1367  depth_dense_sampling_step_X,
1368  depth_dense_sampling_step_Y,
1369  //<projection_error>
1370  projection_error,
1371  projection_error_sample_step,
1372  projection_error_kernel_size
1373  };
1374 
1378  void init()
1379  {
1380  //<conf>
1381  m_nodeMap["conf"] = conf;
1382  //<face>
1383  m_nodeMap["face"] = face;
1384  m_nodeMap["angle_appear"] = angle_appear;
1385  m_nodeMap["angle_disappear"] = angle_disappear;
1386  m_nodeMap["near_clipping"] = near_clipping;
1387  m_nodeMap["far_clipping"] = far_clipping;
1388  m_nodeMap["fov_clipping"] = fov_clipping;
1389  //<camera>
1390  m_nodeMap["camera"] = camera;
1391  m_nodeMap["height"] = height;
1392  m_nodeMap["width"] = width;
1393  m_nodeMap["u0"] = u0;
1394  m_nodeMap["v0"] = v0;
1395  m_nodeMap["px"] = px;
1396  m_nodeMap["py"] = py;
1397  //<lod>
1398  m_nodeMap["lod"] = lod;
1399  m_nodeMap["use_lod"] = use_lod;
1400  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1401  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1402  //<ecm>
1403  m_nodeMap["ecm"] = ecm;
1404  m_nodeMap["mask"] = mask;
1405  m_nodeMap["size"] = size;
1406  m_nodeMap["nb_mask"] = nb_mask;
1407  m_nodeMap["range"] = range;
1408  m_nodeMap["tracking"] = tracking;
1409  m_nodeMap["contrast"] = contrast;
1410  m_nodeMap["edge_threshold"] = edge_threshold;
1411  m_nodeMap["mu1"] = mu1;
1412  m_nodeMap["mu2"] = mu2;
1413  m_nodeMap["sample"] = sample;
1414  m_nodeMap["step"] = step;
1415  //<klt>
1416  m_nodeMap["klt"] = klt;
1417  m_nodeMap["mask_border"] = mask_border;
1418  m_nodeMap["max_features"] = max_features;
1419  m_nodeMap["window_size"] = window_size;
1420  m_nodeMap["quality"] = quality;
1421  m_nodeMap["min_distance"] = min_distance;
1422  m_nodeMap["harris"] = harris;
1423  m_nodeMap["size_block"] = size_block;
1424  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1425  //<depth_normal>
1426  m_nodeMap["depth_normal"] = depth_normal;
1427  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1428  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1429  m_nodeMap["method"] = PCL_plane_estimation_method;
1430  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1431  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1432  m_nodeMap["sampling_step"] = depth_sampling_step;
1433  m_nodeMap["step_X"] = depth_sampling_step_X;
1434  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1435  //<depth_dense>
1436  m_nodeMap["depth_dense"] = depth_dense;
1437  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1438  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1439  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1440  //<projection_error>
1441  m_nodeMap["projection_error"] = projection_error;
1442  m_nodeMap["sample_step"] = projection_error_sample_step;
1443  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1444  }
1445 };
1446 #endif // DOXYGEN_SHOULD_SKIP_THIS
1447 
1448 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1449 {
1450 }
1451 
1453 {
1454  delete m_impl;
1455 }
1456 
1462 void vpMbtXmlGenericParser::parse(const std::string &filename)
1463 {
1464  m_impl->parse(filename);
1465 }
1466 
1471 {
1472  return m_impl->getAngleAppear();
1473 }
1474 
1479 {
1480  return m_impl->getAngleDisappear();
1481 }
1482 
1484 {
1485  m_impl->getCameraParameters(cam);
1486 }
1487 
1492 {
1493  m_impl->getEdgeMe(ecm);
1494 }
1495 
1500 {
1501  return m_impl->getDepthDenseSamplingStepX();
1502 }
1503 
1508 {
1509  return m_impl->getDepthDenseSamplingStepY();
1510 }
1511 
1516 {
1517  return m_impl->getDepthNormalFeatureEstimationMethod();
1518 }
1519 
1524 {
1525  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1526 }
1527 
1532 {
1533  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1534 }
1535 
1540 {
1541  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1542 }
1543 
1548 {
1549  return m_impl->getDepthNormalSamplingStepX();
1550 }
1551 
1556 {
1557  return m_impl->getDepthNormalSamplingStepY();
1558 }
1559 
1564 {
1565  return m_impl->getFarClippingDistance();
1566 }
1567 
1572 {
1573  return m_impl->getFovClipping();
1574 }
1575 
1580 {
1581  return m_impl->getKltBlockSize();
1582 }
1583 
1588 {
1589  return m_impl->getKltHarrisParam();
1590 }
1591 
1596 {
1597  return m_impl->getKltMaskBorder();
1598 }
1599 
1604 {
1605  return m_impl->getKltMaxFeatures();
1606 }
1607 
1612 {
1613  return m_impl->getKltMinDistance();
1614 }
1615 
1620 {
1621  return m_impl->getKltPyramidLevels();
1622 }
1623 
1628 {
1629  return m_impl->getKltQuality();
1630 }
1631 
1636 {
1637  return m_impl->getKltWindowSize();
1638 }
1639 
1644 {
1645  return m_impl->getLodState();
1646 }
1647 
1652 {
1653  return m_impl->getLodMinLineLengthThreshold();
1654 }
1655 
1660 {
1661  return m_impl->getLodMinPolygonAreaThreshold();
1662 }
1663 
1668 {
1669  return m_impl->getNearClippingDistance();
1670 }
1671 
1676 {
1677  m_impl->getProjectionErrorMe(me);
1678 }
1679 
1681 {
1682  return m_impl->getProjectionErrorKernelSize();
1683 }
1684 
1691 {
1692  return m_impl->hasFarClippingDistance();
1693 }
1694 
1701 {
1702  return m_impl->hasNearClippingDistance();
1703 }
1704 
1710 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear)
1711 {
1712  m_impl->setAngleAppear(aappear);
1713 }
1714 
1720 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear)
1721 {
1722  m_impl->setAngleDisappear(adisappear);
1723 }
1724 
1731 {
1732  m_impl->setCameraParameters(cam);
1733 }
1734 
1741 {
1742  m_impl->setDepthDenseSamplingStepX(stepX);
1743 }
1744 
1751 {
1752  m_impl->setDepthDenseSamplingStepY(stepY);
1753 }
1754 
1761 {
1762  m_impl->setDepthNormalFeatureEstimationMethod(method);
1763 }
1764 
1771 {
1772  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1773 }
1774 
1781 {
1782  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1783 }
1784 
1791 {
1792  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1793 }
1794 
1801 {
1802  m_impl->setDepthNormalSamplingStepX(stepX);
1803 }
1804 
1811 {
1812  m_impl->setDepthNormalSamplingStepY(stepY);
1813 }
1814 
1821 {
1822  m_impl->setEdgeMe(ecm);
1823 }
1824 
1831 {
1832  m_impl->setFarClippingDistance(fclip);
1833 }
1834 
1840 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs)
1841 {
1842  m_impl->setKltBlockSize(bs);
1843 }
1844 
1851 {
1852  m_impl->setKltHarrisParam(hp);
1853 }
1854 
1860 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb)
1861 {
1862  m_impl->setKltMaskBorder(mb);
1863 }
1864 
1870 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF)
1871 {
1872  m_impl->setKltMaxFeatures(mF);
1873 }
1874 
1881 {
1882  m_impl->setKltMinDistance(mD);
1883 }
1884 
1891 {
1892  m_impl->setKltPyramidLevels(pL);
1893 }
1894 
1901 {
1902  m_impl->setKltQuality(q);
1903 }
1904 
1910 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w)
1911 {
1912  m_impl->setKltWindowSize(w);
1913 }
1914 
1921 {
1922  m_impl->setNearClippingDistance(nclip);
1923 }
1924 
1931 {
1932  m_impl->setProjectionErrorMe(me);
1933 }
1934 
1941 {
1942  m_impl->setProjectionErrorKernelSize(size);
1943 }
1944 
1945 #elif !defined(VISP_BUILD_SHARED_LIBS)
1946 // Work arround to avoid warning: libvisp_mbt.a(vpMbtXmlGenericParser.cpp.o)
1947 // has no symbols
1948 void dummy_vpMbtXmlGenericParser(){};
1949 #endif
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
double getFarClippingDistance() const
void setKltQuality(const double &q)
void parse(const std::string &filename)
double getNearClippingDistance() const
void setKltPyramidLevels(const unsigned int &pL)
unsigned int getKltBlockSize() const
void setProjectionErrorKernelSize(const unsigned int &size)
void getCameraParameters(vpCameraParameters &cam) const
error that can be emited by ViSP classes.
Definition: vpException.h:71
Definition: vpMe.h:60
vpMbtXmlGenericParser(int type=EDGE_PARSER)
double getLodMinLineLengthThreshold() const
void setKltMaskBorder(const unsigned int &mb)
unsigned int getProjectionErrorKernelSize() const
void setEdgeMe(const vpMe &ecm)
void setDepthNormalSamplingStepX(const unsigned int stepX)
void setKltHarrisParam(const double &hp)
void setDepthDenseSamplingStepX(const unsigned int stepX)
void setAngleDisappear(const double &adisappear)
void setKltMinDistance(const double &mD)
void setProjectionErrorMe(const vpMe &me)
void getProjectionErrorMe(vpMe &me) const
Generic class defining intrinsic camera parameters.
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
unsigned int getDepthNormalSamplingStepX() const
void setKltWindowSize(const unsigned int &w)
void getEdgeMe(vpMe &ecm) const
void setAngleAppear(const double &aappear)
void setDepthDenseSamplingStepY(const unsigned int stepY)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
unsigned int getKltPyramidLevels() const
unsigned int getKltMaskBorder() const
unsigned int getDepthDenseSamplingStepX() const
void setNearClippingDistance(const double &nclip)
void setFarClippingDistance(const double &fclip)
unsigned int getDepthDenseSamplingStepY() const
unsigned int getDepthNormalSamplingStepY() const
unsigned int getKltMaxFeatures() const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
void setDepthNormalPclPlaneEstimationMethod(const int method)
void setKltBlockSize(const unsigned int &bs)
void setDepthNormalPclPlaneEstimationRansacThreshold(const double threshold)
void setKltMaxFeatures(const unsigned int &mF)
void setCameraParameters(const vpCameraParameters &cam)
double getLodMinPolygonAreaThreshold() const
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
int getDepthNormalPclPlaneEstimationMethod() const
void setDepthNormalSamplingStepY(const unsigned int stepY)
unsigned int getKltWindowSize() const