Visual Servoing Platform  version 3.2.0
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
vpMe::getSampleStep
double getSampleStep() const
Definition: vpMe.h:284
vpCameraParameters::get_py
double get_py() const
Definition: vpCameraParameters.h:332
vpException::notImplementedError
Not implemented.
Definition: vpException.h:92
vpMbtEdgeKltXmlParser::ecm
Definition: vpMbtEdgeKltXmlParser.h:68
vpMbtEdgeKltXmlParser::readMainClass
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbtEdgeKltXmlParser.cpp:92
vpMbXmlParser::cam
vpCameraParameters cam
Camera parameters.
Definition: vpMbXmlParser.h:68
vpMbtXmlParser::read_sample_deprecated
void read_sample_deprecated(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbtXmlParser.cpp:284
vpMbtXmlParser::m_ecm
vpMe m_ecm
Moving edges parameters.
Definition: vpMbtXmlParser.h:87
vpMe::getMaskNumber
unsigned int getMaskNumber() const
Definition: vpMe.h:127
vpMbtKltXmlParser::minDist
double minDist
Minimum distance between klt points.
Definition: vpMbtKltXmlParser.h:74
vpMbtKltXmlParser::init
void init()
Definition: vpMbtKltXmlParser.cpp:67
vpMbtKltXmlParser::harrisParam
double harrisParam
Harris free parameters.
Definition: vpMbtKltXmlParser.h:76
vpMbtEdgeKltXmlParser::camera
Definition: vpMbtEdgeKltXmlParser.h:68
vpMbtKltXmlParser::maskBorder
unsigned int maskBorder
Border of the mask used on Klt points.
Definition: vpMbtKltXmlParser.h:66
vpMbXmlParser::useLod
bool useLod
If true, the LOD is enabled, otherwise it is not.
Definition: vpMbXmlParser.h:84
vpMbXmlParser::angleDisappear
double angleDisappear
Angle to determine if a face disappeared.
Definition: vpMbXmlParser.h:72
vpMbtEdgeKltXmlParser::klt
Definition: vpMbtEdgeKltXmlParser.h:68
vpMbXmlParser::angleAppear
double angleAppear
Angle to determine if a face appeared.
Definition: vpMbXmlParser.h:70
vpMbtXmlParser::init
void init()
Definition: vpMbtXmlParser.cpp:65
vpMe::getRange
unsigned int getRange() const
Definition: vpMe.h:178
vpMbtKltXmlParser::maxFeatures
unsigned int maxFeatures
Maximum of Klt features.
Definition: vpMbtKltXmlParser.h:68
vpCameraParameters::get_px
double get_px() const
Definition: vpCameraParameters.h:329
vpMe::getMu2
double getMu2() const
Definition: vpMe.h:160
vpMbtEdgeKltXmlParser::writeMainClass
void writeMainClass(xmlNodePtr node)
Definition: vpMbtEdgeKltXmlParser.cpp:80
vpMbtKltXmlParser::pyramidLevels
unsigned int pyramidLevels
Number of pyramid levels.
Definition: vpMbtKltXmlParser.h:80
vpMbtXmlParser::sample
Definition: vpMbtXmlParser.h:81
vpMbtEdgeKltXmlParser::vpMbtEdgeKltXmlParser
vpMbtEdgeKltXmlParser()
Definition: vpMbtEdgeKltXmlParser.cpp:53
vpMbtEdgeKltXmlParser::~vpMbtEdgeKltXmlParser
virtual ~vpMbtEdgeKltXmlParser()
Definition: vpMbtEdgeKltXmlParser.cpp:58
vpMbtEdgeKltXmlParser::init
void init()
Definition: vpMbtEdgeKltXmlParser.cpp:63
vpMbXmlParser::minLineLengthThreshold
double minLineLengthThreshold
Minimum line length to track a segment when LOD is enabled.
Definition: vpMbXmlParser.h:86
vpCameraParameters::get_v0
double get_v0() const
Definition: vpCameraParameters.h:334
vpMbtKltXmlParser::blockSize
unsigned int blockSize
Block size.
Definition: vpMbtKltXmlParser.h:78
vpMbtXmlParser::read_ecm
void read_ecm(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbtXmlParser.cpp:177
vpMbXmlParser::read_camera
void read_camera(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbXmlParser.cpp:168
vpMe::getMaskSize
unsigned int getMaskSize() const
Definition: vpMe.h:141
vpMbXmlParser::read_face
void read_face(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbXmlParser.cpp:242
vpMbXmlParser::minPolygonAreaThreshold
double minPolygonAreaThreshold
Minimum polygon area to track a face when LOD is enabled.
Definition: vpMbXmlParser.h:88
vpMbXmlParser::read_lod
void read_lod(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbXmlParser.cpp:313
vpMbtEdgeKltXmlParser::face
Definition: vpMbtEdgeKltXmlParser.h:68
vpMbtKltXmlParser::read_klt
void read_klt(xmlDocPtr doc, xmlNodePtr node)
Definition: vpMbtKltXmlParser.cpp:174
vpMbtKltXmlParser::qualityValue
double qualityValue
Quality of the Klt points.
Definition: vpMbtKltXmlParser.h:72
vpCameraParameters::get_u0
double get_u0() const
Definition: vpCameraParameters.h:333
vpMe::getMu1
double getMu1() const
Definition: vpMe.h:154
vpMbtEdgeKltXmlParser::lod
Definition: vpMbtEdgeKltXmlParser.h:68
vpException
error that can be emited by ViSP classes.
Definition: vpException.h:70
vpMe::getThreshold
double getThreshold() const
Definition: vpMe.h:192
vpMbtKltXmlParser::winSize
unsigned int winSize
Windows size.
Definition: vpMbtKltXmlParser.h:70
vpXmlParser::nodeMap
std::map< std::string, int > nodeMap
Definition: vpXmlParser.h:225