Visual Servoing Platform  version 3.2.0
vpMbtXmlGenericParser.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Load XML Parameter for Model Based Tracker.
33  *
34  *****************************************************************************/
35 
42 #ifndef _vpMbtXmlGenericParser_h_
43 #define _vpMbtXmlGenericParser_h_
44 
45 #include <visp3/core/vpConfig.h>
46 
47 #ifdef VISP_HAVE_XML2
48 
49 #include <libxml/xmlmemory.h>
50 
51 #include <visp3/core/vpCameraParameters.h>
52 #include <visp3/core/vpXmlParser.h>
53 #include <visp3/mbt/vpMbtFaceDepthNormal.h>
54 #include <visp3/me/vpMe.h>
55 
64 class VISP_EXPORT vpMbtXmlGenericParser : public vpXmlParser
65 {
66 public:
67  enum vpParserType {
68  EDGE_PARSER = 1 << 0,
70  KLT_PARSER = 1 << 1,
71  DEPTH_NORMAL_PARSER = 1 << 2,
73  DEPTH_DENSE_PARSER = 1 << 3
75  , PROJECTION_ERROR_PARSER = 0
76  };
77 
78 protected:
80  vpParserType m_parserType;
82  vpCameraParameters m_cam;
84  double m_angleAppear;
86  double m_angleDisappear;
88  bool m_hasNearClipping;
90  double m_nearClipping;
92  bool m_hasFarClipping;
94  double m_farClipping;
96  bool m_fovClipping;
97  // LOD
99  bool m_useLod;
101  double m_minLineLengthThreshold;
103  double m_minPolygonAreaThreshold;
104  // Edge
106  vpMe m_ecm;
107  // KLT
109  unsigned int m_kltMaskBorder;
111  unsigned int m_kltMaxFeatures;
113  unsigned int m_kltWinSize;
115  double m_kltQualityValue;
117  double m_kltMinDist;
119  double m_kltHarrisParam;
121  unsigned int m_kltBlockSize;
123  unsigned int m_kltPyramidLevels;
124  // Depth normal
126  vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
128  int m_depthNormalPclPlaneEstimationMethod;
130  int m_depthNormalPclPlaneEstimationRansacMaxIter;
132  double m_depthNormalPclPlaneEstimationRansacThreshold;
134  unsigned int m_depthNormalSamplingStepX;
136  unsigned int m_depthNormalSamplingStepY;
137  // Depth dense
139  unsigned int m_depthDenseSamplingStepX;
141  unsigned int m_depthDenseSamplingStepY;
142  // Projection error
144  vpMe m_projectionErrorMe;
146  unsigned int m_projectionErrorKernelSize;
147 
148  enum vpDataToParseMb {
149  //<conf>
150  conf,
151  //<face>
152  face,
153  angle_appear,
154  angle_disappear,
155  near_clipping,
156  far_clipping,
157  fov_clipping,
158  //<camera>
159  camera,
160  height,
161  width,
162  u0,
163  v0,
164  px,
165  py,
166  lod,
167  use_lod,
168  min_line_length_threshold,
169  min_polygon_area_threshold,
170  //<ecm>
171  ecm,
172  mask,
173  size,
174  nb_mask,
175  range,
176  tracking,
177  contrast,
178  edge_threshold,
179  mu1,
180  mu2,
181  sample,
182  step,
183  //<klt>
184  klt,
185  mask_border,
186  max_features,
187  window_size,
188  quality,
189  min_distance,
190  harris,
191  size_block,
192  pyramid_lvl,
193  //<depth_normal>
194  depth_normal,
195  feature_estimation_method,
196  PCL_plane_estimation,
197  PCL_plane_estimation_method,
198  PCL_plane_estimation_ransac_max_iter,
199  PCL_plane_estimation_ransac_threshold,
200  depth_sampling_step,
201  depth_sampling_step_X,
202  depth_sampling_step_Y,
203  //<depth_dense>
204  depth_dense,
205  depth_dense_sampling_step,
206  depth_dense_sampling_step_X,
207  depth_dense_sampling_step_Y,
208  //<projection_error>
209  projection_error,
210  projection_error_sample_step,
211  projection_error_kernel_size
212  };
213 
214 public:
217  explicit vpMbtXmlGenericParser(const vpParserType &type = EDGE_PARSER);
218  virtual ~vpMbtXmlGenericParser();
219 
223  inline double getAngleAppear() const { return m_angleAppear; }
224 
228  inline double getAngleDisappear() const { return m_angleDisappear; }
229 
230  void getCameraParameters(vpCameraParameters &_cam) const { _cam = m_cam; }
231 
235  void getEdgeMe(vpMe &_ecm) const { _ecm = m_ecm; }
236 
240  inline unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
241 
245  inline unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
246 
250  vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
251  {
252  return m_depthNormalFeatureEstimationMethod;
253  }
254 
258  inline int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
259 
263  inline int getDepthNormalPclPlaneEstimationRansacMaxIter() const
264  {
265  return m_depthNormalPclPlaneEstimationRansacMaxIter;
266  }
267 
271  inline double getDepthNormalPclPlaneEstimationRansacThreshold() const
272  {
273  return m_depthNormalPclPlaneEstimationRansacThreshold;
274  }
275 
279  inline unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
280 
284  inline unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
285 
289  inline double getFarClippingDistance() const { return m_farClipping; }
290 
294  inline bool getFovClipping() const { return m_fovClipping; }
295 
299  inline unsigned int getKltBlockSize() const { return m_kltBlockSize; }
300 
304  inline double getKltHarrisParam() const { return m_kltHarrisParam; }
305 
309  inline unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
310 
314  inline unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
315 
319  inline double getKltMinDistance() const { return m_kltMinDist; }
320 
324  inline unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
325 
329  inline double getKltQuality() const { return m_kltQualityValue; }
330 
334  inline unsigned int getKltWindowSize() const { return m_kltWinSize; }
335 
339  inline bool getLodState() const { return m_useLod; }
340 
344  inline double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
345 
349  inline double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
350 
354  inline double getNearClippingDistance() const { return m_nearClipping; }
355 
359  inline void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
360 
361  inline unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
362 
368  inline bool hasFarClippingDistance() const { return m_hasFarClipping; }
369 
375  inline bool hasNearClippingDistance() const { return m_hasNearClipping; }
376 
377  virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node);
378 
384  inline void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
385 
391  inline void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
392 
398  inline void setCameraParameters(const vpCameraParameters &_cam) { m_cam = _cam; }
399 
405  inline void setDepthDenseSamplingStepX(const unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
406 
412  inline void setDepthDenseSamplingStepY(const unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
413 
419  inline void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
420  {
421  m_depthNormalFeatureEstimationMethod = method;
422  }
423 
429  inline void setDepthNormalPclPlaneEstimationMethod(const int method)
430  {
431  m_depthNormalPclPlaneEstimationMethod = method;
432  }
433 
439  inline void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
440  {
441  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
442  }
443 
449  inline void setDepthNormalPclPlaneEstimationRansacThreshold(const double threshold)
450  {
451  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
452  }
453 
459  inline void setDepthNormalSamplingStepX(const unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
460 
466  inline void setDepthNormalSamplingStepY(const unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
467 
473  inline void setEdgeMe(const vpMe &_ecm) { m_ecm = _ecm; }
474 
480  inline void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
481 
487  inline void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
488 
494  inline void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
495 
501  inline void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
502 
508  inline void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
509 
515  inline void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
516 
522  inline void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
523 
529  inline void setKltQuality(const double &q) { m_kltQualityValue = q; }
530 
536  inline void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
537 
543  inline void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
544 
550  inline void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
551 
557  inline void setProjectionErrorKernelSize(const unsigned int &size) { m_projectionErrorKernelSize = size; }
558 
559  void writeMainClass(xmlNodePtr node);
561 
562 protected:
563  void init();
564 
565  void read_camera(xmlDocPtr doc, xmlNodePtr node);
566  void read_face(xmlDocPtr doc, xmlNodePtr node);
567  void read_lod(xmlDocPtr doc, xmlNodePtr node);
568 
569  // Edge
570  void read_ecm(xmlDocPtr doc, xmlNodePtr node);
571  void read_ecm_sample(xmlDocPtr doc, xmlNodePtr node);
572  void read_sample_deprecated(xmlDocPtr doc, xmlNodePtr node);
573  void read_ecm_mask(xmlDocPtr doc, xmlNodePtr node);
574  void read_ecm_range(xmlDocPtr doc, xmlNodePtr node);
575  void read_ecm_contrast(xmlDocPtr doc, xmlNodePtr node);
576 
577  // KLT
578  void read_klt(xmlDocPtr doc, xmlNodePtr node);
579 
580  // Depth normal
581  void read_depth_normal(xmlDocPtr doc, xmlNodePtr node);
582  void read_depth_normal_PCL(xmlDocPtr doc, xmlNodePtr node);
583  void read_depth_normal_sampling_step(xmlDocPtr doc, xmlNodePtr node);
584 
585  // Depth dense
586  void read_depth_dense(xmlDocPtr doc, xmlNodePtr node);
587  void read_depth_dense_sampling_step(xmlDocPtr doc, xmlNodePtr node);
588 
589  // Projection error
590  void read_projection_error(xmlDocPtr doc, xmlNodePtr node);
591 };
592 
593 #endif
594 
595 #endif
vpMbtFaceDepthNormal::vpFeatureEstimationType
vpFeatureEstimationType
Definition: vpMbtFaceDepthNormal.h:60
vpMbtXmlGenericParser::vpParserType
vpParserType
Definition: vpMbtXmlGenericParser.h:66
vpXmlParser
This class intends to simplify the creation of xml parser based on the libxml2 third party library.
Definition: vpXmlParser.h:176
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition: vpCameraParameters.h:232
vpMbtXmlGenericParser::vpDataToParseMb
vpDataToParseMb
Definition: vpMbtXmlGenericParser.h:147
vpXmlParser::writeMainClass
virtual void writeMainClass(xmlNodePtr node)=0
vpMe
Definition: vpMe.h:59
vpXmlParser::readMainClass
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)=0
vpMbtXmlGenericParser
Parse an Xml file to extract configuration parameters of a mbtConfig object.
Definition: vpMbtXmlGenericParser.h:63