Visual Servoing Platform  version 3.0.0
vpMbtEdgeKltXmlParser.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Load XML parameters of the Model based tracker (using edges and point features).
32  *
33  * Authors:
34  * Aurelien Yol
35  *
36  *****************************************************************************/
37 #include <visp3/core/vpConfig.h>
38 
39 
40 #ifdef VISP_HAVE_XML2
41 
42 #include <iostream>
43 #include <map>
44 
45 #include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */
46 
47 #include <visp3/mbt/vpMbtEdgeKltXmlParser.h>
48 
49 
55 {
56  init();
57 }
58 
63 {
64 }
65 
69 void
71 {
74 
80 }
81 
88 void
89 vpMbtEdgeKltXmlParser::parse(const char * filename)
90 {
91  std::string file = filename;
92  vpXmlParser::parse(file);
93 }
94 
100 void
102 {
103  throw vpException(vpException::notImplementedError, "Not yet implemented." );
104 }
105 
113 void
114 vpMbtEdgeKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node)
115 {
116  bool camera_node = false;
117  bool face_node = false;
118  bool ecm_node = false;
119  bool klt_node = false;
120  bool lod_node = false;
121 
122  for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
123  if(dataNode->type == XML_ELEMENT_NODE){
124  std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name);
125  if(iter_data != nodeMap.end()){
126  switch (iter_data->second){
128  this->read_camera (doc, dataNode);
129  camera_node = true;
130  }break;
132  this->read_face(doc, dataNode);
133  face_node = true;
134  }break;
136  this->read_klt(doc, dataNode);
137  klt_node = true;
138  }break;
140  this->read_ecm (doc, dataNode);
141  ecm_node = true;
142  }break;
143  case sample:{
144  this->read_sample_deprecated (doc, dataNode);
145  }break;
147  this->read_lod(doc, dataNode);
148  lod_node = true;
149  }break;
150  default:{
151 // vpTRACE("unknown tag in read_sample : %d, %s", iter_data->second, (iter_data->first).c_str());
152  }break;
153  }
154  }
155  }
156  }
157 
158  if(!camera_node) {
159  std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl;
160  std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl;
161  std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl;
162  std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl;
163  }
164 
165  if(!face_node) {
166  std::cout << "face : Angle Appear : "<< angleAppear <<" (default)" <<std::endl;
167  std::cout << "face : Angle Disappear : "<< angleDisappear <<" (default)" <<std::endl;
168  }
169 
170  if(!klt_node) {
171  std::cout << "klt : Mask Border : "<< maskBorder <<" (default)" <<std::endl;
172  std::cout << "klt : Max Features : "<< maxFeatures <<" (default)" <<std::endl;
173  std::cout << "klt : Windows Size : "<< winSize <<" (default)" <<std::endl;
174  std::cout << "klt : Quality : "<< qualityValue <<" (default)" <<std::endl;
175  std::cout << "klt : Min Distance : "<< minDist <<" (default)" <<std::endl;
176  std::cout << "klt : Harris Parameter : "<< harrisParam <<" (default)" <<std::endl;
177  std::cout << "klt : Block Size : "<< blockSize <<" (default)" <<std::endl;
178  std::cout << "klt : Pyramid Levels : "<< pyramidLevels <<" (default)" <<std::endl;
179  }
180 
181  if(!ecm_node) {
182  std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() << " (default)" <<std::endl;
183  std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() << " (default)" <<std::endl;
184  std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<< " (default)" <<std::endl;
185  std::cout <<"ecm : contrast : threshold : " << this->m_ecm.getThreshold()<<" (default)" <<std::endl;
186  std::cout <<"ecm : contrast : mu1 : " << this->m_ecm.getMu1()<<" (default)" <<std::endl;
187  std::cout <<"ecm : contrast : mu2 : " << this->m_ecm.getMu2()<<" (default)" <<std::endl;
188  std::cout <<"ecm : sample : sample_step : "<< this->m_ecm.getSampleStep()<< " (default)" << std::endl;
189  }
190 
191  if(!lod_node) {
192  std::cout << "lod : use lod : " << useLod << " (default)" << std::endl;
193  std::cout << "lod : min line length threshold : " << minLineLengthThreshold << " (default)" << std::endl;
194  std::cout << "lod : min polygon area threshold : " << minPolygonAreaThreshold << " (default)" << std::endl;
195  }
196 }
197 
198 #elif !defined(VISP_BUILD_SHARED_LIBS)
199 // Work arround to avoid warning: libvisp_mbt.a(vpMbtEdgeKltXmlParser.cpp.o) has no symbols
200 void dummy_vpMbtEdgeKltXmlParser() {};
201 #endif
202 
unsigned int winSize
Windows size.
unsigned int getRange() const
Definition: vpMe.h:225
unsigned int getMaskSize() const
Definition: vpMe.h:153
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)
vpCameraParameters cam
Camera parameters.
Definition: vpMbXmlParser.h:67
double get_u0() const
void parse(const char *filename)
unsigned int getMaskNumber() const
Definition: vpMe.h:123
void read_lod(xmlDocPtr doc, xmlNodePtr node)
double getMu1() const
Definition: vpMe.h:167
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:69
error that can be emited by ViSP classes.
Definition: vpException.h:73
double minLineLengthThreshold
Minimum line length to track a segment when LOD is enabled.
Definition: vpMbXmlParser.h:85
double get_py() const
double harrisParam
Harris free parameters.
double angleDisappear
Angle to determine if a face disappeared.
Definition: vpMbXmlParser.h:71
unsigned int maxFeatures
Maximum of Klt features.
void read_sample_deprecated(xmlDocPtr doc, xmlNodePtr node)
double getThreshold() const
Definition: vpMe.h:295
void read_camera(xmlDocPtr doc, xmlNodePtr node)
vpMe m_ecm
Moving edges parameters.
double get_v0() const
unsigned int pyramidLevels
Number of pyramid levels.
void read_face(xmlDocPtr doc, xmlNodePtr node)
void writeMainClass(xmlNodePtr node)
double get_px() const
unsigned int blockSize
Block size.
double getMu2() const
Definition: vpMe.h:181
void read_klt(xmlDocPtr doc, xmlNodePtr node)
double qualityValue
Quality of the Klt points.
void read_ecm(xmlDocPtr doc, xmlNodePtr node)
double getSampleStep() const
Definition: vpMe.h:267
std::map< std::string, int > nodeMap
Definition: vpXmlParser.h:193
double minPolygonAreaThreshold
Minimum polygon area to track a face when LOD is enabled.
Definition: vpMbXmlParser.h:87
bool useLod
If true, the LOD is enabled, otherwise it is not.
Definition: vpMbXmlParser.h:83
void parse(const std::string &filename)