Visual Servoing Platform  version 3.1.0
vpMbtXmlGenericParser.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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  };
76 
77 protected:
83  double m_angleAppear;
93  double m_farClipping;
96  // LOD
98  bool m_useLod;
103  // Edge
106  // KLT
108  unsigned int m_kltMaskBorder;
110  unsigned int m_kltMaxFeatures;
112  unsigned int m_kltWinSize;
116  double m_kltMinDist;
120  unsigned int m_kltBlockSize;
122  unsigned int m_kltPyramidLevels;
123  // Depth normal
136  // Depth dense
141 
143  //<conf>
145  //<face>
152  //<camera>
156  u0,
157  v0,
158  px,
159  py,
164  //<ecm>
177  //<klt>
187  //<depth_normal>
197  //<depth_dense>
201  depth_dense_sampling_step_Y
202  };
203 
204 public:
207  explicit vpMbtXmlGenericParser(const vpParserType &type = EDGE_PARSER);
208  virtual ~vpMbtXmlGenericParser();
209 
213  inline double getAngleAppear() const { return m_angleAppear; }
214 
218  inline double getAngleDisappear() const { return m_angleDisappear; }
219 
220  void getCameraParameters(vpCameraParameters &_cam) const { _cam = m_cam; }
221 
225  void getEdgeMe(vpMe &_ecm) const { _ecm = m_ecm; }
226 
230  inline unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
231 
235  inline unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
236 
241  {
242  return m_depthNormalFeatureEstimationMethod;
243  }
244 
248  inline int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
249 
254  {
255  return m_depthNormalPclPlaneEstimationRansacMaxIter;
256  }
257 
262  {
263  return m_depthNormalPclPlaneEstimationRansacThreshold;
264  }
265 
269  inline unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
270 
274  inline unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
275 
279  inline double getFarClippingDistance() const { return m_farClipping; }
280 
284  inline bool getFovClipping() const { return m_fovClipping; }
285 
289  inline unsigned int getKltBlockSize() const { return m_kltBlockSize; }
290 
294  inline double getKltHarrisParam() const { return m_kltHarrisParam; }
295 
299  inline unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
300 
304  inline unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
305 
309  inline double getKltMinDistance() const { return m_kltMinDist; }
310 
314  inline unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
315 
319  inline double getKltQuality() const { return m_kltQualityValue; }
320 
324  inline unsigned int getKltWindowSize() const { return m_kltWinSize; }
325 
329  inline bool getLodState() const { return m_useLod; }
330 
334  inline double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
335 
339  inline double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
340 
344  inline double getNearClippingDistance() const { return m_nearClipping; }
345 
351  inline bool hasFarClippingDistance() const { return m_hasFarClipping; }
352 
358  inline bool hasNearClippingDistance() const { return m_hasNearClipping; }
359 
360  void parse(const std::string &filename);
361 
362  virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node);
363 
369  inline void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
370 
376  inline void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
377 
383  inline void setCameraParameters(const vpCameraParameters &_cam) { m_cam = _cam; }
384 
390  inline void setDepthDenseSamplingStepX(const unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
391 
397  inline void setDepthDenseSamplingStepY(const unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
398 
405  {
406  m_depthNormalFeatureEstimationMethod = method;
407  }
408 
414  inline void setDepthNormalPclPlaneEstimationMethod(const int method)
415  {
416  m_depthNormalPclPlaneEstimationMethod = method;
417  }
418 
424  inline void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
425  {
426  m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
427  }
428 
434  inline void setDepthNormalPclPlaneEstimationRansacThreshold(const double threshold)
435  {
436  m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
437  }
438 
444  inline void setDepthNormalSamplingStepX(const unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
445 
451  inline void setDepthNormalSamplingStepY(const unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
452 
458  inline void setEdgeMe(const vpMe &_ecm) { m_ecm = _ecm; }
459 
465  inline void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
466 
472  inline void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
473 
479  inline void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
480 
486  inline void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
487 
493  inline void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
494 
500  inline void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
501 
507  inline void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
508 
514  inline void setKltQuality(const double &q) { m_kltQualityValue = q; }
515 
521  inline void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
522 
528  inline void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
529 
530  void writeMainClass(xmlNodePtr node);
532 
533 protected:
534  void init();
535 
536  void read_camera(xmlDocPtr doc, xmlNodePtr node);
537  void read_face(xmlDocPtr doc, xmlNodePtr node);
538  void read_lod(xmlDocPtr doc, xmlNodePtr node);
539 
540  // Edge
541  void read_ecm(xmlDocPtr doc, xmlNodePtr node);
542  void read_ecm_sample(xmlDocPtr doc, xmlNodePtr node);
543  void read_sample_deprecated(xmlDocPtr doc, xmlNodePtr node);
544  void read_ecm_mask(xmlDocPtr doc, xmlNodePtr node);
545  void read_ecm_range(xmlDocPtr doc, xmlNodePtr node);
546  void read_ecm_contrast(xmlDocPtr doc, xmlNodePtr node);
547 
548  // KLT
549  void read_klt(xmlDocPtr doc, xmlNodePtr node);
550 
551  // Depth normal
552  void read_depth_normal(xmlDocPtr doc, xmlNodePtr node);
553  void read_depth_normal_PCL(xmlDocPtr doc, xmlNodePtr node);
554  void read_depth_normal_sampling_step(xmlDocPtr doc, xmlNodePtr node);
555 
556  // Depth dense
557  void read_depth_dense(xmlDocPtr doc, xmlNodePtr node);
558  void read_depth_dense_sampling_step(xmlDocPtr doc, xmlNodePtr node);
559 };
560 
561 #endif
562 
563 #endif
unsigned int getDepthNormalSamplingStepY() const
unsigned int m_kltWinSize
Windows size.
unsigned int m_depthDenseSamplingStepX
Sampling step in X.
bool m_hasNearClipping
Is near clipping distance specified?
double m_minLineLengthThreshold
Minimum line length to track a segment when LOD is enabled.
int getDepthNormalPclPlaneEstimationMethod() const
void setKltQuality(const double &q)
void setKltPyramidLevels(const unsigned int &pL)
int m_depthNormalPclPlaneEstimationMethod
PCL plane estimation method.
double m_angleDisappear
Angle to determine if a face disappeared.
double getFarClippingDistance() const
double getDepthNormalPclPlaneEstimationRansacThreshold() const
virtual void writeMainClass(xmlNodePtr node)=0
Definition: vpMe.h:60
bool m_useLod
If true, the LOD is enabled, otherwise it is not.
void getCameraParameters(vpCameraParameters &_cam) const
double m_nearClipping
Near clipping distance.
unsigned int getKltBlockSize() const
void setKltMaskBorder(const unsigned int &mb)
double getNearClippingDistance() const
unsigned int m_depthDenseSamplingStepY
Sampling step in Y.
unsigned int getDepthDenseSamplingStepY() 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)
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)
bool m_fovClipping
Fov Clipping.
vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod
Feature estimation method.
Generic class defining intrinsic camera parameters.
unsigned int getKltWindowSize() const
unsigned int getKltMaxFeatures() const
vpCameraParameters m_cam
Camera parameters.
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)=0
unsigned int getDepthNormalSamplingStepX() const
void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
double m_farClipping
Near clipping distance.
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.
void setDepthDenseSamplingStepY(const unsigned int stepY)
unsigned int m_kltMaskBorder
Border of the mask used on Klt points.
double getLodMinLineLengthThreshold() const
void setNearClippingDistance(const double &nclip)
unsigned int getDepthDenseSamplingStepX() const
void setFarClippingDistance(const double &fclip)
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
unsigned int m_kltPyramidLevels
Number of pyramid levels.
unsigned int getKltMaskBorder() const
void setCameraParameters(const vpCameraParameters &_cam)
double m_kltHarrisParam
Harris free parameters.
void getEdgeMe(vpMe &_ecm) const
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.
double m_angleAppear
Angle to determine if a face appeared.
vpMe m_ecm
Moving edges parameters.
void setDepthNormalSamplingStepY(const unsigned int stepY)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
bool m_hasFarClipping
Is far clipping distance specified?
double getLodMinPolygonAreaThreshold() const
unsigned int getKltPyramidLevels() const
void parse(const std::string &filename)