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