Visual Servoing Platform  version 3.3.1 under development (2020-12-02)
vpMbtXmlGenericParser.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Load XML Parameter for Model Based Tracker.
33  *
34  *****************************************************************************/
35 #include <visp3/core/vpConfig.h>
36 
37 #include <iostream>
38 #include <map>
39 #include <clocale>
40 
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
42 
43 #include <pugixml.hpp>
44 
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 class vpMbtXmlGenericParser::Impl
47 {
48 public:
49  Impl(int type = EDGE_PARSER) :
50  m_parserType(type),
51  //<camera>
52  m_cam(),
53  //<face>
54  m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
55  m_farClipping(false), m_fovClipping(false),
56  //<lod>
57  m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
58  //<ecm>
59  m_ecm(),
60  //<klt>
61  m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
62  m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
63  //<depth_normal>
64  m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
65  m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
66  m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2), m_depthNormalSamplingStepY(2),
67  //<depth_dense>
68  m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
69  //<projection_error>
70  m_projectionErrorMe(), m_projectionErrorKernelSize(2), //5x5
71  m_nodeMap()
72  {
73  init();
74  }
75 
76  void parse(const std::string &filename)
77  {
78  pugi::xml_document doc;
79  if (!doc.load_file(filename.c_str())) {
80  throw vpException(vpException::ioError, "Cannot open file: %s", filename.c_str());
81  }
82 
83  bool camera_node = false;
84  bool face_node = false;
85  bool ecm_node = false;
86  bool klt_node = false;
87  bool lod_node = false;
88  bool depth_normal_node = false;
89  bool depth_dense_node = false;
90  bool projection_error_node = false;
91 
92  pugi::xml_node root_node = doc.document_element();
93  for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
94  if (dataNode.type() == pugi::node_element) {
95  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
96  if (iter_data != m_nodeMap.end()) {
97  switch (iter_data->second) {
98  case camera:
99  if (m_parserType != PROJECTION_ERROR_PARSER) {
100  read_camera(dataNode);
101  camera_node = true;
102  }
103  break;
104 
105  case face:
106  if (m_parserType != PROJECTION_ERROR_PARSER) {
107  read_face(dataNode);
108  face_node = true;
109  }
110  break;
111 
112  case lod:
113  if (m_parserType != PROJECTION_ERROR_PARSER) {
114  read_lod(dataNode);
115  lod_node = true;
116  }
117  break;
118 
119  case ecm:
120  if (m_parserType & EDGE_PARSER) {
121  read_ecm(dataNode);
122  ecm_node = true;
123  }
124  break;
125 
126  case sample:
127  if (m_parserType & EDGE_PARSER)
128  read_sample_deprecated(dataNode);
129  break;
130 
131  case klt:
132  if (m_parserType & KLT_PARSER) {
133  read_klt(dataNode);
134  klt_node = true;
135  }
136  break;
137 
138  case depth_normal:
139  if (m_parserType & DEPTH_NORMAL_PARSER) {
140  read_depth_normal(dataNode);
141  depth_normal_node = true;
142  }
143  break;
144 
145  case depth_dense:
146  if (m_parserType & DEPTH_DENSE_PARSER) {
147  read_depth_dense(dataNode);
148  depth_dense_node = true;
149  }
150  break;
151 
152  case projection_error:
153  if (m_parserType == PROJECTION_ERROR_PARSER) {
154  read_projection_error(dataNode);
155  projection_error_node = true;
156  }
157  break;
158 
159  default:
160  break;
161  }
162  }
163  }
164  }
165 
166  if (m_parserType == PROJECTION_ERROR_PARSER) {
167  if (!projection_error_node) {
168  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
169  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
170  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
171  }
172  } else {
173  if (!camera_node) {
174  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
175  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
176  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
177  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
178  }
179 
180  if (!face_node) {
181  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
182  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
183  }
184 
185  if (!lod_node) {
186  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
187  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
188  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
189  }
190 
191  if (!ecm_node && (m_parserType & EDGE_PARSER)) {
192  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
193  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
194  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
195  std::cout << "ecm : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
196  std::cout << "ecm : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
197  std::cout << "ecm : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
198  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
199  }
200 
201  if (!klt_node && (m_parserType & KLT_PARSER)) {
202  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
203  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
204  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
205  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
206  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
207  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
208  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
209  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
210  }
211 
212  if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
213  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
214  << std::endl;
215  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
216  << " (default)" << std::endl;
217  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
218  << " (default)" << std::endl;
219  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
220  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
221  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
222  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
223  }
224 
225  if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
226  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
227  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
228  }
229  }
230  }
231 
237  void read_camera(const pugi::xml_node &node)
238  {
239  bool u0_node = false;
240  bool v0_node = false;
241  bool px_node = false;
242  bool py_node = false;
243 
244  // current data values.
245  double d_u0 = m_cam.get_u0();
246  double d_v0 = m_cam.get_v0();
247  double d_px = m_cam.get_px();
248  double d_py = m_cam.get_py();
249 
250  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
251  if (dataNode.type() == pugi::node_element) {
252  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
253  if (iter_data != m_nodeMap.end()) {
254  switch (iter_data->second) {
255  case u0:
256  d_u0 = dataNode.text().as_double();
257  u0_node = true;
258  break;
259 
260  case v0:
261  d_v0 = dataNode.text().as_double();
262  v0_node = true;
263  break;
264 
265  case px:
266  d_px = dataNode.text().as_double();
267  px_node = true;
268  break;
269 
270  case py:
271  d_py = dataNode.text().as_double();
272  py_node = true;
273  break;
274 
275  default:
276  break;
277  }
278  }
279  }
280  }
281 
282  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
283 
284  if (!u0_node)
285  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
286  else
287  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
288 
289  if (!v0_node)
290  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
291  else
292  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
293 
294  if (!px_node)
295  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
296  else
297  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
298 
299  if (!py_node)
300  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
301  else
302  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
303  }
304 
310  void read_depth_normal(const pugi::xml_node &node)
311  {
312  bool feature_estimation_method_node = false;
313  bool PCL_plane_estimation_node = false;
314  bool sampling_step_node = false;
315 
316  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
317  if (dataNode.type() == pugi::node_element) {
318  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
319  if (iter_data != m_nodeMap.end()) {
320  switch (iter_data->second) {
321  case feature_estimation_method:
322  m_depthNormalFeatureEstimationMethod =
323  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
324  feature_estimation_method_node = true;
325  break;
326 
327  case PCL_plane_estimation:
328  read_depth_normal_PCL(dataNode);
329  PCL_plane_estimation_node = true;
330  break;
331 
332  case depth_sampling_step:
333  read_depth_normal_sampling_step(dataNode);
334  sampling_step_node = true;
335  break;
336 
337  default:
338  break;
339  }
340  }
341  }
342  }
343 
344  if (!feature_estimation_method_node)
345  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << " (default)"
346  << std::endl;
347  else
348  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
349 
350  if (!PCL_plane_estimation_node) {
351  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
352  << " (default)" << std::endl;
353  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
354  << " (default)" << std::endl;
355  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
356  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
357  }
358 
359  if (!sampling_step_node) {
360  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)" << std::endl;
361  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)" << std::endl;
362  }
363  }
364 
370  void read_depth_normal_PCL(const pugi::xml_node &node)
371  {
372  bool PCL_plane_estimation_method_node = false;
373  bool PCL_plane_estimation_ransac_max_iter_node = false;
374  bool PCL_plane_estimation_ransac_threshold_node = false;
375 
376  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
377  if (dataNode.type() == pugi::node_element) {
378  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
379  if (iter_data != m_nodeMap.end()) {
380  switch (iter_data->second) {
381  case PCL_plane_estimation_method:
382  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
383  PCL_plane_estimation_method_node = true;
384  break;
385 
386  case PCL_plane_estimation_ransac_max_iter:
387  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
388  PCL_plane_estimation_ransac_max_iter_node = true;
389  break;
390 
391  case PCL_plane_estimation_ransac_threshold:
392  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
393  PCL_plane_estimation_ransac_threshold_node = true;
394  break;
395 
396  default:
397  break;
398  }
399  }
400  }
401  }
402 
403  if (!PCL_plane_estimation_method_node)
404  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
405  << " (default)" << std::endl;
406  else
407  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
408  << std::endl;
409 
410  if (!PCL_plane_estimation_ransac_max_iter_node)
411  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
412  << " (default)" << std::endl;
413  else
414  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
415  << std::endl;
416 
417  if (!PCL_plane_estimation_ransac_threshold_node)
418  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
419  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
420  else
421  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
422  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
423  }
424 
430  void read_depth_normal_sampling_step(const pugi::xml_node &node)
431  {
432  bool sampling_step_X_node = false;
433  bool sampling_step_Y_node = false;
434 
435  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
436  if (dataNode.type() == pugi::node_element) {
437  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
438  if (iter_data != m_nodeMap.end()) {
439  switch (iter_data->second) {
440  case depth_sampling_step_X:
441  m_depthNormalSamplingStepX = dataNode.text().as_uint();
442  sampling_step_X_node = true;
443  break;
444 
445  case depth_sampling_step_Y:
446  m_depthNormalSamplingStepY = dataNode.text().as_uint();
447  sampling_step_Y_node = true;
448  break;
449 
450  default:
451  break;
452  }
453  }
454  }
455  }
456 
457  if (!sampling_step_X_node)
458  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)" << std::endl;
459  else
460  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
461 
462  if (!sampling_step_Y_node)
463  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)" << std::endl;
464  else
465  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
466  }
467 
473  void read_depth_dense(const pugi::xml_node &node)
474  {
475  bool sampling_step_node = false;
476 
477  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
478  if (dataNode.type() == pugi::node_element) {
479  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
480  if (iter_data != m_nodeMap.end()) {
481  switch (iter_data->second) {
482  case depth_dense_sampling_step:
483  read_depth_dense_sampling_step(dataNode);
484  sampling_step_node = true;
485  break;
486 
487  default:
488  break;
489  }
490  }
491  }
492  }
493 
494  if (!sampling_step_node) {
495  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
496  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
497  }
498  }
499 
505  void read_depth_dense_sampling_step(const pugi::xml_node &node)
506  {
507  bool sampling_step_X_node = false;
508  bool sampling_step_Y_node = false;
509 
510  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
511  if (dataNode.type() == pugi::node_element) {
512  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
513  if (iter_data != m_nodeMap.end()) {
514  switch (iter_data->second) {
515  case depth_dense_sampling_step_X:
516  m_depthDenseSamplingStepX = dataNode.text().as_uint();
517  sampling_step_X_node = true;
518  break;
519 
520  case depth_dense_sampling_step_Y:
521  m_depthDenseSamplingStepY = dataNode.text().as_uint();
522  sampling_step_Y_node = true;
523  break;
524 
525  default:
526  break;
527  }
528  }
529  }
530  }
531 
532  if (!sampling_step_X_node)
533  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)" << std::endl;
534  else
535  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
536 
537  if (!sampling_step_Y_node)
538  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)" << std::endl;
539  else
540  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
541  }
542 
548  void read_ecm(const pugi::xml_node &node)
549  {
550  bool mask_node = false;
551  bool range_node = false;
552  bool contrast_node = false;
553  bool sample_node = false;
554 
555  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
556  if (dataNode.type() == pugi::node_element) {
557  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
558  if (iter_data != m_nodeMap.end()) {
559  switch (iter_data->second) {
560  case mask:
561  read_ecm_mask(dataNode);
562  mask_node = true;
563  break;
564 
565  case range:
566  read_ecm_range(dataNode);
567  range_node = true;
568  break;
569 
570  case contrast:
571  read_ecm_contrast(dataNode);
572  contrast_node = true;
573  break;
574 
575  case sample:
576  read_ecm_sample(dataNode);
577  sample_node = true;
578  break;
579 
580  default:
581  break;
582  }
583  }
584  }
585  }
586 
587  if (!mask_node) {
588  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
589  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
590  }
591 
592  if (!range_node) {
593  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
594  }
595 
596  if (!contrast_node) {
597  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
598  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
599  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
600  }
601 
602  if (!sample_node) {
603  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
604  }
605  }
606 
612  void read_ecm_contrast(const pugi::xml_node &node)
613  {
614  bool edge_threshold_node = false;
615  bool mu1_node = false;
616  bool mu2_node = false;
617 
618  // current data values.
619  double d_edge_threshold = m_ecm.getThreshold();
620  double d_mu1 = m_ecm.getMu1();
621  double d_mu2 = m_ecm.getMu2();
622 
623  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
624  if (dataNode.type() == pugi::node_element) {
625  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
626  if (iter_data != m_nodeMap.end()) {
627  switch (iter_data->second) {
628  case edge_threshold:
629  d_edge_threshold = dataNode.text().as_double();
630  edge_threshold_node = true;
631  break;
632 
633  case mu1:
634  d_mu1 = dataNode.text().as_double();
635  mu1_node = true;
636  break;
637 
638  case mu2:
639  d_mu2 = dataNode.text().as_double();
640  mu2_node = true;
641  break;
642 
643  default:
644  break;
645  }
646  }
647  }
648  }
649 
650  m_ecm.setMu1(d_mu1);
651  m_ecm.setMu2(d_mu2);
652  m_ecm.setThreshold(d_edge_threshold);
653 
654  if (!edge_threshold_node)
655  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
656  else
657  std::cout << "ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
658 
659  if (!mu1_node)
660  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
661  else
662  std::cout << "ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
663 
664  if (!mu2_node)
665  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
666  else
667  std::cout << "ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
668  }
669 
675  void read_ecm_mask(const pugi::xml_node &node)
676  {
677  bool size_node = false;
678  bool nb_mask_node = false;
679 
680  // current data values.
681  unsigned int d_size = m_ecm.getMaskSize();
682  unsigned int d_nb_mask = m_ecm.getMaskNumber();
683 
684  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
685  if (dataNode.type() == pugi::node_element) {
686  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
687  if (iter_data != m_nodeMap.end()) {
688  switch (iter_data->second) {
689  case size:
690  d_size = dataNode.text().as_uint();
691  size_node = true;
692  break;
693 
694  case nb_mask:
695  d_nb_mask = dataNode.text().as_uint();
696  nb_mask_node = true;
697  break;
698 
699  default:
700  break;
701  }
702  }
703  }
704  }
705 
706  m_ecm.setMaskSize(d_size);
707 
708  // Check to ensure that d_nb_mask > 0
709  if (d_nb_mask == 0)
710  throw(vpException(vpException::badValue, "Model-based tracker mask size "
711  "parameter should be different "
712  "from zero in xml file"));
713  m_ecm.setMaskNumber(d_nb_mask);
714 
715  if (!size_node)
716  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
717  else
718  std::cout << "ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
719 
720  if (!nb_mask_node)
721  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
722  else
723  std::cout << "ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
724  }
725 
731  void read_ecm_range(const pugi::xml_node &node)
732  {
733  bool tracking_node = false;
734 
735  // current data values.
736  unsigned int m_range_tracking = m_ecm.getRange();
737 
738  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
739  if (dataNode.type() == pugi::node_element) {
740  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
741  if (iter_data != m_nodeMap.end()) {
742  switch (iter_data->second) {
743  case tracking:
744  m_range_tracking = dataNode.text().as_uint();
745  tracking_node = true;
746  break;
747 
748  default:
749  break;
750  }
751  }
752  }
753  }
754 
755  m_ecm.setRange(m_range_tracking);
756 
757  if (!tracking_node)
758  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
759  else
760  std::cout << "ecm : range : tracking : " << m_ecm.getRange() << std::endl;
761  }
762 
768  void read_ecm_sample(const pugi::xml_node &node)
769  {
770  bool step_node = false;
771 
772  // current data values.
773  double d_stp = m_ecm.getSampleStep();
774 
775  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
776  if (dataNode.type() == pugi::node_element) {
777  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
778  if (iter_data != m_nodeMap.end()) {
779  switch (iter_data->second) {
780  case step:
781  d_stp = dataNode.text().as_int();
782  step_node = true;
783  break;
784 
785  default:
786  break;
787  }
788  }
789  }
790  }
791 
792  m_ecm.setSampleStep(d_stp);
793 
794  if (!step_node)
795  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
796  else
797  std::cout << "ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
798  }
799 
805  void read_face(const pugi::xml_node &node)
806  {
807  bool angle_appear_node = false;
808  bool angle_disappear_node = false;
809  bool near_clipping_node = false;
810  bool far_clipping_node = false;
811  bool fov_clipping_node = false;
812  m_hasNearClipping = false;
813  m_hasFarClipping = false;
814 
815  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
816  if (dataNode.type() == pugi::node_element) {
817  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
818  if (iter_data != m_nodeMap.end()) {
819  switch (iter_data->second) {
820  case angle_appear:
821  m_angleAppear = dataNode.text().as_double();
822  angle_appear_node = true;
823  break;
824 
825  case angle_disappear:
826  m_angleDisappear = dataNode.text().as_double();
827  angle_disappear_node = true;
828  break;
829 
830  case near_clipping:
831  m_nearClipping = dataNode.text().as_double();
832  m_hasNearClipping = true;
833  near_clipping_node = true;
834  break;
835 
836  case far_clipping:
837  m_farClipping = dataNode.text().as_double();
838  m_hasFarClipping = true;
839  far_clipping_node = true;
840  break;
841 
842  case fov_clipping:
843  if (dataNode.text().as_int())
844  m_fovClipping = true;
845  else
846  m_fovClipping = false;
847  fov_clipping_node = true;
848  break;
849 
850  default:
851  break;
852  }
853  }
854  }
855  }
856 
857  if (!angle_appear_node)
858  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
859  else
860  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
861 
862  if (!angle_disappear_node)
863  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
864  else
865  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
866 
867  if (near_clipping_node)
868  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
869 
870  if (far_clipping_node)
871  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
872 
873  if (fov_clipping_node) {
874  if (m_fovClipping)
875  std::cout << "face : Fov Clipping : True" << std::endl;
876  else
877  std::cout << "face : Fov Clipping : False" << std::endl;
878  }
879  }
880 
886  void read_klt(const pugi::xml_node &node)
887  {
888  bool mask_border_node = false;
889  bool max_features_node = false;
890  bool window_size_node = false;
891  bool quality_node = false;
892  bool min_distance_node = false;
893  bool harris_node = false;
894  bool size_block_node = false;
895  bool pyramid_lvl_node = false;
896 
897  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
898  if (dataNode.type() == pugi::node_element) {
899  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
900  if (iter_data != m_nodeMap.end()) {
901  switch (iter_data->second) {
902  case mask_border:
903  m_kltMaskBorder = dataNode.text().as_uint();
904  mask_border_node = true;
905  break;
906 
907  case max_features:
908  m_kltMaxFeatures = dataNode.text().as_uint();
909  max_features_node = true;
910  break;
911 
912  case window_size:
913  m_kltWinSize = dataNode.text().as_uint();
914  window_size_node = true;
915  break;
916 
917  case quality:
918  m_kltQualityValue = dataNode.text().as_double();
919  quality_node = true;
920  break;
921 
922  case min_distance:
923  m_kltMinDist = dataNode.text().as_double();
924  min_distance_node = true;
925  break;
926 
927  case harris:
928  m_kltHarrisParam = dataNode.text().as_double();
929  harris_node = true;
930  break;
931 
932  case size_block:
933  m_kltBlockSize = dataNode.text().as_uint();
934  size_block_node = true;
935  break;
936 
937  case pyramid_lvl:
938  m_kltPyramidLevels = dataNode.text().as_uint();
939  pyramid_lvl_node = true;
940  break;
941 
942  default:
943  break;
944  }
945  }
946  }
947  }
948 
949  if (!mask_border_node)
950  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
951  else
952  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
953 
954  if (!max_features_node)
955  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
956  else
957  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
958 
959  if (!window_size_node)
960  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
961  else
962  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
963 
964  if (!quality_node)
965  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
966  else
967  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
968 
969  if (!min_distance_node)
970  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
971  else
972  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
973 
974  if (!harris_node)
975  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
976  else
977  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
978 
979  if (!size_block_node)
980  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
981  else
982  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
983 
984  if (!pyramid_lvl_node)
985  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
986  else
987  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
988  }
989 
990  void read_lod(const pugi::xml_node &node)
991  {
992  bool use_lod_node = false;
993  bool min_line_length_threshold_node = false;
994  bool min_polygon_area_threshold_node = false;
995 
996  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
997  if (dataNode.type() == pugi::node_element) {
998  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
999  if (iter_data != m_nodeMap.end()) {
1000  switch (iter_data->second) {
1001  case use_lod:
1002  m_useLod = (dataNode.text().as_int() != 0);
1003  use_lod_node = true;
1004  break;
1005 
1006  case min_line_length_threshold:
1007  m_minLineLengthThreshold = dataNode.text().as_double();
1008  min_line_length_threshold_node = true;
1009  break;
1010 
1011  case min_polygon_area_threshold:
1012  m_minPolygonAreaThreshold = dataNode.text().as_double();
1013  min_polygon_area_threshold_node = true;
1014  break;
1015 
1016  default:
1017  break;
1018  }
1019  }
1020  }
1021  }
1022 
1023  if (!use_lod_node)
1024  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1025  else
1026  std::cout << "lod : use lod : " << m_useLod << std::endl;
1027 
1028  if (!min_line_length_threshold_node)
1029  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1030  else
1031  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1032 
1033  if (!min_polygon_area_threshold_node)
1034  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1035  else
1036  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1037  }
1038 
1039  void read_projection_error(const pugi::xml_node &node)
1040  {
1041  bool step_node = false;
1042  bool kernel_size_node = false;
1043 
1044  // current data values.
1045  double d_stp = m_projectionErrorMe.getSampleStep();
1046  std::string kernel_size_str;
1047 
1048  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1049  if (dataNode.type() == pugi::node_element) {
1050  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1051  if (iter_data != m_nodeMap.end()) {
1052  switch (iter_data->second) {
1053  case projection_error_sample_step:
1054  d_stp = dataNode.text().as_int();
1055  step_node = true;
1056  break;
1057 
1058  case projection_error_kernel_size:
1059  kernel_size_str = dataNode.text().as_string();
1060  kernel_size_node = true;
1061  break;
1062 
1063  default:
1064  break;
1065  }
1066  }
1067  }
1068  }
1069 
1070  m_projectionErrorMe.setSampleStep(d_stp);
1071 
1072  if (kernel_size_str == "3x3") {
1073  m_projectionErrorKernelSize = 1;
1074  } else if (kernel_size_str == "5x5") {
1075  m_projectionErrorKernelSize = 2;
1076  } else if (kernel_size_str == "7x7") {
1077  m_projectionErrorKernelSize = 3;
1078  } else if (kernel_size_str == "9x9") {
1079  m_projectionErrorKernelSize = 4;
1080  } else if (kernel_size_str == "11x11") {
1081  m_projectionErrorKernelSize = 5;
1082  } else if (kernel_size_str == "13x13") {
1083  m_projectionErrorKernelSize = 6;
1084  } else if (kernel_size_str == "15x15") {
1085  m_projectionErrorKernelSize = 7;
1086  } else {
1087  std::cerr << "Unsupported kernel size." << std::endl;
1088  }
1089 
1090  if (!step_node)
1091  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)" << std::endl;
1092  else
1093  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1094 
1095  if (!kernel_size_node)
1096  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 << "x"
1097  << m_projectionErrorKernelSize*2+1 << " (default)" << std::endl;
1098  else
1099  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1100  }
1101 
1107  void read_sample_deprecated(const pugi::xml_node &node)
1108  {
1109  bool step_node = false;
1110  // bool nb_sample_node = false;
1111 
1112  // current data values.
1113  double d_stp = m_ecm.getSampleStep();
1114 
1115  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1116  if (dataNode.type() == pugi::node_element) {
1117  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1118  if (iter_data != m_nodeMap.end()) {
1119  switch (iter_data->second) {
1120  case step:
1121  d_stp = dataNode.text().as_int();
1122  step_node = true;
1123  break;
1124 
1125  default:
1126  break;
1127  }
1128  }
1129  }
1130  }
1131 
1132  m_ecm.setSampleStep(d_stp);
1133 
1134  if (!step_node)
1135  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1136  else
1137  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1138 
1139  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1140  std::cout << " It should be moved in the ecm node (ecm : sample)." << std::endl;
1141  }
1142 
1143  double getAngleAppear() const { return m_angleAppear; }
1144  double getAngleDisappear() const { return m_angleDisappear; }
1145 
1146  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1147 
1148  void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1149 
1150  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1151  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1152 
1154  {
1155  return m_depthNormalFeatureEstimationMethod;
1156  }
1157  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1159  {
1160  return m_depthNormalPclPlaneEstimationRansacMaxIter;
1161  }
1163  {
1164  return m_depthNormalPclPlaneEstimationRansacThreshold;
1165  }
1166  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1167  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1168 
1169  double getFarClippingDistance() const { return m_farClipping; }
1170  bool getFovClipping() const { return m_fovClipping; }
1171 
1172  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1173  double getKltHarrisParam() const { return m_kltHarrisParam; }
1174  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1175  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1176  double getKltMinDistance() const { return m_kltMinDist; }
1177  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1178  double getKltQuality() const { return m_kltQualityValue; }
1179  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1180 
1181  bool getLodState() const { return m_useLod; }
1182  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1183  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1184 
1185  double getNearClippingDistance() const { return m_nearClipping; }
1186 
1187  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1188  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1189 
1190  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1191  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1192 
1193  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1194  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1195 
1196  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1197 
1198  void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1199  void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1201  {
1202  m_depthNormalFeatureEstimationMethod = method;
1203  }
1205  {
1206  m_depthNormalPclPlaneEstimationMethod = method;
1207  }
1209  {
1210  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1211  }
1213  {
1214  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1215  }
1216  void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1217  void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1218 
1219  void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1220 
1221  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1222 
1223  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1224  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1225  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1226  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1227  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1228  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1229  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1230  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1231 
1232  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1233 
1234  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1235  void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1236 
1237 protected:
1239  int m_parserType;
1241  vpCameraParameters m_cam;
1243  double m_angleAppear;
1245  double m_angleDisappear;
1247  bool m_hasNearClipping;
1249  double m_nearClipping;
1251  bool m_hasFarClipping;
1253  double m_farClipping;
1255  bool m_fovClipping;
1256  // LOD
1258  bool m_useLod;
1260  double m_minLineLengthThreshold;
1262  double m_minPolygonAreaThreshold;
1263  // Edge
1265  vpMe m_ecm;
1266  // KLT
1268  unsigned int m_kltMaskBorder;
1270  unsigned int m_kltMaxFeatures;
1272  unsigned int m_kltWinSize;
1274  double m_kltQualityValue;
1276  double m_kltMinDist;
1278  double m_kltHarrisParam;
1280  unsigned int m_kltBlockSize;
1282  unsigned int m_kltPyramidLevels;
1283  // Depth normal
1285  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1287  int m_depthNormalPclPlaneEstimationMethod;
1289  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1291  double m_depthNormalPclPlaneEstimationRansacThreshold;
1293  unsigned int m_depthNormalSamplingStepX;
1295  unsigned int m_depthNormalSamplingStepY;
1296  // Depth dense
1298  unsigned int m_depthDenseSamplingStepX;
1300  unsigned int m_depthDenseSamplingStepY;
1301  // Projection error
1303  vpMe m_projectionErrorMe;
1305  unsigned int m_projectionErrorKernelSize;
1306  std::map<std::string, int> m_nodeMap;
1307 
1308  enum vpDataToParseMb {
1309  //<conf>
1310  conf,
1311  //<face>
1312  face,
1313  angle_appear,
1314  angle_disappear,
1315  near_clipping,
1316  far_clipping,
1317  fov_clipping,
1318  //<camera>
1319  camera,
1320  height,
1321  width,
1322  u0,
1323  v0,
1324  px,
1325  py,
1326  lod,
1327  use_lod,
1328  min_line_length_threshold,
1329  min_polygon_area_threshold,
1330  //<ecm>
1331  ecm,
1332  mask,
1333  size,
1334  nb_mask,
1335  range,
1336  tracking,
1337  contrast,
1338  edge_threshold,
1339  mu1,
1340  mu2,
1341  sample,
1342  step,
1343  //<klt>
1344  klt,
1345  mask_border,
1346  max_features,
1347  window_size,
1348  quality,
1349  min_distance,
1350  harris,
1351  size_block,
1352  pyramid_lvl,
1353  //<depth_normal>
1354  depth_normal,
1355  feature_estimation_method,
1356  PCL_plane_estimation,
1357  PCL_plane_estimation_method,
1358  PCL_plane_estimation_ransac_max_iter,
1359  PCL_plane_estimation_ransac_threshold,
1360  depth_sampling_step,
1361  depth_sampling_step_X,
1362  depth_sampling_step_Y,
1363  //<depth_dense>
1364  depth_dense,
1365  depth_dense_sampling_step,
1366  depth_dense_sampling_step_X,
1367  depth_dense_sampling_step_Y,
1368  //<projection_error>
1369  projection_error,
1370  projection_error_sample_step,
1371  projection_error_kernel_size
1372  };
1373 
1377  void init()
1378  {
1379  //<conf>
1380  m_nodeMap["conf"] = conf;
1381  //<face>
1382  m_nodeMap["face"] = face;
1383  m_nodeMap["angle_appear"] = angle_appear;
1384  m_nodeMap["angle_disappear"] = angle_disappear;
1385  m_nodeMap["near_clipping"] = near_clipping;
1386  m_nodeMap["far_clipping"] = far_clipping;
1387  m_nodeMap["fov_clipping"] = fov_clipping;
1388  //<camera>
1389  m_nodeMap["camera"] = camera;
1390  m_nodeMap["height"] = height;
1391  m_nodeMap["width"] = width;
1392  m_nodeMap["u0"] = u0;
1393  m_nodeMap["v0"] = v0;
1394  m_nodeMap["px"] = px;
1395  m_nodeMap["py"] = py;
1396  //<lod>
1397  m_nodeMap["lod"] = lod;
1398  m_nodeMap["use_lod"] = use_lod;
1399  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1400  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1401  //<ecm>
1402  m_nodeMap["ecm"] = ecm;
1403  m_nodeMap["mask"] = mask;
1404  m_nodeMap["size"] = size;
1405  m_nodeMap["nb_mask"] = nb_mask;
1406  m_nodeMap["range"] = range;
1407  m_nodeMap["tracking"] = tracking;
1408  m_nodeMap["contrast"] = contrast;
1409  m_nodeMap["edge_threshold"] = edge_threshold;
1410  m_nodeMap["mu1"] = mu1;
1411  m_nodeMap["mu2"] = mu2;
1412  m_nodeMap["sample"] = sample;
1413  m_nodeMap["step"] = step;
1414  //<klt>
1415  m_nodeMap["klt"] = klt;
1416  m_nodeMap["mask_border"] = mask_border;
1417  m_nodeMap["max_features"] = max_features;
1418  m_nodeMap["window_size"] = window_size;
1419  m_nodeMap["quality"] = quality;
1420  m_nodeMap["min_distance"] = min_distance;
1421  m_nodeMap["harris"] = harris;
1422  m_nodeMap["size_block"] = size_block;
1423  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1424  //<depth_normal>
1425  m_nodeMap["depth_normal"] = depth_normal;
1426  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1427  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1428  m_nodeMap["method"] = PCL_plane_estimation_method;
1429  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1430  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1431  m_nodeMap["sampling_step"] = depth_sampling_step;
1432  m_nodeMap["step_X"] = depth_sampling_step_X;
1433  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1434  //<depth_dense>
1435  m_nodeMap["depth_dense"] = depth_dense;
1436  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1437  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1438  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1439  //<projection_error>
1440  m_nodeMap["projection_error"] = projection_error;
1441  m_nodeMap["sample_step"] = projection_error_sample_step;
1442  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1443  }
1444 };
1445 #endif // DOXYGEN_SHOULD_SKIP_THIS
1446 
1447 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1448 {
1449  //https://pugixml.org/docs/manual.html#access.attrdata
1450  //https://en.cppreference.com/w/cpp/locale/setlocale
1451  //When called from Java binding, the locale seems to be changed to the default system locale
1452  //It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
1453  if (std::setlocale(LC_ALL, "C") == NULL) {
1454  std::cerr << "Cannot set locale to C" << std::endl;
1455  }
1456 }
1457 
1459 {
1460  delete m_impl;
1461 }
1462 
1468 void vpMbtXmlGenericParser::parse(const std::string &filename)
1469 {
1470  m_impl->parse(filename);
1471 }
1472 
1477 {
1478  return m_impl->getAngleAppear();
1479 }
1480 
1485 {
1486  return m_impl->getAngleDisappear();
1487 }
1488 
1490 {
1491  m_impl->getCameraParameters(cam);
1492 }
1493 
1498 {
1499  m_impl->getEdgeMe(ecm);
1500 }
1501 
1506 {
1507  return m_impl->getDepthDenseSamplingStepX();
1508 }
1509 
1514 {
1515  return m_impl->getDepthDenseSamplingStepY();
1516 }
1517 
1522 {
1523  return m_impl->getDepthNormalFeatureEstimationMethod();
1524 }
1525 
1530 {
1531  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1532 }
1533 
1538 {
1539  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1540 }
1541 
1546 {
1547  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1548 }
1549 
1554 {
1555  return m_impl->getDepthNormalSamplingStepX();
1556 }
1557 
1562 {
1563  return m_impl->getDepthNormalSamplingStepY();
1564 }
1565 
1570 {
1571  return m_impl->getFarClippingDistance();
1572 }
1573 
1578 {
1579  return m_impl->getFovClipping();
1580 }
1581 
1586 {
1587  return m_impl->getKltBlockSize();
1588 }
1589 
1594 {
1595  return m_impl->getKltHarrisParam();
1596 }
1597 
1602 {
1603  return m_impl->getKltMaskBorder();
1604 }
1605 
1610 {
1611  return m_impl->getKltMaxFeatures();
1612 }
1613 
1618 {
1619  return m_impl->getKltMinDistance();
1620 }
1621 
1626 {
1627  return m_impl->getKltPyramidLevels();
1628 }
1629 
1634 {
1635  return m_impl->getKltQuality();
1636 }
1637 
1642 {
1643  return m_impl->getKltWindowSize();
1644 }
1645 
1650 {
1651  return m_impl->getLodState();
1652 }
1653 
1658 {
1659  return m_impl->getLodMinLineLengthThreshold();
1660 }
1661 
1666 {
1667  return m_impl->getLodMinPolygonAreaThreshold();
1668 }
1669 
1674 {
1675  return m_impl->getNearClippingDistance();
1676 }
1677 
1682 {
1683  m_impl->getProjectionErrorMe(me);
1684 }
1685 
1687 {
1688  return m_impl->getProjectionErrorKernelSize();
1689 }
1690 
1697 {
1698  return m_impl->hasFarClippingDistance();
1699 }
1700 
1707 {
1708  return m_impl->hasNearClippingDistance();
1709 }
1710 
1716 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear)
1717 {
1718  m_impl->setAngleAppear(aappear);
1719 }
1720 
1726 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear)
1727 {
1728  m_impl->setAngleDisappear(adisappear);
1729 }
1730 
1737 {
1738  m_impl->setCameraParameters(cam);
1739 }
1740 
1747 {
1748  m_impl->setDepthDenseSamplingStepX(stepX);
1749 }
1750 
1757 {
1758  m_impl->setDepthDenseSamplingStepY(stepY);
1759 }
1760 
1767 {
1768  m_impl->setDepthNormalFeatureEstimationMethod(method);
1769 }
1770 
1777 {
1778  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1779 }
1780 
1787 {
1788  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1789 }
1790 
1797 {
1798  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1799 }
1800 
1807 {
1808  m_impl->setDepthNormalSamplingStepX(stepX);
1809 }
1810 
1817 {
1818  m_impl->setDepthNormalSamplingStepY(stepY);
1819 }
1820 
1827 {
1828  m_impl->setEdgeMe(ecm);
1829 }
1830 
1837 {
1838  m_impl->setFarClippingDistance(fclip);
1839 }
1840 
1846 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs)
1847 {
1848  m_impl->setKltBlockSize(bs);
1849 }
1850 
1857 {
1858  m_impl->setKltHarrisParam(hp);
1859 }
1860 
1866 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb)
1867 {
1868  m_impl->setKltMaskBorder(mb);
1869 }
1870 
1876 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF)
1877 {
1878  m_impl->setKltMaxFeatures(mF);
1879 }
1880 
1887 {
1888  m_impl->setKltMinDistance(mD);
1889 }
1890 
1897 {
1898  m_impl->setKltPyramidLevels(pL);
1899 }
1900 
1907 {
1908  m_impl->setKltQuality(q);
1909 }
1910 
1916 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w)
1917 {
1918  m_impl->setKltWindowSize(w);
1919 }
1920 
1927 {
1928  m_impl->setNearClippingDistance(nclip);
1929 }
1930 
1937 {
1938  m_impl->setProjectionErrorMe(me);
1939 }
1940 
1947 {
1948  m_impl->setProjectionErrorKernelSize(size);
1949 }
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