ViSP  2.9.0
vpMbtEdgeKltXmlParser.cpp
1 /****************************************************************************
2  *
3  * $Id: vpMbtEdgeKltXmlParser.cpp 4577 2014-01-10 16:19:41Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Load XML parameters of the Model based tracker (using edges and point features).
36  *
37  * Authors:
38  * Aurelien Yol
39  *
40  *****************************************************************************/
41 #include <visp/vpConfig.h>
42 
43 
44 #ifdef VISP_HAVE_XML2
45 
46 #include <iostream>
47 #include <map>
48 
49 #include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */
50 
51 #include <visp/vpMbtEdgeKltXmlParser.h>
52 
53 
59 {
60  init();
61 }
62 
67 {
68 }
69 
73 void
75 {
78 
84 }
85 
92 void
93 vpMbtEdgeKltXmlParser::parse(const char * filename)
94 {
95  std::string file = filename;
96  vpXmlParser::parse(file);
97 }
98 
104 void
106 {
107  throw vpException(vpException::notImplementedError, "Not yet implemented." );
108 }
109 
117 void
118 vpMbtEdgeKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node)
119 {
120  bool camera_node = false;
121  bool face_node = false;
122  bool ecm_node = false;
123  bool sample_node = false;
124  bool klt_node = false;
125 
126  for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
127  if(dataNode->type == XML_ELEMENT_NODE){
128  std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name);
129  if(iter_data != nodeMap.end()){
130  switch (iter_data->second){
132  this->read_camera (doc, dataNode);
133  camera_node = true;
134  }break;
136  this->read_face(doc, dataNode);
137  face_node = true;
138  }break;
140  this->read_klt(doc, dataNode);
141  klt_node = true;
142  }break;
144  this->read_ecm (doc, dataNode);
145  ecm_node = true;
146  }break;
148  this->read_sample (doc, dataNode);
149  sample_node = true;
150  }break;
151  default:{
152 // vpTRACE("unknown tag in read_sample : %d, %s", iter_data->second, (iter_data->first).c_str());
153  }break;
154  }
155  }
156  }
157  }
158 
159  if(!camera_node) {
160  std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl;
161  std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl;
162  std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl;
163  std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl;
164  }
165 
166  if(!face_node) {
167  std::cout << "face : Angle Appear : "<< angleAppear <<" (default)" <<std::endl;
168  std::cout << "face : Angle Disappear : "<< angleDisappear <<" (default)" <<std::endl;
169  }
170 
171  if(!klt_node) {
172  std::cout << "klt : Mask Border : "<< maskBorder <<" (default)" <<std::endl;
173  std::cout << "klt : Max Features : "<< maxFeatures <<" (default)" <<std::endl;
174  std::cout << "klt : Windows Size : "<< winSize <<" (default)" <<std::endl;
175  std::cout << "klt : Quality : "<< qualityValue <<" (default)" <<std::endl;
176  std::cout << "klt : Min Distance : "<< minDist <<" (default)" <<std::endl;
177  std::cout << "klt : Harris Parameter : "<< harrisParam <<" (default)" <<std::endl;
178  std::cout << "klt : Block Size : "<< blockSize <<" (default)" <<std::endl;
179  std::cout << "klt : Pyramid Levels : "<< pyramidLevels <<" (default)" <<std::endl;
180  }
181 
182  if(!ecm_node) {
183  std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() << " (default)" <<std::endl;
184  std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() << " (default)" <<std::endl;
185  std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<< " (default)" <<std::endl;
186  std::cout <<"ecm : contrast : threshold : " << this->m_ecm.getThreshold()<<" (default)" <<std::endl;
187  std::cout <<"ecm : contrast : mu1 : " << this->m_ecm.getMu1()<<" (default)" <<std::endl;
188  std::cout <<"ecm : contrast : mu2 : " << this->m_ecm.getMu2()<<" (default)" <<std::endl;
189  }
190 
191  if(!sample_node) {
192  std::cout <<"sample : sample_step : "<< this->m_ecm.getSampleStep()<< " (default)" << std::endl;
193  std::cout <<"sample : n_total_sample : "<< this->m_ecm.getNbTotalSample()<< " (default)"<<std::endl;
194  }
195 }
196 
197 #endif
198 
unsigned int winSize
Windows size.
unsigned int getRange() const
Definition: vpMe.h:236
unsigned int getMaskSize() const
Definition: vpMe.h:164
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)
vpCameraParameters cam
Camera parameters.
Definition: vpMbXmlParser.h:71
double get_u0() const
void parse(const char *filename)
unsigned int getMaskNumber() const
Definition: vpMe.h:134
double getMu1() const
Definition: vpMe.h:178
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:73
error that can be emited by ViSP classes.
Definition: vpException.h:76
double get_py() const
double harrisParam
Harris free parameters.
double angleDisappear
Angle to determine if a face disappeared.
Definition: vpMbXmlParser.h:75
unsigned int maxFeatures
Maximum of Klt features.
int getNbTotalSample() const
Definition: vpMe.h:206
double getThreshold() const
Definition: vpMe.h:306
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
void read_sample(xmlDocPtr doc, xmlNodePtr node)
unsigned int blockSize
Block size.
double getMu2() const
Definition: vpMe.h:192
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:278
std::map< std::string, int > nodeMap
Definition: vpXmlParser.h:197
void parse(const std::string &filename)