Visual Servoing Platform  version 3.6.1 under development (2024-06-22)
vpMbtXmlGenericParser.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Load XML Parameter for Model Based Tracker.
33  *
34 *****************************************************************************/
35 #include <visp3/core/vpConfig.h>
36 
37 #include <clocale>
38 #include <iostream>
39 #include <map>
40 
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
42 
43 #if defined(VISP_HAVE_PUGIXML)
44 #include <pugixml.hpp>
45 
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 
49 class vpMbtXmlGenericParser::Impl
50 {
51 public:
52  Impl(int type = EDGE_PARSER)
53  : m_parserType(type),
54  //<camera>
55  m_cam(),
56  //<face>
57  m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
58  m_farClipping(false), m_fovClipping(false),
59  //<lod>
60  m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
61  //<ecm>
62  m_ecm(),
63  //<klt>
64  m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
65  m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
66  //<depth_normal>
67  m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
68  m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
69  m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2),
70  m_depthNormalSamplingStepY(2),
71  //<depth_dense>
72  m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
73  //<projection_error>
74  m_projectionErrorMe(), m_projectionErrorKernelSize(2), // 5x5
75  m_nodeMap(), m_verbose(true)
76  {
77  // std::setlocale() is not thread safe and need to be called once
78  // https://stackoverflow.com/questions/41117179/undefined-behavior-with-setlocale-and-multithreading
79  if (m_call_setlocale) {
80  // https://pugixml.org/docs/manual.html#access.attrdata
81  // https://en.cppreference.com/w/cpp/locale/setlocale
82  // When called from Java binding, the locale seems to be changed to the default system locale
83  // It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
84  if (std::setlocale(LC_ALL, "C") == nullptr) {
85  std::cerr << "Cannot set locale to C" << std::endl;
86  }
87  m_call_setlocale = false;
88  }
89  init();
90  }
91 
92  void parse(const std::string &filename)
93  {
94  pugi::xml_document doc;
95  if (!doc.load_file(filename.c_str())) {
96  throw vpException(vpException::ioError, "Cannot open file: %s", filename.c_str());
97  }
98 
99  bool camera_node = false;
100  bool face_node = false;
101  bool ecm_node = false;
102  bool klt_node = false;
103  bool lod_node = false;
104  bool depth_normal_node = false;
105  bool depth_dense_node = false;
106  bool projection_error_node = false;
107 
108  pugi::xml_node root_node = doc.document_element();
109  for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
110  if (dataNode.type() == pugi::node_element) {
111  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
112  if (iter_data != m_nodeMap.end()) {
113  switch (iter_data->second) {
114  case camera:
115  if (m_parserType != PROJECTION_ERROR_PARSER) {
116  read_camera(dataNode);
117  camera_node = true;
118  }
119  break;
120 
121  case face:
122  if (m_parserType != PROJECTION_ERROR_PARSER) {
123  read_face(dataNode);
124  face_node = true;
125  }
126  break;
127 
128  case lod:
129  if (m_parserType != PROJECTION_ERROR_PARSER) {
130  read_lod(dataNode);
131  lod_node = true;
132  }
133  break;
134 
135  case ecm:
136  if (m_parserType & EDGE_PARSER) {
137  read_ecm(dataNode);
138  ecm_node = true;
139  }
140  break;
141 
142  case sample:
143  if (m_parserType & EDGE_PARSER)
144  read_sample_deprecated(dataNode);
145  break;
146 
147  case klt:
148  if (m_parserType & KLT_PARSER) {
149  read_klt(dataNode);
150  klt_node = true;
151  }
152  break;
153 
154  case depth_normal:
155  if (m_parserType & DEPTH_NORMAL_PARSER) {
156  read_depth_normal(dataNode);
157  depth_normal_node = true;
158  }
159  break;
160 
161  case depth_dense:
162  if (m_parserType & DEPTH_DENSE_PARSER) {
163  read_depth_dense(dataNode);
164  depth_dense_node = true;
165  }
166  break;
167 
168  case projection_error:
169  if (m_parserType == PROJECTION_ERROR_PARSER) {
170  read_projection_error(dataNode);
171  projection_error_node = true;
172  }
173  break;
174 
175  default:
176  break;
177  }
178  }
179  }
180  }
181 
182  if (m_verbose) {
183  if (m_parserType == PROJECTION_ERROR_PARSER) {
184  if (!projection_error_node) {
185  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
186  << std::endl;
187  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
188  << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
189  }
190  }
191  else {
192  if (!camera_node) {
193  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
194  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
195  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
196  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
197  }
198 
199  if (!face_node) {
200  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
201  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
202  }
203 
204  if (!lod_node) {
205  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
206  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
207  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
208  }
209 
210  if (!ecm_node && (m_parserType & EDGE_PARSER)) {
211  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
212  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
213  std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
214  std::cout << "me : contrast : threshold type : " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
215  std::cout << "me : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
216  std::cout << "me : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
217  std::cout << "me : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
218  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
219  }
220 
221  if (!klt_node && (m_parserType & KLT_PARSER)) {
222  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
223  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
224  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
225  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
226  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
227  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
228  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
229  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
230  }
231 
232  if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
233  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
234  << " (default)" << std::endl;
235  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
236  << " (default)" << std::endl;
237  std::cout << "depth normal : PCL_plane_estimation : max_iter : "
238  << m_depthNormalPclPlaneEstimationRansacMaxIter << " (default)" << std::endl;
239  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
240  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
241  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
242  << std::endl;
243  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
244  << std::endl;
245  }
246 
247  if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
248  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)"
249  << std::endl;
250  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)"
251  << std::endl;
252  }
253  }
254  }
255  }
256 
262  void read_camera(const pugi::xml_node &node)
263  {
264  bool u0_node = false;
265  bool v0_node = false;
266  bool px_node = false;
267  bool py_node = false;
268 
269  // current data values.
270  double d_u0 = m_cam.get_u0();
271  double d_v0 = m_cam.get_v0();
272  double d_px = m_cam.get_px();
273  double d_py = m_cam.get_py();
274 
275  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
276  if (dataNode.type() == pugi::node_element) {
277  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
278  if (iter_data != m_nodeMap.end()) {
279  switch (iter_data->second) {
280  case u0:
281  d_u0 = dataNode.text().as_double();
282  u0_node = true;
283  break;
284 
285  case v0:
286  d_v0 = dataNode.text().as_double();
287  v0_node = true;
288  break;
289 
290  case px:
291  d_px = dataNode.text().as_double();
292  px_node = true;
293  break;
294 
295  case py:
296  d_py = dataNode.text().as_double();
297  py_node = true;
298  break;
299 
300  default:
301  break;
302  }
303  }
304  }
305  }
306 
307  m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
308 
309  if (m_verbose) {
310  if (!u0_node)
311  std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
312  else
313  std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
314 
315  if (!v0_node)
316  std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
317  else
318  std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
319 
320  if (!px_node)
321  std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
322  else
323  std::cout << "camera : px : " << m_cam.get_px() << std::endl;
324 
325  if (!py_node)
326  std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
327  else
328  std::cout << "camera : py : " << m_cam.get_py() << std::endl;
329  }
330  }
331 
337  void read_depth_normal(const pugi::xml_node &node)
338  {
339  bool feature_estimation_method_node = false;
340  bool PCL_plane_estimation_node = false;
341  bool sampling_step_node = false;
342 
343  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
344  if (dataNode.type() == pugi::node_element) {
345  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
346  if (iter_data != m_nodeMap.end()) {
347  switch (iter_data->second) {
348  case feature_estimation_method:
349  m_depthNormalFeatureEstimationMethod =
350  (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
351  feature_estimation_method_node = true;
352  break;
353 
354  case PCL_plane_estimation:
355  read_depth_normal_PCL(dataNode);
356  PCL_plane_estimation_node = true;
357  break;
358 
359  case depth_sampling_step:
360  read_depth_normal_sampling_step(dataNode);
361  sampling_step_node = true;
362  break;
363 
364  default:
365  break;
366  }
367  }
368  }
369  }
370 
371  if (m_verbose) {
372  if (!feature_estimation_method_node)
373  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
374  << " (default)" << std::endl;
375  else
376  std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
377 
378  if (!PCL_plane_estimation_node) {
379  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
380  << " (default)" << std::endl;
381  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
382  << " (default)" << std::endl;
383  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
384  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
385  }
386 
387  if (!sampling_step_node) {
388  std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
389  << std::endl;
390  std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
391  << std::endl;
392  }
393  }
394  }
395 
401  void read_depth_normal_PCL(const pugi::xml_node &node)
402  {
403  bool PCL_plane_estimation_method_node = false;
404  bool PCL_plane_estimation_ransac_max_iter_node = false;
405  bool PCL_plane_estimation_ransac_threshold_node = false;
406 
407  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
408  if (dataNode.type() == pugi::node_element) {
409  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
410  if (iter_data != m_nodeMap.end()) {
411  switch (iter_data->second) {
412  case PCL_plane_estimation_method:
413  m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
414  PCL_plane_estimation_method_node = true;
415  break;
416 
417  case PCL_plane_estimation_ransac_max_iter:
418  m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
419  PCL_plane_estimation_ransac_max_iter_node = true;
420  break;
421 
422  case PCL_plane_estimation_ransac_threshold:
423  m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
424  PCL_plane_estimation_ransac_threshold_node = true;
425  break;
426 
427  default:
428  break;
429  }
430  }
431  }
432  }
433 
434  if (m_verbose) {
435  if (!PCL_plane_estimation_method_node)
436  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
437  << " (default)" << std::endl;
438  else
439  std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
440  << std::endl;
441 
442  if (!PCL_plane_estimation_ransac_max_iter_node)
443  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
444  << " (default)" << std::endl;
445  else
446  std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
447  << std::endl;
448 
449  if (!PCL_plane_estimation_ransac_threshold_node)
450  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
451  << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
452  else
453  std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
454  << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
455  }
456  }
457 
463  void read_depth_normal_sampling_step(const pugi::xml_node &node)
464  {
465  bool sampling_step_X_node = false;
466  bool sampling_step_Y_node = false;
467 
468  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
469  if (dataNode.type() == pugi::node_element) {
470  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
471  if (iter_data != m_nodeMap.end()) {
472  switch (iter_data->second) {
473  case depth_sampling_step_X:
474  m_depthNormalSamplingStepX = dataNode.text().as_uint();
475  sampling_step_X_node = true;
476  break;
477 
478  case depth_sampling_step_Y:
479  m_depthNormalSamplingStepY = dataNode.text().as_uint();
480  sampling_step_Y_node = true;
481  break;
482 
483  default:
484  break;
485  }
486  }
487  }
488  }
489 
490  if (m_verbose) {
491  if (!sampling_step_X_node)
492  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)"
493  << std::endl;
494  else
495  std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
496 
497  if (!sampling_step_Y_node)
498  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)"
499  << std::endl;
500  else
501  std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
502  }
503  }
504 
510  void read_depth_dense(const pugi::xml_node &node)
511  {
512  bool sampling_step_node = false;
513 
514  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
515  if (dataNode.type() == pugi::node_element) {
516  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
517  if (iter_data != m_nodeMap.end()) {
518  switch (iter_data->second) {
519  case depth_dense_sampling_step:
520  read_depth_dense_sampling_step(dataNode);
521  sampling_step_node = true;
522  break;
523 
524  default:
525  break;
526  }
527  }
528  }
529  }
530 
531  if (!sampling_step_node && m_verbose) {
532  std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
533  std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
534  }
535  }
536 
542  void read_depth_dense_sampling_step(const pugi::xml_node &node)
543  {
544  bool sampling_step_X_node = false;
545  bool sampling_step_Y_node = false;
546 
547  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
548  if (dataNode.type() == pugi::node_element) {
549  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
550  if (iter_data != m_nodeMap.end()) {
551  switch (iter_data->second) {
552  case depth_dense_sampling_step_X:
553  m_depthDenseSamplingStepX = dataNode.text().as_uint();
554  sampling_step_X_node = true;
555  break;
556 
557  case depth_dense_sampling_step_Y:
558  m_depthDenseSamplingStepY = dataNode.text().as_uint();
559  sampling_step_Y_node = true;
560  break;
561 
562  default:
563  break;
564  }
565  }
566  }
567  }
568 
569  if (m_verbose) {
570  if (!sampling_step_X_node)
571  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)"
572  << std::endl;
573  else
574  std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
575 
576  if (!sampling_step_Y_node)
577  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)"
578  << std::endl;
579  else
580  std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
581  }
582  }
583 
589  void read_ecm(const pugi::xml_node &node)
590  {
591  bool mask_node = false;
592  bool range_node = false;
593  bool contrast_node = false;
594  bool sample_node = false;
595 
596  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
597  if (dataNode.type() == pugi::node_element) {
598  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
599  if (iter_data != m_nodeMap.end()) {
600  switch (iter_data->second) {
601  case mask:
602  read_ecm_mask(dataNode);
603  mask_node = true;
604  break;
605 
606  case range:
607  read_ecm_range(dataNode);
608  range_node = true;
609  break;
610 
611  case contrast:
612  read_ecm_contrast(dataNode);
613  contrast_node = true;
614  break;
615 
616  case sample:
617  read_ecm_sample(dataNode);
618  sample_node = true;
619  break;
620 
621  default:
622  break;
623  }
624  }
625  }
626  }
627 
628  if (m_verbose) {
629  if (!mask_node) {
630  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
631  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
632  }
633 
634  if (!range_node) {
635  std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
636  }
637 
638  if (!contrast_node) {
639  std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
640  std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
641  std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
642  std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
643  }
644 
645  if (!sample_node) {
646  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
647  }
648  }
649  }
650 
656  void read_ecm_contrast(const pugi::xml_node &node)
657  {
658  bool edge_threshold_type_node = false;
659  bool edge_threshold_node = false;
660  bool mu1_node = false;
661  bool mu2_node = false;
662 
663  // current data values.
664  vpMe::vpLikelihoodThresholdType d_edge_threshold_type = m_ecm.getLikelihoodThresholdType();
665  double d_edge_threshold = m_ecm.getThreshold();
666  double d_mu1 = m_ecm.getMu1();
667  double d_mu2 = m_ecm.getMu2();
668 
669  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
670  if (dataNode.type() == pugi::node_element) {
671  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
672  if (iter_data != m_nodeMap.end()) {
673  switch (iter_data->second) {
674  case edge_threshold_type:
675  d_edge_threshold_type = static_cast<vpMe::vpLikelihoodThresholdType>(dataNode.text().as_int());
676  edge_threshold_type_node = true;
677  break;
678 
679  case edge_threshold:
680  d_edge_threshold = dataNode.text().as_int();
681  edge_threshold_node = true;
682  break;
683 
684  case mu1:
685  d_mu1 = dataNode.text().as_double();
686  mu1_node = true;
687  break;
688 
689  case mu2:
690  d_mu2 = dataNode.text().as_double();
691  mu2_node = true;
692  break;
693 
694  default:
695  break;
696  }
697  }
698  }
699  }
700 
701  m_ecm.setMu1(d_mu1);
702  m_ecm.setMu2(d_mu2);
703  m_ecm.setLikelihoodThresholdType(d_edge_threshold_type);
704  m_ecm.setThreshold(d_edge_threshold);
705 
706  if (m_verbose) {
707  if (!edge_threshold_type_node)
708  std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
709  else
710  std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << std::endl;
711 
712  if (!edge_threshold_node)
713  std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
714  else
715  std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << std::endl;
716 
717  if (!mu1_node)
718  std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
719  else
720  std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << std::endl;
721 
722  if (!mu2_node)
723  std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
724  else
725  std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << std::endl;
726  }
727  }
728 
734  void read_ecm_mask(const pugi::xml_node &node)
735  {
736  bool size_node = false;
737  bool nb_mask_node = false;
738 
739  // current data values.
740  unsigned int d_size = m_ecm.getMaskSize();
741  unsigned int d_nb_mask = m_ecm.getMaskNumber();
742 
743  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
744  if (dataNode.type() == pugi::node_element) {
745  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
746  if (iter_data != m_nodeMap.end()) {
747  switch (iter_data->second) {
748  case size:
749  d_size = dataNode.text().as_uint();
750  size_node = true;
751  break;
752 
753  case nb_mask:
754  d_nb_mask = dataNode.text().as_uint();
755  nb_mask_node = true;
756  break;
757 
758  default:
759  break;
760  }
761  }
762  }
763  }
764 
765  m_ecm.setMaskSize(d_size);
766 
767  // Check to ensure that d_nb_mask > 0
768  if (d_nb_mask == 0)
769  throw(vpException(vpException::badValue, "Model-based tracker mask size "
770  "parameter should be different "
771  "from zero in xml file"));
772  m_ecm.setMaskNumber(d_nb_mask);
773 
774  if (m_verbose) {
775  if (!size_node)
776  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
777  else
778  std::cout << "me : mask : size : " << m_ecm.getMaskSize() << std::endl;
779 
780  if (!nb_mask_node)
781  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
782  else
783  std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
784  }
785  }
786 
792  void read_ecm_range(const pugi::xml_node &node)
793  {
794  bool tracking_node = false;
795 
796  // current data values.
797  unsigned int m_range_tracking = m_ecm.getRange();
798 
799  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
800  if (dataNode.type() == pugi::node_element) {
801  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
802  if (iter_data != m_nodeMap.end()) {
803  switch (iter_data->second) {
804  case tracking:
805  m_range_tracking = dataNode.text().as_uint();
806  tracking_node = true;
807  break;
808 
809  default:
810  break;
811  }
812  }
813  }
814  }
815 
816  m_ecm.setRange(m_range_tracking);
817 
818  if (m_verbose) {
819  if (!tracking_node)
820  std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
821  else
822  std::cout << "me : range : tracking : " << m_ecm.getRange() << std::endl;
823  }
824  }
825 
831  void read_ecm_sample(const pugi::xml_node &node)
832  {
833  bool step_node = false;
834 
835  // current data values.
836  double d_stp = m_ecm.getSampleStep();
837 
838  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
839  if (dataNode.type() == pugi::node_element) {
840  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
841  if (iter_data != m_nodeMap.end()) {
842  switch (iter_data->second) {
843  case step:
844  d_stp = dataNode.text().as_int();
845  step_node = true;
846  break;
847 
848  default:
849  break;
850  }
851  }
852  }
853  }
854 
855  m_ecm.setSampleStep(d_stp);
856 
857  if (m_verbose) {
858  if (!step_node)
859  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
860  else
861  std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
862  }
863  }
864 
870  void read_face(const pugi::xml_node &node)
871  {
872  bool angle_appear_node = false;
873  bool angle_disappear_node = false;
874  bool near_clipping_node = false;
875  bool far_clipping_node = false;
876  bool fov_clipping_node = false;
877  m_hasNearClipping = false;
878  m_hasFarClipping = false;
879 
880  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
881  if (dataNode.type() == pugi::node_element) {
882  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
883  if (iter_data != m_nodeMap.end()) {
884  switch (iter_data->second) {
885  case angle_appear:
886  m_angleAppear = dataNode.text().as_double();
887  angle_appear_node = true;
888  break;
889 
890  case angle_disappear:
891  m_angleDisappear = dataNode.text().as_double();
892  angle_disappear_node = true;
893  break;
894 
895  case near_clipping:
896  m_nearClipping = dataNode.text().as_double();
897  m_hasNearClipping = true;
898  near_clipping_node = true;
899  break;
900 
901  case far_clipping:
902  m_farClipping = dataNode.text().as_double();
903  m_hasFarClipping = true;
904  far_clipping_node = true;
905  break;
906 
907  case fov_clipping:
908  if (dataNode.text().as_int())
909  m_fovClipping = true;
910  else
911  m_fovClipping = false;
912  fov_clipping_node = true;
913  break;
914 
915  default:
916  break;
917  }
918  }
919  }
920  }
921 
922  if (m_verbose) {
923  if (!angle_appear_node)
924  std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
925  else
926  std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
927 
928  if (!angle_disappear_node)
929  std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
930  else
931  std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
932 
933  if (near_clipping_node)
934  std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
935 
936  if (far_clipping_node)
937  std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
938 
939  if (fov_clipping_node) {
940  if (m_fovClipping)
941  std::cout << "face : Fov Clipping : True" << std::endl;
942  else
943  std::cout << "face : Fov Clipping : False" << std::endl;
944  }
945  }
946  }
947 
953  void read_klt(const pugi::xml_node &node)
954  {
955  bool mask_border_node = false;
956  bool max_features_node = false;
957  bool window_size_node = false;
958  bool quality_node = false;
959  bool min_distance_node = false;
960  bool harris_node = false;
961  bool size_block_node = false;
962  bool pyramid_lvl_node = false;
963 
964  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
965  if (dataNode.type() == pugi::node_element) {
966  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
967  if (iter_data != m_nodeMap.end()) {
968  switch (iter_data->second) {
969  case mask_border:
970  m_kltMaskBorder = dataNode.text().as_uint();
971  mask_border_node = true;
972  break;
973 
974  case max_features:
975  m_kltMaxFeatures = dataNode.text().as_uint();
976  max_features_node = true;
977  break;
978 
979  case window_size:
980  m_kltWinSize = dataNode.text().as_uint();
981  window_size_node = true;
982  break;
983 
984  case quality:
985  m_kltQualityValue = dataNode.text().as_double();
986  quality_node = true;
987  break;
988 
989  case min_distance:
990  m_kltMinDist = dataNode.text().as_double();
991  min_distance_node = true;
992  break;
993 
994  case harris:
995  m_kltHarrisParam = dataNode.text().as_double();
996  harris_node = true;
997  break;
998 
999  case size_block:
1000  m_kltBlockSize = dataNode.text().as_uint();
1001  size_block_node = true;
1002  break;
1003 
1004  case pyramid_lvl:
1005  m_kltPyramidLevels = dataNode.text().as_uint();
1006  pyramid_lvl_node = true;
1007  break;
1008 
1009  default:
1010  break;
1011  }
1012  }
1013  }
1014  }
1015 
1016  if (m_verbose) {
1017  if (!mask_border_node)
1018  std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
1019  else
1020  std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
1021 
1022  if (!max_features_node)
1023  std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
1024  else
1025  std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
1026 
1027  if (!window_size_node)
1028  std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
1029  else
1030  std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
1031 
1032  if (!quality_node)
1033  std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
1034  else
1035  std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
1036 
1037  if (!min_distance_node)
1038  std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
1039  else
1040  std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
1041 
1042  if (!harris_node)
1043  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
1044  else
1045  std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1046 
1047  if (!size_block_node)
1048  std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
1049  else
1050  std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
1051 
1052  if (!pyramid_lvl_node)
1053  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
1054  else
1055  std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1056  }
1057  }
1058 
1059  void read_lod(const pugi::xml_node &node)
1060  {
1061  bool use_lod_node = false;
1062  bool min_line_length_threshold_node = false;
1063  bool min_polygon_area_threshold_node = false;
1064 
1065  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1066  if (dataNode.type() == pugi::node_element) {
1067  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1068  if (iter_data != m_nodeMap.end()) {
1069  switch (iter_data->second) {
1070  case use_lod:
1071  m_useLod = (dataNode.text().as_int() != 0);
1072  use_lod_node = true;
1073  break;
1074 
1075  case min_line_length_threshold:
1076  m_minLineLengthThreshold = dataNode.text().as_double();
1077  min_line_length_threshold_node = true;
1078  break;
1079 
1080  case min_polygon_area_threshold:
1081  m_minPolygonAreaThreshold = dataNode.text().as_double();
1082  min_polygon_area_threshold_node = true;
1083  break;
1084 
1085  default:
1086  break;
1087  }
1088  }
1089  }
1090  }
1091 
1092  if (m_verbose) {
1093  if (!use_lod_node)
1094  std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1095  else
1096  std::cout << "lod : use lod : " << m_useLod << std::endl;
1097 
1098  if (!min_line_length_threshold_node)
1099  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1100  else
1101  std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1102 
1103  if (!min_polygon_area_threshold_node)
1104  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1105  else
1106  std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1107  }
1108  }
1109 
1110  void read_projection_error(const pugi::xml_node &node)
1111  {
1112  bool step_node = false;
1113  bool kernel_size_node = false;
1114 
1115  // current data values.
1116  double d_stp = m_projectionErrorMe.getSampleStep();
1117  std::string kernel_size_str;
1118 
1119  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1120  if (dataNode.type() == pugi::node_element) {
1121  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1122  if (iter_data != m_nodeMap.end()) {
1123  switch (iter_data->second) {
1124  case projection_error_sample_step:
1125  d_stp = dataNode.text().as_int();
1126  step_node = true;
1127  break;
1128 
1129  case projection_error_kernel_size:
1130  kernel_size_str = dataNode.text().as_string();
1131  kernel_size_node = true;
1132  break;
1133 
1134  default:
1135  break;
1136  }
1137  }
1138  }
1139  }
1140 
1141  m_projectionErrorMe.setSampleStep(d_stp);
1142 
1143  if (kernel_size_str == "3x3") {
1144  m_projectionErrorKernelSize = 1;
1145  }
1146  else if (kernel_size_str == "5x5") {
1147  m_projectionErrorKernelSize = 2;
1148  }
1149  else if (kernel_size_str == "7x7") {
1150  m_projectionErrorKernelSize = 3;
1151  }
1152  else if (kernel_size_str == "9x9") {
1153  m_projectionErrorKernelSize = 4;
1154  }
1155  else if (kernel_size_str == "11x11") {
1156  m_projectionErrorKernelSize = 5;
1157  }
1158  else if (kernel_size_str == "13x13") {
1159  m_projectionErrorKernelSize = 6;
1160  }
1161  else if (kernel_size_str == "15x15") {
1162  m_projectionErrorKernelSize = 7;
1163  }
1164  else {
1165  std::cerr << "Unsupported kernel size." << std::endl;
1166  }
1167 
1168  if (m_verbose) {
1169  if (!step_node)
1170  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
1171  << std::endl;
1172  else
1173  std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1174 
1175  if (!kernel_size_node)
1176  std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
1177  << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
1178  else
1179  std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1180  }
1181  }
1182 
1188  void read_sample_deprecated(const pugi::xml_node &node)
1189  {
1190  bool step_node = false;
1191  // bool nb_sample_node = false;
1192 
1193  // current data values.
1194  double d_stp = m_ecm.getSampleStep();
1195 
1196  for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1197  if (dataNode.type() == pugi::node_element) {
1198  std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1199  if (iter_data != m_nodeMap.end()) {
1200  switch (iter_data->second) {
1201  case step:
1202  d_stp = dataNode.text().as_int();
1203  step_node = true;
1204  break;
1205 
1206  default:
1207  break;
1208  }
1209  }
1210  }
1211  }
1212 
1213  m_ecm.setSampleStep(d_stp);
1214 
1215  if (m_verbose) {
1216  if (!step_node)
1217  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1218  else
1219  std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1220 
1221  std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1222  std::cout << " It should be moved in the ecm node (me : sample)." << std::endl;
1223  }
1224  }
1225 
1226  double getAngleAppear() const { return m_angleAppear; }
1227  double getAngleDisappear() const { return m_angleDisappear; }
1228 
1229  void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1230 
1231  void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1232 
1233  unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1234  unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1235 
1237  {
1238  return m_depthNormalFeatureEstimationMethod;
1239  }
1240  int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1241  int getDepthNormalPclPlaneEstimationRansacMaxIter() const { return m_depthNormalPclPlaneEstimationRansacMaxIter; }
1243  {
1244  return m_depthNormalPclPlaneEstimationRansacThreshold;
1245  }
1246  unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1247  unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1248 
1249  double getFarClippingDistance() const { return m_farClipping; }
1250  bool getFovClipping() const { return m_fovClipping; }
1251 
1252  unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1253  double getKltHarrisParam() const { return m_kltHarrisParam; }
1254  unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1255  unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1256  double getKltMinDistance() const { return m_kltMinDist; }
1257  unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1258  double getKltQuality() const { return m_kltQualityValue; }
1259  unsigned int getKltWindowSize() const { return m_kltWinSize; }
1260 
1261  bool getLodState() const { return m_useLod; }
1262  double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1263  double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1264 
1265  double getNearClippingDistance() const { return m_nearClipping; }
1266 
1267  void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1268  unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1269 
1270  bool hasFarClippingDistance() const { return m_hasFarClipping; }
1271  bool hasNearClippingDistance() const { return m_hasNearClipping; }
1272 
1273  void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1274  void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1275 
1276  void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1277 
1278  void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1279  void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1281  {
1282  m_depthNormalFeatureEstimationMethod = method;
1283  }
1284  void setDepthNormalPclPlaneEstimationMethod(int method) { m_depthNormalPclPlaneEstimationMethod = method; }
1286  {
1287  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1288  }
1290  {
1291  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1292  }
1293  void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1294  void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1295 
1296  void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1297 
1298  void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1299 
1300  void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1301  void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1302  void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1303  void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1304  void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1305  void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1306  void setKltQuality(const double &q) { m_kltQualityValue = q; }
1307  void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1308 
1309  void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1310 
1311  void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1312  void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1313 
1314  void setVerbose(bool verbose) { m_verbose = verbose; }
1315 
1316 protected:
1318  int m_parserType;
1320  vpCameraParameters m_cam;
1322  double m_angleAppear;
1324  double m_angleDisappear;
1326  bool m_hasNearClipping;
1328  double m_nearClipping;
1330  bool m_hasFarClipping;
1332  double m_farClipping;
1334  bool m_fovClipping;
1335  // LOD
1337  bool m_useLod;
1339  double m_minLineLengthThreshold;
1341  double m_minPolygonAreaThreshold;
1342  // Edge
1344  vpMe m_ecm;
1345  // KLT
1347  unsigned int m_kltMaskBorder;
1349  unsigned int m_kltMaxFeatures;
1351  unsigned int m_kltWinSize;
1353  double m_kltQualityValue;
1355  double m_kltMinDist;
1357  double m_kltHarrisParam;
1359  unsigned int m_kltBlockSize;
1361  unsigned int m_kltPyramidLevels;
1362  // Depth normal
1364  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1366  int m_depthNormalPclPlaneEstimationMethod;
1368  int m_depthNormalPclPlaneEstimationRansacMaxIter;
1370  double m_depthNormalPclPlaneEstimationRansacThreshold;
1372  unsigned int m_depthNormalSamplingStepX;
1374  unsigned int m_depthNormalSamplingStepY;
1375  // Depth dense
1377  unsigned int m_depthDenseSamplingStepX;
1379  unsigned int m_depthDenseSamplingStepY;
1380  // Projection error
1382  vpMe m_projectionErrorMe;
1384  unsigned int m_projectionErrorKernelSize;
1385  std::map<std::string, int> m_nodeMap;
1387  bool m_verbose;
1388 
1389  enum vpDataToParseMb
1390  {
1391  //<conf>
1392  conf,
1393  //<face>
1394  face,
1395  angle_appear,
1396  angle_disappear,
1397  near_clipping,
1398  far_clipping,
1399  fov_clipping,
1400  //<camera>
1401  camera,
1402  height,
1403  width,
1404  u0,
1405  v0,
1406  px,
1407  py,
1408  lod,
1409  use_lod,
1410  min_line_length_threshold,
1411  min_polygon_area_threshold,
1412  //<ecm>
1413  ecm,
1414  mask,
1415  size,
1416  nb_mask,
1417  range,
1418  tracking,
1419  contrast,
1420  edge_threshold,
1421  edge_threshold_type,
1422  mu1,
1423  mu2,
1424  sample,
1425  step,
1426  //<klt>
1427  klt,
1428  mask_border,
1429  max_features,
1430  window_size,
1431  quality,
1432  min_distance,
1433  harris,
1434  size_block,
1435  pyramid_lvl,
1436  //<depth_normal>
1437  depth_normal,
1438  feature_estimation_method,
1439  PCL_plane_estimation,
1440  PCL_plane_estimation_method,
1441  PCL_plane_estimation_ransac_max_iter,
1442  PCL_plane_estimation_ransac_threshold,
1443  depth_sampling_step,
1444  depth_sampling_step_X,
1445  depth_sampling_step_Y,
1446  //<depth_dense>
1447  depth_dense,
1448  depth_dense_sampling_step,
1449  depth_dense_sampling_step_X,
1450  depth_dense_sampling_step_Y,
1451  //<projection_error>
1452  projection_error,
1453  projection_error_sample_step,
1454  projection_error_kernel_size
1455  };
1456 
1460  void init()
1461  {
1462  //<conf>
1463  m_nodeMap["conf"] = conf;
1464  //<face>
1465  m_nodeMap["face"] = face;
1466  m_nodeMap["angle_appear"] = angle_appear;
1467  m_nodeMap["angle_disappear"] = angle_disappear;
1468  m_nodeMap["near_clipping"] = near_clipping;
1469  m_nodeMap["far_clipping"] = far_clipping;
1470  m_nodeMap["fov_clipping"] = fov_clipping;
1471  //<camera>
1472  m_nodeMap["camera"] = camera;
1473  m_nodeMap["height"] = height;
1474  m_nodeMap["width"] = width;
1475  m_nodeMap["u0"] = u0;
1476  m_nodeMap["v0"] = v0;
1477  m_nodeMap["px"] = px;
1478  m_nodeMap["py"] = py;
1479  //<lod>
1480  m_nodeMap["lod"] = lod;
1481  m_nodeMap["use_lod"] = use_lod;
1482  m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1483  m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1484  //<ecm>
1485  m_nodeMap["ecm"] = ecm;
1486  m_nodeMap["mask"] = mask;
1487  m_nodeMap["size"] = size;
1488  m_nodeMap["nb_mask"] = nb_mask;
1489  m_nodeMap["range"] = range;
1490  m_nodeMap["tracking"] = tracking;
1491  m_nodeMap["contrast"] = contrast;
1492  m_nodeMap["edge_threshold_type"] = edge_threshold_type;
1493  m_nodeMap["edge_threshold"] = edge_threshold;
1494  m_nodeMap["mu1"] = mu1;
1495  m_nodeMap["mu2"] = mu2;
1496  m_nodeMap["sample"] = sample;
1497  m_nodeMap["step"] = step;
1498  //<klt>
1499  m_nodeMap["klt"] = klt;
1500  m_nodeMap["mask_border"] = mask_border;
1501  m_nodeMap["max_features"] = max_features;
1502  m_nodeMap["window_size"] = window_size;
1503  m_nodeMap["quality"] = quality;
1504  m_nodeMap["min_distance"] = min_distance;
1505  m_nodeMap["harris"] = harris;
1506  m_nodeMap["size_block"] = size_block;
1507  m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1508  //<depth_normal>
1509  m_nodeMap["depth_normal"] = depth_normal;
1510  m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1511  m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1512  m_nodeMap["method"] = PCL_plane_estimation_method;
1513  m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1514  m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1515  m_nodeMap["sampling_step"] = depth_sampling_step;
1516  m_nodeMap["step_X"] = depth_sampling_step_X;
1517  m_nodeMap["step_Y"] = depth_sampling_step_Y;
1518  //<depth_dense>
1519  m_nodeMap["depth_dense"] = depth_dense;
1520  m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1521  m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1522  m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1523  //<projection_error>
1524  m_nodeMap["projection_error"] = projection_error;
1525  m_nodeMap["sample_step"] = projection_error_sample_step;
1526  m_nodeMap["kernel_size"] = projection_error_kernel_size;
1527  }
1528 
1529 private:
1530  static bool m_call_setlocale;
1531 };
1532 
1533 bool vpMbtXmlGenericParser::Impl::m_call_setlocale = true;
1534 
1535 #endif // DOXYGEN_SHOULD_SKIP_THIS
1536 
1537 vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1538 { }
1539 
1541 
1547 void vpMbtXmlGenericParser::parse(const std::string &filename) { m_impl->parse(filename); }
1548 
1552 double vpMbtXmlGenericParser::getAngleAppear() const { return m_impl->getAngleAppear(); }
1553 
1557 double vpMbtXmlGenericParser::getAngleDisappear() const { return m_impl->getAngleDisappear(); }
1558 
1559 void vpMbtXmlGenericParser::getCameraParameters(vpCameraParameters &cam) const { m_impl->getCameraParameters(cam); }
1560 
1564 void vpMbtXmlGenericParser::getEdgeMe(vpMe &ecm) const { m_impl->getEdgeMe(ecm); }
1565 
1569 unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepX() const { return m_impl->getDepthDenseSamplingStepX(); }
1570 
1574 unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepY() const { return m_impl->getDepthDenseSamplingStepY(); }
1575 
1580 {
1581  return m_impl->getDepthNormalFeatureEstimationMethod();
1582 }
1583 
1588 {
1589  return m_impl->getDepthNormalPclPlaneEstimationMethod();
1590 }
1591 
1596 {
1597  return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1598 }
1599 
1604 {
1605  return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1606 }
1607 
1612 {
1613  return m_impl->getDepthNormalSamplingStepX();
1614 }
1615 
1620 {
1621  return m_impl->getDepthNormalSamplingStepY();
1622 }
1623 
1627 double vpMbtXmlGenericParser::getFarClippingDistance() const { return m_impl->getFarClippingDistance(); }
1628 
1632 bool vpMbtXmlGenericParser::getFovClipping() const { return m_impl->getFovClipping(); }
1633 
1637 unsigned int vpMbtXmlGenericParser::getKltBlockSize() const { return m_impl->getKltBlockSize(); }
1638 
1642 double vpMbtXmlGenericParser::getKltHarrisParam() const { return m_impl->getKltHarrisParam(); }
1643 
1647 unsigned int vpMbtXmlGenericParser::getKltMaskBorder() const { return m_impl->getKltMaskBorder(); }
1648 
1652 unsigned int vpMbtXmlGenericParser::getKltMaxFeatures() const { return m_impl->getKltMaxFeatures(); }
1653 
1657 double vpMbtXmlGenericParser::getKltMinDistance() const { return m_impl->getKltMinDistance(); }
1658 
1662 unsigned int vpMbtXmlGenericParser::getKltPyramidLevels() const { return m_impl->getKltPyramidLevels(); }
1663 
1667 double vpMbtXmlGenericParser::getKltQuality() const { return m_impl->getKltQuality(); }
1668 
1672 unsigned int vpMbtXmlGenericParser::getKltWindowSize() const { return m_impl->getKltWindowSize(); }
1673 
1677 bool vpMbtXmlGenericParser::getLodState() const { return m_impl->getLodState(); }
1678 
1682 double vpMbtXmlGenericParser::getLodMinLineLengthThreshold() const { return m_impl->getLodMinLineLengthThreshold(); }
1683 
1687 double vpMbtXmlGenericParser::getLodMinPolygonAreaThreshold() const { return m_impl->getLodMinPolygonAreaThreshold(); }
1688 
1692 double vpMbtXmlGenericParser::getNearClippingDistance() const { return m_impl->getNearClippingDistance(); }
1693 
1697 void vpMbtXmlGenericParser::getProjectionErrorMe(vpMe &me) const { m_impl->getProjectionErrorMe(me); }
1698 
1700 {
1701  return m_impl->getProjectionErrorKernelSize();
1702 }
1703 
1709 bool vpMbtXmlGenericParser::hasFarClippingDistance() const { return m_impl->hasFarClippingDistance(); }
1710 
1716 bool vpMbtXmlGenericParser::hasNearClippingDistance() const { return m_impl->hasNearClippingDistance(); }
1717 
1723 void vpMbtXmlGenericParser::setAngleAppear(const double &aappear) { m_impl->setAngleAppear(aappear); }
1724 
1730 void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear) { m_impl->setAngleDisappear(adisappear); }
1731 
1737 void vpMbtXmlGenericParser::setCameraParameters(const vpCameraParameters &cam) { m_impl->setCameraParameters(cam); }
1738 
1745 {
1746  m_impl->setDepthDenseSamplingStepX(stepX);
1747 }
1748 
1755 {
1756  m_impl->setDepthDenseSamplingStepY(stepY);
1757 }
1758 
1766 {
1767  m_impl->setDepthNormalFeatureEstimationMethod(method);
1768 }
1769 
1776 {
1777  m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1778 }
1779 
1786 {
1787  m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1788 }
1789 
1796 {
1797  m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1798 }
1799 
1806 {
1807  m_impl->setDepthNormalSamplingStepX(stepX);
1808 }
1809 
1816 {
1817  m_impl->setDepthNormalSamplingStepY(stepY);
1818 }
1819 
1825 void vpMbtXmlGenericParser::setEdgeMe(const vpMe &moving_edge) { m_impl->setEdgeMe(moving_edge); }
1826 
1832 void vpMbtXmlGenericParser::setFarClippingDistance(const double &fclip) { m_impl->setFarClippingDistance(fclip); }
1833 
1839 void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs) { m_impl->setKltBlockSize(bs); }
1840 
1846 void vpMbtXmlGenericParser::setKltHarrisParam(const double &hp) { m_impl->setKltHarrisParam(hp); }
1847 
1853 void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb) { m_impl->setKltMaskBorder(mb); }
1854 
1860 void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF) { m_impl->setKltMaxFeatures(mF); }
1861 
1867 void vpMbtXmlGenericParser::setKltMinDistance(const double &mD) { m_impl->setKltMinDistance(mD); }
1868 
1874 void vpMbtXmlGenericParser::setKltPyramidLevels(const unsigned int &pL) { m_impl->setKltPyramidLevels(pL); }
1875 
1881 void vpMbtXmlGenericParser::setKltQuality(const double &q) { m_impl->setKltQuality(q); }
1882 
1888 void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w) { m_impl->setKltWindowSize(w); }
1889 
1895 void vpMbtXmlGenericParser::setNearClippingDistance(const double &nclip) { m_impl->setNearClippingDistance(nclip); }
1896 
1902 void vpMbtXmlGenericParser::setProjectionErrorMe(const vpMe &me) { m_impl->setProjectionErrorMe(me); }
1903 
1910 {
1911  m_impl->setProjectionErrorKernelSize(size);
1912 }
1913 
1919 void vpMbtXmlGenericParser::setVerbose(bool verbose) { m_impl->setVerbose(verbose); }
1921 #elif !defined(VISP_BUILD_SHARED_LIBS)
1922 // Work around to avoid warning: libvisp_core.a(vpMbtXmlGenericParser.cpp.o) has no symbols
1923 void dummy_vpMbtXmlGenericParser() { };
1924 
1925 #endif
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
Definition: vpException.h:60
@ ioError
I/O error.
Definition: vpException.h:67
@ badValue
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:73
void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter)
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
unsigned int getKltMaxFeatures() const
void setProjectionErrorMe(const vpMe &me)
unsigned int getDepthNormalSamplingStepX() const
unsigned int getProjectionErrorKernelSize() const
void setKltMinDistance(const double &mD)
unsigned int getKltBlockSize() const
void getCameraParameters(vpCameraParameters &cam) const
vpMbtXmlGenericParser(int type=EDGE_PARSER)
void setDepthDenseSamplingStepY(unsigned int stepY)
void setEdgeMe(const vpMe &ecm)
unsigned int getDepthNormalSamplingStepY() const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
void setKltMaskBorder(const unsigned int &mb)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
void getEdgeMe(vpMe &ecm) const
double getLodMinLineLengthThreshold() const
void setDepthNormalPclPlaneEstimationMethod(int method)
void setDepthNormalSamplingStepX(unsigned int stepX)
unsigned int getKltMaskBorder() const
void setAngleDisappear(const double &adisappear)
void setDepthDenseSamplingStepX(unsigned int stepX)
void setProjectionErrorKernelSize(const unsigned int &size)
void setKltPyramidLevels(const unsigned int &pL)
void setKltWindowSize(const unsigned int &w)
void setKltMaxFeatures(const unsigned int &mF)
int getDepthNormalPclPlaneEstimationMethod() const
void setAngleAppear(const double &aappear)
void setKltBlockSize(const unsigned int &bs)
void setKltHarrisParam(const double &hp)
unsigned int getDepthDenseSamplingStepY() const
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void parse(const std::string &filename)
void setNearClippingDistance(const double &nclip)
void setKltQuality(const double &q)
void getProjectionErrorMe(vpMe &me) const
unsigned int getKltPyramidLevels() const
void setFarClippingDistance(const double &fclip)
unsigned int getKltWindowSize() const
void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
unsigned int getDepthDenseSamplingStepX() const
void setCameraParameters(const vpCameraParameters &cam)
double getLodMinPolygonAreaThreshold() const
void setDepthNormalSamplingStepY(unsigned int stepY)
Definition: vpMe.h:130
vpLikelihoodThresholdType
Definition: vpMe.h:136
void init(VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &Iinput, VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &IcannyVisp, VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > *p_dIx, VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > *p_dIy, VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > *p_IcannyimgFilter)
Initialize the different displays.