Visual Servoing Platform  version 3.1.0
vpMbtEdgeKltXmlParser.cpp
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 parameters of the Model based tracker (using edges and point
33  *features).
34  *
35  * Authors:
36  * Aurelien Yol
37  *
38  *****************************************************************************/
39 #include <visp3/core/vpConfig.h>
40 
41 #ifdef VISP_HAVE_XML2
42 
43 #include <iostream>
44 #include <map>
45 
46 #include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */
47 
48 #include <visp3/mbt/vpMbtEdgeKltXmlParser.h>
49 
55 
60 
65 {
68 
74 }
75 
82 void vpMbtEdgeKltXmlParser::parse(const char *filename)
83 {
84  std::string file = filename;
85  vpXmlParser::parse(file);
86 }
87 
93 void vpMbtEdgeKltXmlParser::writeMainClass(xmlNodePtr /*node*/)
94 {
95  throw vpException(vpException::notImplementedError, "Not yet implemented.");
96 }
97 
105 void vpMbtEdgeKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node)
106 {
107  bool camera_node = false;
108  bool face_node = false;
109  bool ecm_node = false;
110  bool klt_node = false;
111  bool lod_node = false;
112 
113  for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
114  if (dataNode->type == XML_ELEMENT_NODE) {
115  std::map<std::string, int>::iterator iter_data = this->nodeMap.find((char *)dataNode->name);
116  if (iter_data != nodeMap.end()) {
117  switch (iter_data->second) {
119  this->read_camera(doc, dataNode);
120  camera_node = true;
121  } break;
123  this->read_face(doc, dataNode);
124  face_node = true;
125  } break;
127  this->read_klt(doc, dataNode);
128  klt_node = true;
129  } break;
131  this->read_ecm(doc, dataNode);
132  ecm_node = true;
133  } break;
134  case sample: {
135  this->read_sample_deprecated(doc, dataNode);
136  } break;
138  this->read_lod(doc, dataNode);
139  lod_node = true;
140  } break;
141  default: {
142  // vpTRACE("unknown tag in read_sample : %d, %s",
143  // iter_data->second, (iter_data->first).c_str());
144  } break;
145  }
146  }
147  }
148  }
149 
150  if (!camera_node) {
151  std::cout << "camera : u0 : " << this->cam.get_u0() << " (default)" << std::endl;
152  std::cout << "camera : v0 : " << this->cam.get_v0() << " (default)" << std::endl;
153  std::cout << "camera : px : " << this->cam.get_px() << " (default)" << std::endl;
154  std::cout << "camera : py : " << this->cam.get_py() << " (default)" << std::endl;
155  }
156 
157  if (!face_node) {
158  std::cout << "face : Angle Appear : " << angleAppear << " (default)" << std::endl;
159  std::cout << "face : Angle Disappear : " << angleDisappear << " (default)" << std::endl;
160  }
161 
162  if (!klt_node) {
163  std::cout << "klt : Mask Border : " << maskBorder << " (default)" << std::endl;
164  std::cout << "klt : Max Features : " << maxFeatures << " (default)" << std::endl;
165  std::cout << "klt : Windows Size : " << winSize << " (default)" << std::endl;
166  std::cout << "klt : Quality : " << qualityValue << " (default)" << std::endl;
167  std::cout << "klt : Min Distance : " << minDist << " (default)" << std::endl;
168  std::cout << "klt : Harris Parameter : " << harrisParam << " (default)" << std::endl;
169  std::cout << "klt : Block Size : " << blockSize << " (default)" << std::endl;
170  std::cout << "klt : Pyramid Levels : " << pyramidLevels << " (default)" << std::endl;
171  }
172 
173  if (!ecm_node) {
174  std::cout << "ecm : mask : size : " << this->m_ecm.getMaskSize() << " (default)" << std::endl;
175  std::cout << "ecm : mask : nb_mask : " << this->m_ecm.getMaskNumber() << " (default)" << std::endl;
176  std::cout << "ecm : range : tracking : " << this->m_ecm.getRange() << " (default)" << std::endl;
177  std::cout << "ecm : contrast : threshold : " << this->m_ecm.getThreshold() << " (default)" << std::endl;
178  std::cout << "ecm : contrast : mu1 : " << this->m_ecm.getMu1() << " (default)" << std::endl;
179  std::cout << "ecm : contrast : mu2 : " << this->m_ecm.getMu2() << " (default)" << std::endl;
180  std::cout << "ecm : sample : sample_step : " << this->m_ecm.getSampleStep() << " (default)" << std::endl;
181  }
182 
183  if (!lod_node) {
184  std::cout << "lod : use lod : " << useLod << " (default)" << std::endl;
185  std::cout << "lod : min line length threshold : " << minLineLengthThreshold << " (default)" << std::endl;
186  std::cout << "lod : min polygon area threshold : " << minPolygonAreaThreshold << " (default)" << std::endl;
187  }
188 }
189 
190 #elif !defined(VISP_BUILD_SHARED_LIBS)
191 // Work arround to avoid warning: libvisp_mbt.a(vpMbtEdgeKltXmlParser.cpp.o)
192 // has no symbols
193 void dummy_vpMbtEdgeKltXmlParser(){};
194 #endif
unsigned int winSize
Windows size.
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)
vpCameraParameters cam
Camera parameters.
Definition: vpMbXmlParser.h:69
void parse(const char *filename)
void read_lod(xmlDocPtr doc, xmlNodePtr node)
double minDist
Minimum distance between klt points.
unsigned int maskBorder
Border of the mask used on Klt points.
double angleAppear
Angle to determine if a face appeared.
Definition: vpMbXmlParser.h:71
error that can be emited by ViSP classes.
Definition: vpException.h:71
double minLineLengthThreshold
Minimum line length to track a segment when LOD is enabled.
Definition: vpMbXmlParser.h:87
double harrisParam
Harris free parameters.
unsigned int getMaskSize() const
Definition: vpMe.h:142
double angleDisappear
Angle to determine if a face disappeared.
Definition: vpMbXmlParser.h:73
unsigned int maxFeatures
Maximum of Klt features.
void read_sample_deprecated(xmlDocPtr doc, xmlNodePtr node)
double getMu1() const
Definition: vpMe.h:155
void read_camera(xmlDocPtr doc, xmlNodePtr node)
double getThreshold() const
Definition: vpMe.h:193
vpMe m_ecm
Moving edges parameters.
double getSampleStep() const
Definition: vpMe.h:285
unsigned int pyramidLevels
Number of pyramid levels.
void read_face(xmlDocPtr doc, xmlNodePtr node)
unsigned int getMaskNumber() const
Definition: vpMe.h:128
void writeMainClass(xmlNodePtr node)
unsigned int blockSize
Block size.
double getMu2() const
Definition: vpMe.h:161
void read_klt(xmlDocPtr doc, xmlNodePtr node)
double qualityValue
Quality of the Klt points.
void read_ecm(xmlDocPtr doc, xmlNodePtr node)
std::map< std::string, int > nodeMap
Definition: vpXmlParser.h:226
unsigned int getRange() const
Definition: vpMe.h:179
double minPolygonAreaThreshold
Minimum polygon area to track a face when LOD is enabled.
Definition: vpMbXmlParser.h:89
bool useLod
If true, the LOD is enabled, otherwise it is not.
Definition: vpMbXmlParser.h:85
void parse(const std::string &filename)