Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpMbtEdgeKltXmlParser.cpp
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 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 
81 void vpMbtEdgeKltXmlParser::writeMainClass(xmlNodePtr /*node*/)
82 {
83  throw vpException(vpException::notImplementedError, "Not yet implemented.");
84 }
85 
93 void vpMbtEdgeKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node)
94 {
95  bool camera_node = false;
96  bool face_node = false;
97  bool ecm_node = false;
98  bool klt_node = false;
99  bool lod_node = false;
100 
101  for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
102  if (dataNode->type == XML_ELEMENT_NODE) {
103  std::map<std::string, int>::iterator iter_data = this->nodeMap.find((char *)dataNode->name);
104  if (iter_data != nodeMap.end()) {
105  switch (iter_data->second) {
107  this->read_camera(doc, dataNode);
108  camera_node = true;
109  } break;
111  this->read_face(doc, dataNode);
112  face_node = true;
113  } break;
115  this->read_klt(doc, dataNode);
116  klt_node = true;
117  } break;
119  this->read_ecm(doc, dataNode);
120  ecm_node = true;
121  } break;
122  case sample: {
123  this->read_sample_deprecated(doc, dataNode);
124  } break;
126  this->read_lod(doc, dataNode);
127  lod_node = true;
128  } break;
129  default: {
130  // vpTRACE("unknown tag in read_sample : %d, %s",
131  // iter_data->second, (iter_data->first).c_str());
132  } break;
133  }
134  }
135  }
136  }
137 
138  if (!camera_node) {
139  std::cout << "camera : u0 : " << this->cam.get_u0() << " (default)" << std::endl;
140  std::cout << "camera : v0 : " << this->cam.get_v0() << " (default)" << std::endl;
141  std::cout << "camera : px : " << this->cam.get_px() << " (default)" << std::endl;
142  std::cout << "camera : py : " << this->cam.get_py() << " (default)" << std::endl;
143  }
144 
145  if (!face_node) {
146  std::cout << "face : Angle Appear : " << angleAppear << " (default)" << std::endl;
147  std::cout << "face : Angle Disappear : " << angleDisappear << " (default)" << std::endl;
148  }
149 
150  if (!klt_node) {
151  std::cout << "klt : Mask Border : " << maskBorder << " (default)" << std::endl;
152  std::cout << "klt : Max Features : " << maxFeatures << " (default)" << std::endl;
153  std::cout << "klt : Windows Size : " << winSize << " (default)" << std::endl;
154  std::cout << "klt : Quality : " << qualityValue << " (default)" << std::endl;
155  std::cout << "klt : Min Distance : " << minDist << " (default)" << std::endl;
156  std::cout << "klt : Harris Parameter : " << harrisParam << " (default)" << std::endl;
157  std::cout << "klt : Block Size : " << blockSize << " (default)" << std::endl;
158  std::cout << "klt : Pyramid Levels : " << pyramidLevels << " (default)" << std::endl;
159  }
160 
161  if (!ecm_node) {
162  std::cout << "ecm : mask : size : " << this->m_ecm.getMaskSize() << " (default)" << std::endl;
163  std::cout << "ecm : mask : nb_mask : " << this->m_ecm.getMaskNumber() << " (default)" << std::endl;
164  std::cout << "ecm : range : tracking : " << this->m_ecm.getRange() << " (default)" << std::endl;
165  std::cout << "ecm : contrast : threshold : " << this->m_ecm.getThreshold() << " (default)" << std::endl;
166  std::cout << "ecm : contrast : mu1 : " << this->m_ecm.getMu1() << " (default)" << std::endl;
167  std::cout << "ecm : contrast : mu2 : " << this->m_ecm.getMu2() << " (default)" << std::endl;
168  std::cout << "ecm : sample : sample_step : " << this->m_ecm.getSampleStep() << " (default)" << std::endl;
169  }
170 
171  if (!lod_node) {
172  std::cout << "lod : use lod : " << useLod << " (default)" << std::endl;
173  std::cout << "lod : min line length threshold : " << minLineLengthThreshold << " (default)" << std::endl;
174  std::cout << "lod : min polygon area threshold : " << minPolygonAreaThreshold << " (default)" << std::endl;
175  }
176 }
177 
178 #elif !defined(VISP_BUILD_SHARED_LIBS)
179 // Work arround to avoid warning: libvisp_mbt.a(vpMbtEdgeKltXmlParser.cpp.o)
180 // has no symbols
181 void dummy_vpMbtEdgeKltXmlParser(){};
182 #endif
unsigned int winSize
Windows size.
unsigned int getRange() const
Definition: vpMe.h:179
unsigned int getMaskSize() const
Definition: vpMe.h:142
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)
vpCameraParameters cam
Camera parameters.
Definition: vpMbXmlParser.h:69
double get_u0() const
unsigned int getMaskNumber() const
Definition: vpMe.h:128
void read_lod(xmlDocPtr doc, xmlNodePtr node)
double getMu1() const
Definition: vpMe.h:155
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 get_py() const
double harrisParam
Harris free parameters.
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 getThreshold() const
Definition: vpMe.h:193
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:161
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:285
std::map< std::string, int > nodeMap
Definition: vpXmlParser.h:226
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