Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMbtXmlGenericParser.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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 Parameter for Model Based Tracker.
32 */
33
34#include <visp3/core/vpConfig.h>
35
36#include <clocale>
37#include <iostream>
38#include <map>
39
40#include <visp3/mbt/vpMbtXmlGenericParser.h>
41
42#if defined(VISP_HAVE_PUGIXML)
43#include <pugixml.hpp>
44
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
47
48class vpMbtXmlGenericParser::Impl
49{
50public:
51 Impl(int type = EDGE_PARSER)
52 : m_parserType(type),
53 // <camera>
54 m_cam(),
55 // <face>
56 m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
57 m_farClipping(false), m_fovClipping(false),
58 // <lod>
59 m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
60 // <ecm>
61 m_ecm(),
62 // <klt>
63 m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
64 m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
65 // <depth_normal>
66 m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION),
67 m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
68 m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2),
69 m_depthNormalSamplingStepY(2),
70 // <depth_dense>
71 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
72 // <projection_error>
73 m_projectionErrorMe(), m_projectionErrorKernelSize(2), // 5x5
74 m_nodeMap(), m_verbose(true)
75 {
76 // std::setlocale() is not thread safe and need to be called once
77 // https://stackoverflow.com/questions/41117179/undefined-behavior-with-setlocale-and-multithreading
78 if (m_call_setlocale) {
79 // https://pugixml.org/docs/manual.html#access.attrdata
80 // https://en.cppreference.com/w/cpp/locale/setlocale
81 // When called from Java binding, the locale seems to be changed to the default system locale
82 // It thus mess with the parsing of numbers with pugixml and comma decimal separator environment
83 if (std::setlocale(LC_ALL, "C") == nullptr) {
84 std::cerr << "Cannot set locale to C" << std::endl;
85 }
86 m_call_setlocale = false;
87 }
88 init();
89 }
90
91 void parse(const std::string &filename)
92 {
93 pugi::xml_document doc;
94 if (!doc.load_file(filename.c_str())) {
95 throw vpException(vpException::ioError, "Cannot open file: %s", filename.c_str());
96 }
97
98 bool camera_node = false;
99 bool face_node = false;
100 bool ecm_node = false;
101 bool klt_node = false;
102 bool lod_node = false;
103 bool depth_normal_node = false;
104 bool depth_dense_node = false;
105 bool projection_error_node = false;
106
107 pugi::xml_node root_node = doc.document_element();
108 for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
109 if (dataNode.type() == pugi::node_element) {
110 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
111 if (iter_data != m_nodeMap.end()) {
112 switch (iter_data->second) {
113 case camera:
114 if (m_parserType != PROJECTION_ERROR_PARSER) {
115 read_camera(dataNode);
116 camera_node = true;
117 }
118 break;
119
120 case face:
121 if (m_parserType != PROJECTION_ERROR_PARSER) {
122 read_face(dataNode);
123 face_node = true;
124 }
125 break;
126
127 case lod:
128 if (m_parserType != PROJECTION_ERROR_PARSER) {
129 read_lod(dataNode);
130 lod_node = true;
131 }
132 break;
133
134 case ecm:
135 if (m_parserType & EDGE_PARSER) {
136 read_ecm(dataNode);
137 ecm_node = true;
138 }
139 break;
140
141 case sample:
142 if (m_parserType & EDGE_PARSER)
143 read_sample_deprecated(dataNode);
144 break;
145
146 case klt:
147 if (m_parserType & KLT_PARSER) {
148 read_klt(dataNode);
149 klt_node = true;
150 }
151 break;
152
153 case depth_normal:
154 if (m_parserType & DEPTH_NORMAL_PARSER) {
155 read_depth_normal(dataNode);
156 depth_normal_node = true;
157 }
158 break;
159
160 case depth_dense:
161 if (m_parserType & DEPTH_DENSE_PARSER) {
162 read_depth_dense(dataNode);
163 depth_dense_node = true;
164 }
165 break;
166
167 case projection_error:
168 if (m_parserType == PROJECTION_ERROR_PARSER) {
169 read_projection_error(dataNode);
170 projection_error_node = true;
171 }
172 break;
173
174 default:
175 break;
176 }
177 }
178 }
179 }
180
181 if (m_verbose) {
182 if (m_parserType == PROJECTION_ERROR_PARSER) {
183 if (!projection_error_node) {
184 std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
185 << std::endl;
186 std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
187 << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
188 }
189 }
190 else {
191 if (!camera_node) {
192 std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
193 std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
194 std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
195 std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
196 }
197
198 if (!face_node) {
199 std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
200 std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
201 }
202
203 if (!lod_node) {
204 std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
205 std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
206 std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
207 }
208
209 if (!ecm_node && (m_parserType & EDGE_PARSER)) {
210 std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
211 std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
212 std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
213 std::cout << "me : contrast : threshold type : " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
214 std::cout << "me : contrast : threshold : " << m_ecm.getThreshold() << " (default)" << std::endl;
215 std::cout << "me : contrast : mu1 : " << m_ecm.getMu1() << " (default)" << std::endl;
216 std::cout << "me : contrast : mu2 : " << m_ecm.getMu2() << " (default)" << std::endl;
217 std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
218 }
219
220 if (!klt_node && (m_parserType & KLT_PARSER)) {
221 std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
222 std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
223 std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
224 std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
225 std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
226 std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
227 std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
228 std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
229 }
230
231 if (!depth_normal_node && (m_parserType & DEPTH_NORMAL_PARSER)) {
232 std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
233 << " (default)" << std::endl;
234 std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
235 << " (default)" << std::endl;
236 std::cout << "depth normal : PCL_plane_estimation : max_iter : "
237 << m_depthNormalPclPlaneEstimationRansacMaxIter << " (default)" << std::endl;
238 std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
239 << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
240 std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
241 << std::endl;
242 std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
243 << std::endl;
244 }
245
246 if (!depth_dense_node && (m_parserType & DEPTH_DENSE_PARSER)) {
247 std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)"
248 << std::endl;
249 std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)"
250 << std::endl;
251 }
252 }
253 }
254 }
255
261 void read_camera(const pugi::xml_node &node)
262 {
263 bool u0_node = false;
264 bool v0_node = false;
265 bool px_node = false;
266 bool py_node = false;
267
268 // current data values.
269 double d_u0 = m_cam.get_u0();
270 double d_v0 = m_cam.get_v0();
271 double d_px = m_cam.get_px();
272 double d_py = m_cam.get_py();
273
274 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
275 if (dataNode.type() == pugi::node_element) {
276 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
277 if (iter_data != m_nodeMap.end()) {
278 switch (iter_data->second) {
279 case u0:
280 d_u0 = dataNode.text().as_double();
281 u0_node = true;
282 break;
283
284 case v0:
285 d_v0 = dataNode.text().as_double();
286 v0_node = true;
287 break;
288
289 case px:
290 d_px = dataNode.text().as_double();
291 px_node = true;
292 break;
293
294 case py:
295 d_py = dataNode.text().as_double();
296 py_node = true;
297 break;
298
299 default:
300 break;
301 }
302 }
303 }
304 }
305
306 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
307
308 if (m_verbose) {
309 if (!u0_node)
310 std::cout << "camera : u0 : " << m_cam.get_u0() << " (default)" << std::endl;
311 else
312 std::cout << "camera : u0 : " << m_cam.get_u0() << std::endl;
313
314 if (!v0_node)
315 std::cout << "camera : v0 : " << m_cam.get_v0() << " (default)" << std::endl;
316 else
317 std::cout << "camera : v0 : " << m_cam.get_v0() << std::endl;
318
319 if (!px_node)
320 std::cout << "camera : px : " << m_cam.get_px() << " (default)" << std::endl;
321 else
322 std::cout << "camera : px : " << m_cam.get_px() << std::endl;
323
324 if (!py_node)
325 std::cout << "camera : py : " << m_cam.get_py() << " (default)" << std::endl;
326 else
327 std::cout << "camera : py : " << m_cam.get_py() << std::endl;
328 }
329 }
330
336 void read_depth_normal(const pugi::xml_node &node)
337 {
338 bool feature_estimation_method_node = false;
339 bool PCL_plane_estimation_node = false;
340 bool sampling_step_node = false;
341
342 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
343 if (dataNode.type() == pugi::node_element) {
344 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
345 if (iter_data != m_nodeMap.end()) {
346 switch (iter_data->second) {
347 case feature_estimation_method:
348 m_depthNormalFeatureEstimationMethod =
349 (vpMbtFaceDepthNormal::vpFeatureEstimationType)dataNode.text().as_int();
350 feature_estimation_method_node = true;
351 break;
352
353 case PCL_plane_estimation:
354 read_depth_normal_PCL(dataNode);
355 PCL_plane_estimation_node = true;
356 break;
357
358 case depth_sampling_step:
359 read_depth_normal_sampling_step(dataNode);
360 sampling_step_node = true;
361 break;
362
363 default:
364 break;
365 }
366 }
367 }
368 }
369
370 if (m_verbose) {
371 if (!feature_estimation_method_node)
372 std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
373 << " (default)" << std::endl;
374 else
375 std::cout << "depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
376
377 if (!PCL_plane_estimation_node) {
378 std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
379 << " (default)" << std::endl;
380 std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
381 << " (default)" << std::endl;
382 std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
383 << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
384 }
385
386 if (!sampling_step_node) {
387 std::cout << "depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX << " (default)"
388 << std::endl;
389 std::cout << "depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY << " (default)"
390 << std::endl;
391 }
392 }
393 }
394
400 void read_depth_normal_PCL(const pugi::xml_node &node)
401 {
402 bool PCL_plane_estimation_method_node = false;
403 bool PCL_plane_estimation_ransac_max_iter_node = false;
404 bool PCL_plane_estimation_ransac_threshold_node = false;
405
406 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
407 if (dataNode.type() == pugi::node_element) {
408 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
409 if (iter_data != m_nodeMap.end()) {
410 switch (iter_data->second) {
411 case PCL_plane_estimation_method:
412 m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
413 PCL_plane_estimation_method_node = true;
414 break;
415
416 case PCL_plane_estimation_ransac_max_iter:
417 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
418 PCL_plane_estimation_ransac_max_iter_node = true;
419 break;
420
421 case PCL_plane_estimation_ransac_threshold:
422 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
423 PCL_plane_estimation_ransac_threshold_node = true;
424 break;
425
426 default:
427 break;
428 }
429 }
430 }
431 }
432
433 if (m_verbose) {
434 if (!PCL_plane_estimation_method_node)
435 std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
436 << " (default)" << std::endl;
437 else
438 std::cout << "depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
439 << std::endl;
440
441 if (!PCL_plane_estimation_ransac_max_iter_node)
442 std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
443 << " (default)" << std::endl;
444 else
445 std::cout << "depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
446 << std::endl;
447
448 if (!PCL_plane_estimation_ransac_threshold_node)
449 std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
450 << m_depthNormalPclPlaneEstimationRansacThreshold << " (default)" << std::endl;
451 else
452 std::cout << "depth normal : PCL_plane_estimation : ransac_threshold : "
453 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
454 }
455 }
456
462 void read_depth_normal_sampling_step(const pugi::xml_node &node)
463 {
464 bool sampling_step_X_node = false;
465 bool sampling_step_Y_node = false;
466
467 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
468 if (dataNode.type() == pugi::node_element) {
469 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
470 if (iter_data != m_nodeMap.end()) {
471 switch (iter_data->second) {
472 case depth_sampling_step_X:
473 m_depthNormalSamplingStepX = dataNode.text().as_uint();
474 sampling_step_X_node = true;
475 break;
476
477 case depth_sampling_step_Y:
478 m_depthNormalSamplingStepY = dataNode.text().as_uint();
479 sampling_step_Y_node = true;
480 break;
481
482 default:
483 break;
484 }
485 }
486 }
487 }
488
489 if (m_verbose) {
490 if (!sampling_step_X_node)
491 std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << " (default)"
492 << std::endl;
493 else
494 std::cout << "depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
495
496 if (!sampling_step_Y_node)
497 std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << " (default)"
498 << std::endl;
499 else
500 std::cout << "depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
501 }
502 }
503
509 void read_depth_dense(const pugi::xml_node &node)
510 {
511 bool sampling_step_node = false;
512
513 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
514 if (dataNode.type() == pugi::node_element) {
515 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
516 if (iter_data != m_nodeMap.end()) {
517 switch (iter_data->second) {
518 case depth_dense_sampling_step:
519 read_depth_dense_sampling_step(dataNode);
520 sampling_step_node = true;
521 break;
522
523 default:
524 break;
525 }
526 }
527 }
528 }
529
530 if (!sampling_step_node && m_verbose) {
531 std::cout << "depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX << " (default)" << std::endl;
532 std::cout << "depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY << " (default)" << std::endl;
533 }
534 }
535
541 void read_depth_dense_sampling_step(const pugi::xml_node &node)
542 {
543 bool sampling_step_X_node = false;
544 bool sampling_step_Y_node = false;
545
546 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
547 if (dataNode.type() == pugi::node_element) {
548 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
549 if (iter_data != m_nodeMap.end()) {
550 switch (iter_data->second) {
551 case depth_dense_sampling_step_X:
552 m_depthDenseSamplingStepX = dataNode.text().as_uint();
553 sampling_step_X_node = true;
554 break;
555
556 case depth_dense_sampling_step_Y:
557 m_depthDenseSamplingStepY = dataNode.text().as_uint();
558 sampling_step_Y_node = true;
559 break;
560
561 default:
562 break;
563 }
564 }
565 }
566 }
567
568 if (m_verbose) {
569 if (!sampling_step_X_node)
570 std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << " (default)"
571 << std::endl;
572 else
573 std::cout << "depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
574
575 if (!sampling_step_Y_node)
576 std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << " (default)"
577 << std::endl;
578 else
579 std::cout << "depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
580 }
581 }
582
588 void read_ecm(const pugi::xml_node &node)
589 {
590 bool mask_node = false;
591 bool range_node = false;
592 bool contrast_node = false;
593 bool sample_node = false;
594
595 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
596 if (dataNode.type() == pugi::node_element) {
597 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
598 if (iter_data != m_nodeMap.end()) {
599 switch (iter_data->second) {
600 case mask:
601 read_ecm_mask(dataNode);
602 mask_node = true;
603 break;
604
605 case range:
606 read_ecm_range(dataNode);
607 range_node = true;
608 break;
609
610 case contrast:
611 read_ecm_contrast(dataNode);
612 contrast_node = true;
613 break;
614
615 case sample:
616 read_ecm_sample(dataNode);
617 sample_node = true;
618 break;
619
620 default:
621 break;
622 }
623 }
624 }
625 }
626
627 if (m_verbose) {
628 if (!mask_node) {
629 std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
630 std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
631 }
632
633 if (!range_node) {
634 std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
635 }
636
637 if (!contrast_node) {
638 std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
639 std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
640 std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
641 std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
642 }
643
644 if (!sample_node) {
645 std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
646 }
647 }
648 }
649
655 void read_ecm_contrast(const pugi::xml_node &node)
656 {
657 bool edge_threshold_type_node = false;
658 bool edge_threshold_node = false;
659 bool edge_min_node = false;
660 bool edge_ratio_node = false;
661 bool mu1_node = false;
662 bool mu2_node = false;
663
664 // current data values.
665 vpMe::vpLikelihoodThresholdType d_edge_threshold_type = m_ecm.getLikelihoodThresholdType();
666 double d_edge_threshold = m_ecm.getThreshold();
667 double d_edge_min_threshold = m_ecm.getMinThreshold();
668 double d_edge_thresh_ratio = m_ecm.getThresholdMarginRatio();
669 double d_mu1 = m_ecm.getMu1();
670 double d_mu2 = m_ecm.getMu2();
671
672 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
673 if (dataNode.type() == pugi::node_element) {
674 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
675 if (iter_data != m_nodeMap.end()) {
676 switch (iter_data->second) {
677 case edge_threshold_type:
678 d_edge_threshold_type = static_cast<vpMe::vpLikelihoodThresholdType>(dataNode.text().as_int());
679 edge_threshold_type_node = true;
680 break;
681
682 case edge_threshold:
683 d_edge_threshold = dataNode.text().as_int();
684 edge_threshold_node = true;
685 break;
686
687 case edge_threshold_ratio:
688 d_edge_thresh_ratio = dataNode.text().as_double();
689 edge_ratio_node = true;
690 break;
691
692 case edge_min_threshold:
693 d_edge_min_threshold = dataNode.text().as_double();
694 edge_min_node = true;
695 break;
696
697 case mu1:
698 d_mu1 = dataNode.text().as_double();
699 mu1_node = true;
700 break;
701
702 case mu2:
703 d_mu2 = dataNode.text().as_double();
704 mu2_node = true;
705 break;
706
707 default:
708 break;
709 }
710 }
711 }
712 }
713
714 m_ecm.setMu1(d_mu1);
715 m_ecm.setMu2(d_mu2);
716 m_ecm.setLikelihoodThresholdType(d_edge_threshold_type);
717 m_ecm.setThreshold(d_edge_threshold);
718 m_ecm.setThresholdMarginRatio(d_edge_thresh_ratio);
719 m_ecm.setMinThreshold(d_edge_min_threshold);
720
721 if (m_verbose) {
722 if (!edge_threshold_type_node) {
723 std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << " (default)" << std::endl;
724 }
725 else {
726 std::cout << "me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << std::endl;
727 }
728
729 if (!edge_threshold_node) {
730 std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << " (default)" << std::endl;
731 }
732 else {
733 std::cout << "me : contrast : threshold " << m_ecm.getThreshold() << std::endl;
734 }
735
736 if (!edge_min_node) {
737 std::cout << "me : contrast : min threshold " << m_ecm.getMinThreshold() << " (default)" << std::endl;
738 }
739 else {
740 std::cout << "me : contrast : min threshold " << m_ecm.getMinThreshold() << std::endl;
741 }
742
743 if (!edge_ratio_node) {
744 std::cout << "me : contrast : threshold margin ratio " << m_ecm.getThresholdMarginRatio() << " (default)" << std::endl;
745 }
746 else {
747 std::cout << "me : contrast : threshold margin ratio " << m_ecm.getThresholdMarginRatio() << std::endl;
748 }
749
750 if (!mu1_node) {
751 std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << " (default)" << std::endl;
752 }
753 else {
754 std::cout << "me : contrast : mu1 " << m_ecm.getMu1() << std::endl;
755 }
756
757 if (!mu2_node) {
758 std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << " (default)" << std::endl;
759 }
760 else {
761 std::cout << "me : contrast : mu2 " << m_ecm.getMu2() << std::endl;
762 }
763 }
764 }
765
771 void read_ecm_mask(const pugi::xml_node &node)
772 {
773 bool size_node = false;
774 bool nb_mask_node = false;
775
776 // current data values.
777 unsigned int d_size = m_ecm.getMaskSize();
778 unsigned int d_nb_mask = m_ecm.getMaskNumber();
779
780 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
781 if (dataNode.type() == pugi::node_element) {
782 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
783 if (iter_data != m_nodeMap.end()) {
784 switch (iter_data->second) {
785 case size:
786 d_size = dataNode.text().as_uint();
787 size_node = true;
788 break;
789
790 case nb_mask:
791 d_nb_mask = dataNode.text().as_uint();
792 nb_mask_node = true;
793 break;
794
795 default:
796 break;
797 }
798 }
799 }
800 }
801
802 m_ecm.setMaskSize(d_size);
803
804 // Check to ensure that d_nb_mask > 0
805 if (d_nb_mask == 0)
806 throw(vpException(vpException::badValue, "Model-based tracker mask size "
807 "parameter should be different "
808 "from zero in xml file"));
809 m_ecm.setMaskNumber(d_nb_mask);
810
811 if (m_verbose) {
812 if (!size_node)
813 std::cout << "me : mask : size : " << m_ecm.getMaskSize() << " (default)" << std::endl;
814 else
815 std::cout << "me : mask : size : " << m_ecm.getMaskSize() << std::endl;
816
817 if (!nb_mask_node)
818 std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << " (default)" << std::endl;
819 else
820 std::cout << "me : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
821 }
822 }
823
829 void read_ecm_range(const pugi::xml_node &node)
830 {
831 bool tracking_node = false;
832 bool init_node = false;
833
834 // current data values.
835 unsigned int m_range_tracking = m_ecm.getRange();
836 int initRange = 0;
837
838 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
839 if (dataNode.type() == pugi::node_element) {
840 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
841 if (iter_data != m_nodeMap.end()) {
842 switch (iter_data->second) {
843 case tracking:
844 m_range_tracking = dataNode.text().as_uint();
845 tracking_node = true;
846 break;
847 case init_range:
848 initRange = dataNode.text().as_int();
849 tracking_node = true;
850 break;
851
852 default:
853 break;
854 }
855 }
856 }
857 }
858
859 m_ecm.setRange(m_range_tracking);
860 m_ecm.setInitRange(initRange);
861
862 if (m_verbose) {
863 if (!tracking_node) {
864 std::cout << "me : range : tracking : " << m_ecm.getRange() << " (default)" << std::endl;
865 }
866 else {
867 std::cout << "me : range : tracking : " << m_ecm.getRange() << std::endl;
868 }
869 if (!init_node) {
870 std::cout << "me : range : init range : " << m_ecm.getInitRange() << " (default)" << std::endl;
871 }
872 else {
873 std::cout << "me : range : init range : " << initRange << std::endl;
874 }
875 }
876 }
877
883 void read_ecm_sample(const pugi::xml_node &node)
884 {
885 bool step_node = false;
886
887 // current data values.
888 double d_stp = m_ecm.getSampleStep();
889
890 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
891 if (dataNode.type() == pugi::node_element) {
892 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
893 if (iter_data != m_nodeMap.end()) {
894 switch (iter_data->second) {
895 case step:
896 d_stp = dataNode.text().as_int();
897 step_node = true;
898 break;
899
900 default:
901 break;
902 }
903 }
904 }
905 }
906
907 m_ecm.setSampleStep(d_stp);
908
909 if (m_verbose) {
910 if (!step_node)
911 std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
912 else
913 std::cout << "me : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
914 }
915 }
916
922 void read_face(const pugi::xml_node &node)
923 {
924 bool angle_appear_node = false;
925 bool angle_disappear_node = false;
926 bool near_clipping_node = false;
927 bool far_clipping_node = false;
928 bool fov_clipping_node = false;
929 m_hasNearClipping = false;
930 m_hasFarClipping = false;
931
932 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
933 if (dataNode.type() == pugi::node_element) {
934 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
935 if (iter_data != m_nodeMap.end()) {
936 switch (iter_data->second) {
937 case angle_appear:
938 m_angleAppear = dataNode.text().as_double();
939 angle_appear_node = true;
940 break;
941
942 case angle_disappear:
943 m_angleDisappear = dataNode.text().as_double();
944 angle_disappear_node = true;
945 break;
946
947 case near_clipping:
948 m_nearClipping = dataNode.text().as_double();
949 m_hasNearClipping = true;
950 near_clipping_node = true;
951 break;
952
953 case far_clipping:
954 m_farClipping = dataNode.text().as_double();
955 m_hasFarClipping = true;
956 far_clipping_node = true;
957 break;
958
959 case fov_clipping:
960 if (dataNode.text().as_int())
961 m_fovClipping = true;
962 else
963 m_fovClipping = false;
964 fov_clipping_node = true;
965 break;
966
967 default:
968 break;
969 }
970 }
971 }
972 }
973
974 if (m_verbose) {
975 if (!angle_appear_node)
976 std::cout << "face : Angle Appear : " << m_angleAppear << " (default)" << std::endl;
977 else
978 std::cout << "face : Angle Appear : " << m_angleAppear << std::endl;
979
980 if (!angle_disappear_node)
981 std::cout << "face : Angle Disappear : " << m_angleDisappear << " (default)" << std::endl;
982 else
983 std::cout << "face : Angle Disappear : " << m_angleDisappear << std::endl;
984
985 if (near_clipping_node)
986 std::cout << "face : Near Clipping : " << m_nearClipping << std::endl;
987
988 if (far_clipping_node)
989 std::cout << "face : Far Clipping : " << m_farClipping << std::endl;
990
991 if (fov_clipping_node) {
992 if (m_fovClipping)
993 std::cout << "face : Fov Clipping : True" << std::endl;
994 else
995 std::cout << "face : Fov Clipping : False" << std::endl;
996 }
997 }
998 }
999
1005 void read_klt(const pugi::xml_node &node)
1006 {
1007 bool mask_border_node = false;
1008 bool max_features_node = false;
1009 bool window_size_node = false;
1010 bool quality_node = false;
1011 bool min_distance_node = false;
1012 bool harris_node = false;
1013 bool size_block_node = false;
1014 bool pyramid_lvl_node = false;
1015
1016 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1017 if (dataNode.type() == pugi::node_element) {
1018 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1019 if (iter_data != m_nodeMap.end()) {
1020 switch (iter_data->second) {
1021 case mask_border:
1022 m_kltMaskBorder = dataNode.text().as_uint();
1023 mask_border_node = true;
1024 break;
1025
1026 case max_features:
1027 m_kltMaxFeatures = dataNode.text().as_uint();
1028 max_features_node = true;
1029 break;
1030
1031 case window_size:
1032 m_kltWinSize = dataNode.text().as_uint();
1033 window_size_node = true;
1034 break;
1035
1036 case quality:
1037 m_kltQualityValue = dataNode.text().as_double();
1038 quality_node = true;
1039 break;
1040
1041 case min_distance:
1042 m_kltMinDist = dataNode.text().as_double();
1043 min_distance_node = true;
1044 break;
1045
1046 case harris:
1047 m_kltHarrisParam = dataNode.text().as_double();
1048 harris_node = true;
1049 break;
1050
1051 case size_block:
1052 m_kltBlockSize = dataNode.text().as_uint();
1053 size_block_node = true;
1054 break;
1055
1056 case pyramid_lvl:
1057 m_kltPyramidLevels = dataNode.text().as_uint();
1058 pyramid_lvl_node = true;
1059 break;
1060
1061 default:
1062 break;
1063 }
1064 }
1065 }
1066 }
1067
1068 if (m_verbose) {
1069 if (!mask_border_node)
1070 std::cout << "klt : Mask Border : " << m_kltMaskBorder << " (default)" << std::endl;
1071 else
1072 std::cout << "klt : Mask Border : " << m_kltMaskBorder << std::endl;
1073
1074 if (!max_features_node)
1075 std::cout << "klt : Max Features : " << m_kltMaxFeatures << " (default)" << std::endl;
1076 else
1077 std::cout << "klt : Max Features : " << m_kltMaxFeatures << std::endl;
1078
1079 if (!window_size_node)
1080 std::cout << "klt : Windows Size : " << m_kltWinSize << " (default)" << std::endl;
1081 else
1082 std::cout << "klt : Windows Size : " << m_kltWinSize << std::endl;
1083
1084 if (!quality_node)
1085 std::cout << "klt : Quality : " << m_kltQualityValue << " (default)" << std::endl;
1086 else
1087 std::cout << "klt : Quality : " << m_kltQualityValue << std::endl;
1088
1089 if (!min_distance_node)
1090 std::cout << "klt : Min Distance : " << m_kltMinDist << " (default)" << std::endl;
1091 else
1092 std::cout << "klt : Min Distance : " << m_kltMinDist << std::endl;
1093
1094 if (!harris_node)
1095 std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << " (default)" << std::endl;
1096 else
1097 std::cout << "klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1098
1099 if (!size_block_node)
1100 std::cout << "klt : Block Size : " << m_kltBlockSize << " (default)" << std::endl;
1101 else
1102 std::cout << "klt : Block Size : " << m_kltBlockSize << std::endl;
1103
1104 if (!pyramid_lvl_node)
1105 std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << " (default)" << std::endl;
1106 else
1107 std::cout << "klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1108 }
1109 }
1110
1111 void read_lod(const pugi::xml_node &node)
1112 {
1113 bool use_lod_node = false;
1114 bool min_line_length_threshold_node = false;
1115 bool min_polygon_area_threshold_node = false;
1116
1117 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1118 if (dataNode.type() == pugi::node_element) {
1119 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1120 if (iter_data != m_nodeMap.end()) {
1121 switch (iter_data->second) {
1122 case use_lod:
1123 m_useLod = (dataNode.text().as_int() != 0);
1124 use_lod_node = true;
1125 break;
1126
1127 case min_line_length_threshold:
1128 m_minLineLengthThreshold = dataNode.text().as_double();
1129 min_line_length_threshold_node = true;
1130 break;
1131
1132 case min_polygon_area_threshold:
1133 m_minPolygonAreaThreshold = dataNode.text().as_double();
1134 min_polygon_area_threshold_node = true;
1135 break;
1136
1137 default:
1138 break;
1139 }
1140 }
1141 }
1142 }
1143
1144 if (m_verbose) {
1145 if (!use_lod_node)
1146 std::cout << "lod : use lod : " << m_useLod << " (default)" << std::endl;
1147 else
1148 std::cout << "lod : use lod : " << m_useLod << std::endl;
1149
1150 if (!min_line_length_threshold_node)
1151 std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << " (default)" << std::endl;
1152 else
1153 std::cout << "lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1154
1155 if (!min_polygon_area_threshold_node)
1156 std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << " (default)" << std::endl;
1157 else
1158 std::cout << "lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1159 }
1160 }
1161
1162 void read_projection_error(const pugi::xml_node &node)
1163 {
1164 bool step_node = false;
1165 bool kernel_size_node = false;
1166
1167 // current data values.
1168 double d_stp = m_projectionErrorMe.getSampleStep();
1169 std::string kernel_size_str;
1170
1171 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1172 if (dataNode.type() == pugi::node_element) {
1173 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1174 if (iter_data != m_nodeMap.end()) {
1175 switch (iter_data->second) {
1176 case projection_error_sample_step:
1177 d_stp = dataNode.text().as_int();
1178 step_node = true;
1179 break;
1180
1181 case projection_error_kernel_size:
1182 kernel_size_str = dataNode.text().as_string();
1183 kernel_size_node = true;
1184 break;
1185
1186 default:
1187 break;
1188 }
1189 }
1190 }
1191 }
1192
1193 m_projectionErrorMe.setSampleStep(d_stp);
1194
1195 if (kernel_size_str == "3x3") {
1196 m_projectionErrorKernelSize = 1;
1197 }
1198 else if (kernel_size_str == "5x5") {
1199 m_projectionErrorKernelSize = 2;
1200 }
1201 else if (kernel_size_str == "7x7") {
1202 m_projectionErrorKernelSize = 3;
1203 }
1204 else if (kernel_size_str == "9x9") {
1205 m_projectionErrorKernelSize = 4;
1206 }
1207 else if (kernel_size_str == "11x11") {
1208 m_projectionErrorKernelSize = 5;
1209 }
1210 else if (kernel_size_str == "13x13") {
1211 m_projectionErrorKernelSize = 6;
1212 }
1213 else if (kernel_size_str == "15x15") {
1214 m_projectionErrorKernelSize = 7;
1215 }
1216 else {
1217 std::cerr << "Unsupported kernel size." << std::endl;
1218 }
1219
1220 if (m_verbose) {
1221 if (!step_node)
1222 std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << " (default)"
1223 << std::endl;
1224 else
1225 std::cout << "projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1226
1227 if (!kernel_size_node)
1228 std::cout << "projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 << "x"
1229 << m_projectionErrorKernelSize * 2 + 1 << " (default)" << std::endl;
1230 else
1231 std::cout << "projection_error : kernel_size : " << kernel_size_str << std::endl;
1232 }
1233 }
1234
1240 void read_sample_deprecated(const pugi::xml_node &node)
1241 {
1242 bool step_node = false;
1243 // bool nb_sample_node = false;
1244
1245 // current data values.
1246 double d_stp = m_ecm.getSampleStep();
1247
1248 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1249 if (dataNode.type() == pugi::node_element) {
1250 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1251 if (iter_data != m_nodeMap.end()) {
1252 switch (iter_data->second) {
1253 case step:
1254 d_stp = dataNode.text().as_int();
1255 step_node = true;
1256 break;
1257
1258 default:
1259 break;
1260 }
1261 }
1262 }
1263 }
1264
1265 m_ecm.setSampleStep(d_stp);
1266
1267 if (m_verbose) {
1268 if (!step_node)
1269 std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << " (default)" << std::endl;
1270 else
1271 std::cout << "[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1272
1273 std::cout << " WARNING : This node (sample) is deprecated." << std::endl;
1274 std::cout << " It should be moved in the ecm node (me : sample)." << std::endl;
1275 }
1276 }
1277
1278 double getAngleAppear() const { return m_angleAppear; }
1279 double getAngleDisappear() const { return m_angleDisappear; }
1280
1281 void getCameraParameters(vpCameraParameters &cam) const { cam = m_cam; }
1282
1283 void getEdgeMe(vpMe &moving_edge) const { moving_edge = m_ecm; }
1284
1285 unsigned int getDepthDenseSamplingStepX() const { return m_depthDenseSamplingStepX; }
1286 unsigned int getDepthDenseSamplingStepY() const { return m_depthDenseSamplingStepY; }
1287
1288 vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
1289 {
1290 return m_depthNormalFeatureEstimationMethod;
1291 }
1292 int getDepthNormalPclPlaneEstimationMethod() const { return m_depthNormalPclPlaneEstimationMethod; }
1293 int getDepthNormalPclPlaneEstimationRansacMaxIter() const { return m_depthNormalPclPlaneEstimationRansacMaxIter; }
1294 double getDepthNormalPclPlaneEstimationRansacThreshold() const
1295 {
1296 return m_depthNormalPclPlaneEstimationRansacThreshold;
1297 }
1298 unsigned int getDepthNormalSamplingStepX() const { return m_depthNormalSamplingStepX; }
1299 unsigned int getDepthNormalSamplingStepY() const { return m_depthNormalSamplingStepY; }
1300
1301 double getFarClippingDistance() const { return m_farClipping; }
1302 bool getFovClipping() const { return m_fovClipping; }
1303
1304 unsigned int getKltBlockSize() const { return m_kltBlockSize; }
1305 double getKltHarrisParam() const { return m_kltHarrisParam; }
1306 unsigned int getKltMaskBorder() const { return m_kltMaskBorder; }
1307 unsigned int getKltMaxFeatures() const { return m_kltMaxFeatures; }
1308 double getKltMinDistance() const { return m_kltMinDist; }
1309 unsigned int getKltPyramidLevels() const { return m_kltPyramidLevels; }
1310 double getKltQuality() const { return m_kltQualityValue; }
1311 unsigned int getKltWindowSize() const { return m_kltWinSize; }
1312
1313 bool getLodState() const { return m_useLod; }
1314 double getLodMinLineLengthThreshold() const { return m_minLineLengthThreshold; }
1315 double getLodMinPolygonAreaThreshold() const { return m_minPolygonAreaThreshold; }
1316
1317 double getNearClippingDistance() const { return m_nearClipping; }
1318
1319 void getProjectionErrorMe(vpMe &me) const { me = m_projectionErrorMe; }
1320 unsigned int getProjectionErrorKernelSize() const { return m_projectionErrorKernelSize; }
1321
1322 bool hasFarClippingDistance() const { return m_hasFarClipping; }
1323 bool hasNearClippingDistance() const { return m_hasNearClipping; }
1324
1325 void setAngleAppear(const double &aappear) { m_angleAppear = aappear; }
1326 void setAngleDisappear(const double &adisappear) { m_angleDisappear = adisappear; }
1327
1328 void setCameraParameters(const vpCameraParameters &cam) { m_cam = cam; }
1329
1330 void setDepthDenseSamplingStepX(unsigned int stepX) { m_depthDenseSamplingStepX = stepX; }
1331 void setDepthDenseSamplingStepY(unsigned int stepY) { m_depthDenseSamplingStepY = stepY; }
1332 void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
1333 {
1334 m_depthNormalFeatureEstimationMethod = method;
1335 }
1336 void setDepthNormalPclPlaneEstimationMethod(int method) { m_depthNormalPclPlaneEstimationMethod = method; }
1337 void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter)
1338 {
1339 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1340 }
1341 void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
1342 {
1343 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1344 }
1345 void setDepthNormalSamplingStepX(unsigned int stepX) { m_depthNormalSamplingStepX = stepX; }
1346 void setDepthNormalSamplingStepY(unsigned int stepY) { m_depthNormalSamplingStepY = stepY; }
1347
1348 void setEdgeMe(const vpMe &moving_edge) { m_ecm = moving_edge; }
1349
1350 void setFarClippingDistance(const double &fclip) { m_farClipping = fclip; }
1351
1352 void setKltBlockSize(const unsigned int &bs) { m_kltBlockSize = bs; }
1353 void setKltHarrisParam(const double &hp) { m_kltHarrisParam = hp; }
1354 void setKltMaskBorder(const unsigned int &mb) { m_kltMaskBorder = mb; }
1355 void setKltMaxFeatures(const unsigned int &mF) { m_kltMaxFeatures = mF; }
1356 void setKltMinDistance(const double &mD) { m_kltMinDist = mD; }
1357 void setKltPyramidLevels(const unsigned int &pL) { m_kltPyramidLevels = pL; }
1358 void setKltQuality(const double &q) { m_kltQualityValue = q; }
1359 void setKltWindowSize(const unsigned int &w) { m_kltWinSize = w; }
1360
1361 void setNearClippingDistance(const double &nclip) { m_nearClipping = nclip; }
1362
1363 void setProjectionErrorMe(const vpMe &me) { m_projectionErrorMe = me; }
1364 void setProjectionErrorKernelSize(const unsigned int &kernel_size) { m_projectionErrorKernelSize = kernel_size; }
1365
1366 void setVerbose(bool verbose) { m_verbose = verbose; }
1367
1368protected:
1370 int m_parserType;
1372 vpCameraParameters m_cam;
1374 double m_angleAppear;
1376 double m_angleDisappear;
1378 bool m_hasNearClipping;
1380 double m_nearClipping;
1382 bool m_hasFarClipping;
1384 double m_farClipping;
1386 bool m_fovClipping;
1387 // LOD
1389 bool m_useLod;
1391 double m_minLineLengthThreshold;
1393 double m_minPolygonAreaThreshold;
1394 // Edge
1396 vpMe m_ecm;
1397 // KLT
1399 unsigned int m_kltMaskBorder;
1401 unsigned int m_kltMaxFeatures;
1403 unsigned int m_kltWinSize;
1405 double m_kltQualityValue;
1407 double m_kltMinDist;
1409 double m_kltHarrisParam;
1411 unsigned int m_kltBlockSize;
1413 unsigned int m_kltPyramidLevels;
1414 // Depth normal
1416 vpMbtFaceDepthNormal::vpFeatureEstimationType m_depthNormalFeatureEstimationMethod;
1418 int m_depthNormalPclPlaneEstimationMethod;
1420 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1422 double m_depthNormalPclPlaneEstimationRansacThreshold;
1424 unsigned int m_depthNormalSamplingStepX;
1426 unsigned int m_depthNormalSamplingStepY;
1427 // Depth dense
1429 unsigned int m_depthDenseSamplingStepX;
1431 unsigned int m_depthDenseSamplingStepY;
1432 // Projection error
1434 vpMe m_projectionErrorMe;
1436 unsigned int m_projectionErrorKernelSize;
1437 std::map<std::string, int> m_nodeMap;
1439 bool m_verbose;
1440
1441 enum vpDataToParseMb
1442 {
1443 // <conf>
1444 conf,
1445 // <face>
1446 face,
1447 angle_appear,
1448 angle_disappear,
1449 near_clipping,
1450 far_clipping,
1451 fov_clipping,
1452 // <camera>
1453 camera,
1454 height,
1455 width,
1456 u0,
1457 v0,
1458 px,
1459 py,
1460 lod,
1461 use_lod,
1462 min_line_length_threshold,
1463 min_polygon_area_threshold,
1464 // <ecm>
1465 ecm,
1466 mask,
1467 size,
1468 nb_mask,
1469 init_range,
1470 range,
1471 tracking,
1472 contrast,
1473 edge_threshold,
1474 edge_min_threshold,
1475 edge_threshold_ratio,
1476 edge_threshold_type,
1477 mu1,
1478 mu2,
1479 sample,
1480 step,
1481 // <klt>
1482 klt,
1483 mask_border,
1484 max_features,
1485 window_size,
1486 quality,
1487 min_distance,
1488 harris,
1489 size_block,
1490 pyramid_lvl,
1491 // <depth_normal>
1492 depth_normal,
1493 feature_estimation_method,
1494 PCL_plane_estimation,
1495 PCL_plane_estimation_method,
1496 PCL_plane_estimation_ransac_max_iter,
1497 PCL_plane_estimation_ransac_threshold,
1498 depth_sampling_step,
1499 depth_sampling_step_X,
1500 depth_sampling_step_Y,
1501 // <depth_dense>
1502 depth_dense,
1503 depth_dense_sampling_step,
1504 depth_dense_sampling_step_X,
1505 depth_dense_sampling_step_Y,
1506 // <projection_error>
1507 projection_error,
1508 projection_error_sample_step,
1509 projection_error_kernel_size
1510 };
1511
1515 void init()
1516 {
1517 //<conf>
1518 m_nodeMap["conf"] = conf;
1519 //<face>
1520 m_nodeMap["face"] = face;
1521 m_nodeMap["angle_appear"] = angle_appear;
1522 m_nodeMap["angle_disappear"] = angle_disappear;
1523 m_nodeMap["near_clipping"] = near_clipping;
1524 m_nodeMap["far_clipping"] = far_clipping;
1525 m_nodeMap["fov_clipping"] = fov_clipping;
1526 //<camera>
1527 m_nodeMap["camera"] = camera;
1528 m_nodeMap["height"] = height;
1529 m_nodeMap["width"] = width;
1530 m_nodeMap["u0"] = u0;
1531 m_nodeMap["v0"] = v0;
1532 m_nodeMap["px"] = px;
1533 m_nodeMap["py"] = py;
1534 //<lod>
1535 m_nodeMap["lod"] = lod;
1536 m_nodeMap["use_lod"] = use_lod;
1537 m_nodeMap["min_line_length_threshold"] = min_line_length_threshold;
1538 m_nodeMap["min_polygon_area_threshold"] = min_polygon_area_threshold;
1539 //<ecm>
1540 m_nodeMap["ecm"] = ecm;
1541 m_nodeMap["mask"] = mask;
1542 m_nodeMap["size"] = size;
1543 m_nodeMap["nb_mask"] = nb_mask;
1544 m_nodeMap["init_range"] = init_range;
1545 m_nodeMap["range"] = range;
1546 m_nodeMap["tracking"] = tracking;
1547 m_nodeMap["contrast"] = contrast;
1548 m_nodeMap["edge_threshold_type"] = edge_threshold_type;
1549 m_nodeMap["edge_threshold"] = edge_threshold;
1550 m_nodeMap["edge_min_threshold"] = edge_min_threshold;
1551 m_nodeMap["edge_threshold_margin_ratio"] = edge_threshold_ratio;
1552 m_nodeMap["mu1"] = mu1;
1553 m_nodeMap["mu2"] = mu2;
1554 m_nodeMap["sample"] = sample;
1555 m_nodeMap["step"] = step;
1556 //<klt>
1557 m_nodeMap["klt"] = klt;
1558 m_nodeMap["mask_border"] = mask_border;
1559 m_nodeMap["max_features"] = max_features;
1560 m_nodeMap["window_size"] = window_size;
1561 m_nodeMap["quality"] = quality;
1562 m_nodeMap["min_distance"] = min_distance;
1563 m_nodeMap["harris"] = harris;
1564 m_nodeMap["size_block"] = size_block;
1565 m_nodeMap["pyramid_lvl"] = pyramid_lvl;
1566 //<depth_normal>
1567 m_nodeMap["depth_normal"] = depth_normal;
1568 m_nodeMap["feature_estimation_method"] = feature_estimation_method;
1569 m_nodeMap["PCL_plane_estimation"] = PCL_plane_estimation;
1570 m_nodeMap["method"] = PCL_plane_estimation_method;
1571 m_nodeMap["ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1572 m_nodeMap["ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1573 m_nodeMap["sampling_step"] = depth_sampling_step;
1574 m_nodeMap["step_X"] = depth_sampling_step_X;
1575 m_nodeMap["step_Y"] = depth_sampling_step_Y;
1576 //<depth_dense>
1577 m_nodeMap["depth_dense"] = depth_dense;
1578 m_nodeMap["sampling_step"] = depth_dense_sampling_step;
1579 m_nodeMap["step_X"] = depth_dense_sampling_step_X;
1580 m_nodeMap["step_Y"] = depth_dense_sampling_step_Y;
1581 //<projection_error>
1582 m_nodeMap["projection_error"] = projection_error;
1583 m_nodeMap["sample_step"] = projection_error_sample_step;
1584 m_nodeMap["kernel_size"] = projection_error_kernel_size;
1585 }
1586
1587private:
1588 static bool m_call_setlocale;
1589};
1590
1591bool vpMbtXmlGenericParser::Impl::m_call_setlocale = true;
1592
1593#endif // DOXYGEN_SHOULD_SKIP_THIS
1594
1595vpMbtXmlGenericParser::vpMbtXmlGenericParser(int type) : m_impl(new Impl(type))
1596{ }
1597
1599
1605void vpMbtXmlGenericParser::parse(const std::string &filename) { m_impl->parse(filename); }
1606
1610double vpMbtXmlGenericParser::getAngleAppear() const { return m_impl->getAngleAppear(); }
1611
1615double vpMbtXmlGenericParser::getAngleDisappear() const { return m_impl->getAngleDisappear(); }
1616
1617void vpMbtXmlGenericParser::getCameraParameters(vpCameraParameters &cam) const { m_impl->getCameraParameters(cam); }
1618
1622void vpMbtXmlGenericParser::getEdgeMe(vpMe &ecm) const { m_impl->getEdgeMe(ecm); }
1623
1627unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepX() const { return m_impl->getDepthDenseSamplingStepX(); }
1628
1632unsigned int vpMbtXmlGenericParser::getDepthDenseSamplingStepY() const { return m_impl->getDepthDenseSamplingStepY(); }
1633
1638{
1639 return m_impl->getDepthNormalFeatureEstimationMethod();
1640}
1641
1646{
1647 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1648}
1649
1654{
1655 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1656}
1657
1662{
1663 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1664}
1665
1670{
1671 return m_impl->getDepthNormalSamplingStepX();
1672}
1673
1678{
1679 return m_impl->getDepthNormalSamplingStepY();
1680}
1681
1685double vpMbtXmlGenericParser::getFarClippingDistance() const { return m_impl->getFarClippingDistance(); }
1686
1690bool vpMbtXmlGenericParser::getFovClipping() const { return m_impl->getFovClipping(); }
1691
1695unsigned int vpMbtXmlGenericParser::getKltBlockSize() const { return m_impl->getKltBlockSize(); }
1696
1700double vpMbtXmlGenericParser::getKltHarrisParam() const { return m_impl->getKltHarrisParam(); }
1701
1705unsigned int vpMbtXmlGenericParser::getKltMaskBorder() const { return m_impl->getKltMaskBorder(); }
1706
1710unsigned int vpMbtXmlGenericParser::getKltMaxFeatures() const { return m_impl->getKltMaxFeatures(); }
1711
1715double vpMbtXmlGenericParser::getKltMinDistance() const { return m_impl->getKltMinDistance(); }
1716
1720unsigned int vpMbtXmlGenericParser::getKltPyramidLevels() const { return m_impl->getKltPyramidLevels(); }
1721
1725double vpMbtXmlGenericParser::getKltQuality() const { return m_impl->getKltQuality(); }
1726
1730unsigned int vpMbtXmlGenericParser::getKltWindowSize() const { return m_impl->getKltWindowSize(); }
1731
1735bool vpMbtXmlGenericParser::getLodState() const { return m_impl->getLodState(); }
1736
1740double vpMbtXmlGenericParser::getLodMinLineLengthThreshold() const { return m_impl->getLodMinLineLengthThreshold(); }
1741
1745double vpMbtXmlGenericParser::getLodMinPolygonAreaThreshold() const { return m_impl->getLodMinPolygonAreaThreshold(); }
1746
1750double vpMbtXmlGenericParser::getNearClippingDistance() const { return m_impl->getNearClippingDistance(); }
1751
1755void vpMbtXmlGenericParser::getProjectionErrorMe(vpMe &me) const { m_impl->getProjectionErrorMe(me); }
1756
1758{
1759 return m_impl->getProjectionErrorKernelSize();
1760}
1761
1767bool vpMbtXmlGenericParser::hasFarClippingDistance() const { return m_impl->hasFarClippingDistance(); }
1768
1774bool vpMbtXmlGenericParser::hasNearClippingDistance() const { return m_impl->hasNearClippingDistance(); }
1775
1781void vpMbtXmlGenericParser::setAngleAppear(const double &aappear) { m_impl->setAngleAppear(aappear); }
1782
1788void vpMbtXmlGenericParser::setAngleDisappear(const double &adisappear) { m_impl->setAngleDisappear(adisappear); }
1789
1795void vpMbtXmlGenericParser::setCameraParameters(const vpCameraParameters &cam) { m_impl->setCameraParameters(cam); }
1796
1803{
1804 m_impl->setDepthDenseSamplingStepX(stepX);
1805}
1806
1813{
1814 m_impl->setDepthDenseSamplingStepY(stepY);
1815}
1816
1824{
1825 m_impl->setDepthNormalFeatureEstimationMethod(method);
1826}
1827
1834{
1835 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1836}
1837
1844{
1845 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1846}
1847
1854{
1855 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1856}
1857
1864{
1865 m_impl->setDepthNormalSamplingStepX(stepX);
1866}
1867
1874{
1875 m_impl->setDepthNormalSamplingStepY(stepY);
1876}
1877
1883void vpMbtXmlGenericParser::setEdgeMe(const vpMe &moving_edge) { m_impl->setEdgeMe(moving_edge); }
1884
1890void vpMbtXmlGenericParser::setFarClippingDistance(const double &fclip) { m_impl->setFarClippingDistance(fclip); }
1891
1897void vpMbtXmlGenericParser::setKltBlockSize(const unsigned int &bs) { m_impl->setKltBlockSize(bs); }
1898
1904void vpMbtXmlGenericParser::setKltHarrisParam(const double &hp) { m_impl->setKltHarrisParam(hp); }
1905
1911void vpMbtXmlGenericParser::setKltMaskBorder(const unsigned int &mb) { m_impl->setKltMaskBorder(mb); }
1912
1918void vpMbtXmlGenericParser::setKltMaxFeatures(const unsigned int &mF) { m_impl->setKltMaxFeatures(mF); }
1919
1925void vpMbtXmlGenericParser::setKltMinDistance(const double &mD) { m_impl->setKltMinDistance(mD); }
1926
1932void vpMbtXmlGenericParser::setKltPyramidLevels(const unsigned int &pL) { m_impl->setKltPyramidLevels(pL); }
1933
1939void vpMbtXmlGenericParser::setKltQuality(const double &q) { m_impl->setKltQuality(q); }
1940
1946void vpMbtXmlGenericParser::setKltWindowSize(const unsigned int &w) { m_impl->setKltWindowSize(w); }
1947
1953void vpMbtXmlGenericParser::setNearClippingDistance(const double &nclip) { m_impl->setNearClippingDistance(nclip); }
1954
1960void vpMbtXmlGenericParser::setProjectionErrorMe(const vpMe &me) { m_impl->setProjectionErrorMe(me); }
1961
1968{
1969 m_impl->setProjectionErrorKernelSize(size);
1970}
1971
1977void vpMbtXmlGenericParser::setVerbose(bool verbose) { m_impl->setVerbose(verbose); }
1978END_VISP_NAMESPACE
1979#elif !defined(VISP_BUILD_SHARED_LIBS)
1980// Work around to avoid warning: libvisp_core.a(vpMbtXmlGenericParser.cpp.o) has no symbols
1981void dummy_vpMbtXmlGenericParser() { }
1982
1983#endif
Generic class defining intrinsic camera parameters.
@ ioError
I/O error.
Definition vpException.h:67
@ badValue
Used to indicate that a value is not in the allowed range.
Definition vpException.h:73
void setDepthNormalPclPlaneEstimationRansacMaxIter(int maxIter)
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
unsigned int getKltMaxFeatures() const
void setProjectionErrorMe(const vpMe &me)
unsigned int getDepthNormalSamplingStepX() const
unsigned int getProjectionErrorKernelSize() const
void setKltMinDistance(const double &mD)
unsigned int getKltBlockSize() const
void getCameraParameters(vpCameraParameters &cam) const
vpMbtXmlGenericParser(int type=EDGE_PARSER)
void setDepthDenseSamplingStepY(unsigned int stepY)
void setEdgeMe(const vpMe &ecm)
unsigned int getDepthNormalSamplingStepY() const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
void setKltMaskBorder(const unsigned int &mb)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
void getEdgeMe(vpMe &ecm) const
double getLodMinLineLengthThreshold() const
void setDepthNormalPclPlaneEstimationMethod(int method)
void setDepthNormalSamplingStepX(unsigned int stepX)
unsigned int getKltMaskBorder() const
void setAngleDisappear(const double &adisappear)
void setDepthDenseSamplingStepX(unsigned int stepX)
void setProjectionErrorKernelSize(const unsigned int &size)
void setKltPyramidLevels(const unsigned int &pL)
void setKltWindowSize(const unsigned int &w)
void setKltMaxFeatures(const unsigned int &mF)
int getDepthNormalPclPlaneEstimationMethod() const
void setAngleAppear(const double &aappear)
void setKltBlockSize(const unsigned int &bs)
void setKltHarrisParam(const double &hp)
unsigned int getDepthDenseSamplingStepY() const
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void parse(const std::string &filename)
void setNearClippingDistance(const double &nclip)
void setKltQuality(const double &q)
void getProjectionErrorMe(vpMe &me) const
unsigned int getKltPyramidLevels() const
void setFarClippingDistance(const double &fclip)
unsigned int getKltWindowSize() const
void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
unsigned int getDepthDenseSamplingStepX() const
void setCameraParameters(const vpCameraParameters &cam)
double getLodMinPolygonAreaThreshold() const
void setDepthNormalSamplingStepY(unsigned int stepY)
Definition vpMe.h:143
vpLikelihoodThresholdType
Definition vpMe.h:149