Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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:
84  double m_angleAppear;
94  double m_farClipping;
97  // LOD
99  bool m_useLod;
104  // Edge
107  // KLT
109  unsigned int m_kltMaskBorder;
111  unsigned int m_kltMaxFeatures;
113  unsigned int m_kltWinSize;
117  double m_kltMinDist;
121  unsigned int m_kltBlockSize;
123  unsigned int m_kltPyramidLevels;
124  // Depth normal
137  // Depth dense
142  // Projection error
147 
149  //<conf>
151  //<face>
158  //<camera>
162  u0,
163  v0,
164  px,
165  py,
170  //<ecm>
183  //<klt>
193  //<depth_normal>
203  //<depth_dense>
208  //<projection_error>
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 
251  {
252  return m_depthNormalFeatureEstimationMethod;
253  }
254 
258  inline int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
259 
264  {
265  return m_depthNormalPclPlaneEstimationRansacMaxIter;
266  }
267 
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 
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
unsigned int m_kltWinSize
Windows size.
unsigned int m_depthDenseSamplingStepX
Sampling step in X.
double getFarClippingDistance() const
bool m_hasNearClipping
Is near clipping distance specified?
double m_minLineLengthThreshold
Minimum line length to track a segment when LOD is enabled.
double getKltMinDistance() const
void setKltQuality(const double &q)
double getNearClippingDistance() const
void setKltPyramidLevels(const unsigned int &pL)
int m_depthNormalPclPlaneEstimationMethod
PCL plane estimation method.
void getCameraParameters(vpCameraParameters &_cam) const
double m_angleDisappear
Angle to determine if a face disappeared.
bool hasNearClippingDistance() const
unsigned int getKltBlockSize() const
void setProjectionErrorKernelSize(const unsigned int &size)
virtual void writeMainClass(xmlNodePtr node)=0
Definition: vpMe.h:60
bool m_useLod
If true, the LOD is enabled, otherwise it is not.
double m_nearClipping
Near clipping distance.
double getLodMinLineLengthThreshold() const
void setKltMaskBorder(const unsigned int &mb)
unsigned int m_depthDenseSamplingStepY
Sampling step in Y.
unsigned int getProjectionErrorKernelSize() const
unsigned int m_kltBlockSize
Block size.
int m_depthNormalPclPlaneEstimationRansacMaxIter
PCL RANSAC maximum number of iterations.
This class intends to simplify the creation of xml parser based on the libxml2 third party library...
Definition: vpXmlParser.h:177
double m_kltMinDist
Minimum distance between klt points.
void setDepthNormalSamplingStepX(const unsigned int stepX)
Parse an Xml file to extract configuration parameters of a mbtConfig object.Data parser for the model...
unsigned int m_depthNormalSamplingStepX
Sampling step in X.
void setKltHarrisParam(const double &hp)
bool hasFarClippingDistance() const
void setDepthDenseSamplingStepX(const unsigned int stepX)
unsigned int m_depthNormalSamplingStepY
Sampling step in Y.
void setAngleDisappear(const double &adisappear)
void setEdgeMe(const vpMe &_ecm)
double m_kltQualityValue
Quality of the Klt points.
void setKltMinDistance(const double &mD)
void setProjectionErrorMe(const vpMe &me)
void getProjectionErrorMe(vpMe &me) const
bool m_fovClipping
Fov Clipping.
vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod
Feature estimation method.
Generic class defining intrinsic camera parameters.
double getKltHarrisParam() const
double getDepthNormalPclPlaneEstimationRansacThreshold() const
vpCameraParameters m_cam
Camera parameters.
void getEdgeMe(vpMe &_ecm) const
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)=0
void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
double getAngleDisappear() const
double m_farClipping
Near clipping distance.
unsigned int getDepthNormalSamplingStepX() const
void setKltWindowSize(const unsigned int &w)
double m_minPolygonAreaThreshold
Minimum polygon area to track a face when LOD is enabled.
void setAngleAppear(const double &aappear)
double m_depthNormalPclPlaneEstimationRansacThreshold
PCL RANSAC threshold.
vpParserType m_parserType
Parser type.
unsigned int m_projectionErrorKernelSize
Kernel size (actual_kernel_size = size*2 + 1) used for projection error computation.
void setDepthDenseSamplingStepY(const unsigned int stepY)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
unsigned int getKltPyramidLevels() const
unsigned int m_kltMaskBorder
Border of the mask used on Klt points.
unsigned int getKltMaskBorder() const
unsigned int getDepthDenseSamplingStepX() const
void setNearClippingDistance(const double &nclip)
void setFarClippingDistance(const double &fclip)
unsigned int getDepthDenseSamplingStepY() const
unsigned int m_kltPyramidLevels
Number of pyramid levels.
void setCameraParameters(const vpCameraParameters &_cam)
unsigned int getDepthNormalSamplingStepY() const
unsigned int getKltMaxFeatures() const
double m_kltHarrisParam
Harris free parameters.
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
void setDepthNormalPclPlaneEstimationMethod(const int method)
void setKltBlockSize(const unsigned int &bs)
void setDepthNormalPclPlaneEstimationRansacThreshold(const double threshold)
void setKltMaxFeatures(const unsigned int &mF)
unsigned int m_kltMaxFeatures
Maximum of Klt features.
vpMe m_projectionErrorMe
ME parameters for projection error computation.
double getLodMinPolygonAreaThreshold() const
double m_angleAppear
Angle to determine if a face appeared.
vpMe m_ecm
Moving edges parameters.
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
int getDepthNormalPclPlaneEstimationMethod() const
void setDepthNormalSamplingStepY(const unsigned int stepY)
unsigned int getKltWindowSize() const
bool m_hasFarClipping
Is far clipping distance specified?