35 #include <visp3/core/vpConfig.h>
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
43 #if defined(VISP_HAVE_PUGIXML)
44 #include <pugixml.hpp>
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49 class vpMbtXmlGenericParser::Impl
57 m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
58 m_farClipping(false), m_fovClipping(false),
60 m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
64 m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
65 m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
68 m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
69 m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2),
70 m_depthNormalSamplingStepY(2),
72 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
74 m_projectionErrorMe(), m_projectionErrorKernelSize(2),
75 m_nodeMap(), m_verbose(true)
79 if (m_call_setlocale) {
84 if (std::setlocale(LC_ALL,
"C") ==
nullptr) {
85 std::cerr <<
"Cannot set locale to C" << std::endl;
87 m_call_setlocale =
false;
92 void parse(
const std::string &filename)
94 pugi::xml_document doc;
95 if (!doc.load_file(filename.c_str())) {
99 bool camera_node =
false;
100 bool face_node =
false;
101 bool ecm_node =
false;
102 bool klt_node =
false;
103 bool lod_node =
false;
104 bool depth_normal_node =
false;
105 bool depth_dense_node =
false;
106 bool projection_error_node =
false;
108 pugi::xml_node root_node = doc.document_element();
109 for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
110 if (dataNode.type() == pugi::node_element) {
111 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
112 if (iter_data != m_nodeMap.end()) {
113 switch (iter_data->second) {
116 read_camera(dataNode);
144 read_sample_deprecated(dataNode);
156 read_depth_normal(dataNode);
157 depth_normal_node =
true;
163 read_depth_dense(dataNode);
164 depth_dense_node =
true;
168 case projection_error:
170 read_projection_error(dataNode);
171 projection_error_node =
true;
184 if (!projection_error_node) {
185 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
187 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
188 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
193 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
194 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
195 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
196 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
200 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
201 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
205 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
206 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
207 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
211 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
212 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
213 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
214 std::cout <<
"me : contrast : threshold type : " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
215 std::cout <<
"me : contrast : threshold : " << m_ecm.getThreshold() <<
" (default)" << std::endl;
216 std::cout <<
"me : contrast : mu1 : " << m_ecm.getMu1() <<
" (default)" << std::endl;
217 std::cout <<
"me : contrast : mu2 : " << m_ecm.getMu2() <<
" (default)" << std::endl;
218 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
221 if (!klt_node && (m_parserType &
KLT_PARSER)) {
222 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
223 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
224 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
225 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
226 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
227 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
228 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
229 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
233 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
234 <<
" (default)" << std::endl;
235 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
236 <<
" (default)" << std::endl;
237 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : "
238 << m_depthNormalPclPlaneEstimationRansacMaxIter <<
" (default)" << std::endl;
239 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
240 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
241 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
243 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
248 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)"
250 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)"
262 void read_camera(
const pugi::xml_node &node)
264 bool u0_node =
false;
265 bool v0_node =
false;
266 bool px_node =
false;
267 bool py_node =
false;
270 double d_u0 = m_cam.get_u0();
271 double d_v0 = m_cam.get_v0();
272 double d_px = m_cam.get_px();
273 double d_py = m_cam.get_py();
275 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
276 if (dataNode.type() == pugi::node_element) {
277 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
278 if (iter_data != m_nodeMap.end()) {
279 switch (iter_data->second) {
281 d_u0 = dataNode.text().as_double();
286 d_v0 = dataNode.text().as_double();
291 d_px = dataNode.text().as_double();
296 d_py = dataNode.text().as_double();
307 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
311 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
313 std::cout <<
"camera : u0 : " << m_cam.get_u0() << std::endl;
316 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
318 std::cout <<
"camera : v0 : " << m_cam.get_v0() << std::endl;
321 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
323 std::cout <<
"camera : px : " << m_cam.get_px() << std::endl;
326 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
328 std::cout <<
"camera : py : " << m_cam.get_py() << std::endl;
337 void read_depth_normal(
const pugi::xml_node &node)
339 bool feature_estimation_method_node =
false;
340 bool PCL_plane_estimation_node =
false;
341 bool sampling_step_node =
false;
343 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
344 if (dataNode.type() == pugi::node_element) {
345 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
346 if (iter_data != m_nodeMap.end()) {
347 switch (iter_data->second) {
348 case feature_estimation_method:
349 m_depthNormalFeatureEstimationMethod =
351 feature_estimation_method_node =
true;
354 case PCL_plane_estimation:
355 read_depth_normal_PCL(dataNode);
356 PCL_plane_estimation_node =
true;
359 case depth_sampling_step:
360 read_depth_normal_sampling_step(dataNode);
361 sampling_step_node =
true;
372 if (!feature_estimation_method_node)
373 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
374 <<
" (default)" << std::endl;
376 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
378 if (!PCL_plane_estimation_node) {
379 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
380 <<
" (default)" << std::endl;
381 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
382 <<
" (default)" << std::endl;
383 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
384 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
387 if (!sampling_step_node) {
388 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
390 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
401 void read_depth_normal_PCL(
const pugi::xml_node &node)
403 bool PCL_plane_estimation_method_node =
false;
404 bool PCL_plane_estimation_ransac_max_iter_node =
false;
405 bool PCL_plane_estimation_ransac_threshold_node =
false;
407 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
408 if (dataNode.type() == pugi::node_element) {
409 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
410 if (iter_data != m_nodeMap.end()) {
411 switch (iter_data->second) {
412 case PCL_plane_estimation_method:
413 m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
414 PCL_plane_estimation_method_node =
true;
417 case PCL_plane_estimation_ransac_max_iter:
418 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
419 PCL_plane_estimation_ransac_max_iter_node =
true;
422 case PCL_plane_estimation_ransac_threshold:
423 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
424 PCL_plane_estimation_ransac_threshold_node =
true;
435 if (!PCL_plane_estimation_method_node)
436 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
437 <<
" (default)" << std::endl;
439 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
442 if (!PCL_plane_estimation_ransac_max_iter_node)
443 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
444 <<
" (default)" << std::endl;
446 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
449 if (!PCL_plane_estimation_ransac_threshold_node)
450 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
451 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
453 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
454 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
463 void read_depth_normal_sampling_step(
const pugi::xml_node &node)
465 bool sampling_step_X_node =
false;
466 bool sampling_step_Y_node =
false;
468 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
469 if (dataNode.type() == pugi::node_element) {
470 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
471 if (iter_data != m_nodeMap.end()) {
472 switch (iter_data->second) {
473 case depth_sampling_step_X:
474 m_depthNormalSamplingStepX = dataNode.text().as_uint();
475 sampling_step_X_node =
true;
478 case depth_sampling_step_Y:
479 m_depthNormalSamplingStepY = dataNode.text().as_uint();
480 sampling_step_Y_node =
true;
491 if (!sampling_step_X_node)
492 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX <<
" (default)"
495 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
497 if (!sampling_step_Y_node)
498 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY <<
" (default)"
501 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
510 void read_depth_dense(
const pugi::xml_node &node)
512 bool sampling_step_node =
false;
514 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
515 if (dataNode.type() == pugi::node_element) {
516 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
517 if (iter_data != m_nodeMap.end()) {
518 switch (iter_data->second) {
519 case depth_dense_sampling_step:
520 read_depth_dense_sampling_step(dataNode);
521 sampling_step_node =
true;
531 if (!sampling_step_node && m_verbose) {
532 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
533 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
542 void read_depth_dense_sampling_step(
const pugi::xml_node &node)
544 bool sampling_step_X_node =
false;
545 bool sampling_step_Y_node =
false;
547 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
548 if (dataNode.type() == pugi::node_element) {
549 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
550 if (iter_data != m_nodeMap.end()) {
551 switch (iter_data->second) {
552 case depth_dense_sampling_step_X:
553 m_depthDenseSamplingStepX = dataNode.text().as_uint();
554 sampling_step_X_node =
true;
557 case depth_dense_sampling_step_Y:
558 m_depthDenseSamplingStepY = dataNode.text().as_uint();
559 sampling_step_Y_node =
true;
570 if (!sampling_step_X_node)
571 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX <<
" (default)"
574 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
576 if (!sampling_step_Y_node)
577 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY <<
" (default)"
580 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
589 void read_ecm(
const pugi::xml_node &node)
591 bool mask_node =
false;
592 bool range_node =
false;
593 bool contrast_node =
false;
594 bool sample_node =
false;
596 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
597 if (dataNode.type() == pugi::node_element) {
598 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
599 if (iter_data != m_nodeMap.end()) {
600 switch (iter_data->second) {
602 read_ecm_mask(dataNode);
607 read_ecm_range(dataNode);
612 read_ecm_contrast(dataNode);
613 contrast_node =
true;
617 read_ecm_sample(dataNode);
630 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
631 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
635 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
638 if (!contrast_node) {
639 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
640 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
641 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
642 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
646 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
656 void read_ecm_contrast(
const pugi::xml_node &node)
658 bool edge_threshold_type_node =
false;
659 bool edge_threshold_node =
false;
660 bool mu1_node =
false;
661 bool mu2_node =
false;
665 double d_edge_threshold = m_ecm.getThreshold();
666 double d_mu1 = m_ecm.getMu1();
667 double d_mu2 = m_ecm.getMu2();
669 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
670 if (dataNode.type() == pugi::node_element) {
671 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
672 if (iter_data != m_nodeMap.end()) {
673 switch (iter_data->second) {
674 case edge_threshold_type:
676 edge_threshold_type_node =
true;
680 d_edge_threshold = dataNode.text().as_int();
681 edge_threshold_node =
true;
685 d_mu1 = dataNode.text().as_double();
690 d_mu2 = dataNode.text().as_double();
703 m_ecm.setLikelihoodThresholdType(d_edge_threshold_type);
704 m_ecm.setThreshold(d_edge_threshold);
707 if (!edge_threshold_type_node)
708 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
710 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << std::endl;
712 if (!edge_threshold_node)
713 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
715 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() << std::endl;
718 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
720 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() << std::endl;
723 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
725 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() << std::endl;
734 void read_ecm_mask(
const pugi::xml_node &node)
736 bool size_node =
false;
737 bool nb_mask_node =
false;
740 unsigned int d_size = m_ecm.getMaskSize();
741 unsigned int d_nb_mask = m_ecm.getMaskNumber();
743 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
744 if (dataNode.type() == pugi::node_element) {
745 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
746 if (iter_data != m_nodeMap.end()) {
747 switch (iter_data->second) {
749 d_size = dataNode.text().as_uint();
754 d_nb_mask = dataNode.text().as_uint();
765 m_ecm.setMaskSize(d_size);
770 "parameter should be different "
771 "from zero in xml file"));
772 m_ecm.setMaskNumber(d_nb_mask);
776 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
778 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() << std::endl;
781 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
783 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
792 void read_ecm_range(
const pugi::xml_node &node)
794 bool tracking_node =
false;
797 unsigned int m_range_tracking = m_ecm.getRange();
799 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
800 if (dataNode.type() == pugi::node_element) {
801 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
802 if (iter_data != m_nodeMap.end()) {
803 switch (iter_data->second) {
805 m_range_tracking = dataNode.text().as_uint();
806 tracking_node =
true;
816 m_ecm.setRange(m_range_tracking);
820 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
822 std::cout <<
"me : range : tracking : " << m_ecm.getRange() << std::endl;
831 void read_ecm_sample(
const pugi::xml_node &node)
833 bool step_node =
false;
836 double d_stp = m_ecm.getSampleStep();
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) {
844 d_stp = dataNode.text().as_int();
855 m_ecm.setSampleStep(d_stp);
859 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
861 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
870 void read_face(
const pugi::xml_node &node)
872 bool angle_appear_node =
false;
873 bool angle_disappear_node =
false;
874 bool near_clipping_node =
false;
875 bool far_clipping_node =
false;
876 bool fov_clipping_node =
false;
877 m_hasNearClipping =
false;
878 m_hasFarClipping =
false;
880 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
881 if (dataNode.type() == pugi::node_element) {
882 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
883 if (iter_data != m_nodeMap.end()) {
884 switch (iter_data->second) {
886 m_angleAppear = dataNode.text().as_double();
887 angle_appear_node =
true;
890 case angle_disappear:
891 m_angleDisappear = dataNode.text().as_double();
892 angle_disappear_node =
true;
896 m_nearClipping = dataNode.text().as_double();
897 m_hasNearClipping =
true;
898 near_clipping_node =
true;
902 m_farClipping = dataNode.text().as_double();
903 m_hasFarClipping =
true;
904 far_clipping_node =
true;
908 if (dataNode.text().as_int())
909 m_fovClipping =
true;
911 m_fovClipping =
false;
912 fov_clipping_node =
true;
923 if (!angle_appear_node)
924 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
926 std::cout <<
"face : Angle Appear : " << m_angleAppear << std::endl;
928 if (!angle_disappear_node)
929 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
931 std::cout <<
"face : Angle Disappear : " << m_angleDisappear << std::endl;
933 if (near_clipping_node)
934 std::cout <<
"face : Near Clipping : " << m_nearClipping << std::endl;
936 if (far_clipping_node)
937 std::cout <<
"face : Far Clipping : " << m_farClipping << std::endl;
939 if (fov_clipping_node) {
941 std::cout <<
"face : Fov Clipping : True" << std::endl;
943 std::cout <<
"face : Fov Clipping : False" << std::endl;
953 void read_klt(
const pugi::xml_node &node)
955 bool mask_border_node =
false;
956 bool max_features_node =
false;
957 bool window_size_node =
false;
958 bool quality_node =
false;
959 bool min_distance_node =
false;
960 bool harris_node =
false;
961 bool size_block_node =
false;
962 bool pyramid_lvl_node =
false;
964 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
965 if (dataNode.type() == pugi::node_element) {
966 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
967 if (iter_data != m_nodeMap.end()) {
968 switch (iter_data->second) {
970 m_kltMaskBorder = dataNode.text().as_uint();
971 mask_border_node =
true;
975 m_kltMaxFeatures = dataNode.text().as_uint();
976 max_features_node =
true;
980 m_kltWinSize = dataNode.text().as_uint();
981 window_size_node =
true;
985 m_kltQualityValue = dataNode.text().as_double();
990 m_kltMinDist = dataNode.text().as_double();
991 min_distance_node =
true;
995 m_kltHarrisParam = dataNode.text().as_double();
1000 m_kltBlockSize = dataNode.text().as_uint();
1001 size_block_node =
true;
1005 m_kltPyramidLevels = dataNode.text().as_uint();
1006 pyramid_lvl_node =
true;
1017 if (!mask_border_node)
1018 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
1020 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder << std::endl;
1022 if (!max_features_node)
1023 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
1025 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures << std::endl;
1027 if (!window_size_node)
1028 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
1030 std::cout <<
"klt : Windows Size : " << m_kltWinSize << std::endl;
1033 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
1035 std::cout <<
"klt : Quality : " << m_kltQualityValue << std::endl;
1037 if (!min_distance_node)
1038 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
1040 std::cout <<
"klt : Min Distance : " << m_kltMinDist << std::endl;
1043 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
1045 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1047 if (!size_block_node)
1048 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
1050 std::cout <<
"klt : Block Size : " << m_kltBlockSize << std::endl;
1052 if (!pyramid_lvl_node)
1053 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
1055 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1059 void read_lod(
const pugi::xml_node &node)
1061 bool use_lod_node =
false;
1062 bool min_line_length_threshold_node =
false;
1063 bool min_polygon_area_threshold_node =
false;
1065 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1066 if (dataNode.type() == pugi::node_element) {
1067 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1068 if (iter_data != m_nodeMap.end()) {
1069 switch (iter_data->second) {
1071 m_useLod = (dataNode.text().as_int() != 0);
1072 use_lod_node =
true;
1075 case min_line_length_threshold:
1076 m_minLineLengthThreshold = dataNode.text().as_double();
1077 min_line_length_threshold_node =
true;
1080 case min_polygon_area_threshold:
1081 m_minPolygonAreaThreshold = dataNode.text().as_double();
1082 min_polygon_area_threshold_node =
true;
1094 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
1096 std::cout <<
"lod : use lod : " << m_useLod << std::endl;
1098 if (!min_line_length_threshold_node)
1099 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
1101 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1103 if (!min_polygon_area_threshold_node)
1104 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
1106 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1110 void read_projection_error(
const pugi::xml_node &node)
1112 bool step_node =
false;
1113 bool kernel_size_node =
false;
1116 double d_stp = m_projectionErrorMe.getSampleStep();
1117 std::string kernel_size_str;
1119 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1120 if (dataNode.type() == pugi::node_element) {
1121 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1122 if (iter_data != m_nodeMap.end()) {
1123 switch (iter_data->second) {
1124 case projection_error_sample_step:
1125 d_stp = dataNode.text().as_int();
1129 case projection_error_kernel_size:
1130 kernel_size_str = dataNode.text().as_string();
1131 kernel_size_node =
true;
1141 m_projectionErrorMe.setSampleStep(d_stp);
1143 if (kernel_size_str ==
"3x3") {
1144 m_projectionErrorKernelSize = 1;
1146 else if (kernel_size_str ==
"5x5") {
1147 m_projectionErrorKernelSize = 2;
1149 else if (kernel_size_str ==
"7x7") {
1150 m_projectionErrorKernelSize = 3;
1152 else if (kernel_size_str ==
"9x9") {
1153 m_projectionErrorKernelSize = 4;
1155 else if (kernel_size_str ==
"11x11") {
1156 m_projectionErrorKernelSize = 5;
1158 else if (kernel_size_str ==
"13x13") {
1159 m_projectionErrorKernelSize = 6;
1161 else if (kernel_size_str ==
"15x15") {
1162 m_projectionErrorKernelSize = 7;
1165 std::cerr <<
"Unsupported kernel size." << std::endl;
1170 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
1173 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1175 if (!kernel_size_node)
1176 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
1177 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
1179 std::cout <<
"projection_error : kernel_size : " << kernel_size_str << std::endl;
1188 void read_sample_deprecated(
const pugi::xml_node &node)
1190 bool step_node =
false;
1194 double d_stp = m_ecm.getSampleStep();
1196 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1197 if (dataNode.type() == pugi::node_element) {
1198 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1199 if (iter_data != m_nodeMap.end()) {
1200 switch (iter_data->second) {
1202 d_stp = dataNode.text().as_int();
1213 m_ecm.setSampleStep(d_stp);
1217 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
1219 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1221 std::cout <<
" WARNING : This node (sample) is deprecated." << std::endl;
1222 std::cout <<
" It should be moved in the ecm node (me : sample)." << std::endl;
1231 void getEdgeMe(
vpMe &moving_edge)
const { moving_edge = m_ecm; }
1238 return m_depthNormalFeatureEstimationMethod;
1244 return m_depthNormalPclPlaneEstimationRansacThreshold;
1273 void setAngleAppear(
const double &aappear) { m_angleAppear = aappear; }
1274 void setAngleDisappear(
const double &adisappear) { m_angleDisappear = adisappear; }
1282 m_depthNormalFeatureEstimationMethod = method;
1287 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1291 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1296 void setEdgeMe(
const vpMe &moving_edge) { m_ecm = moving_edge; }
1306 void setKltQuality(
const double &q) { m_kltQualityValue = q; }
1314 void setVerbose(
bool verbose) { m_verbose = verbose; }
1322 double m_angleAppear;
1324 double m_angleDisappear;
1326 bool m_hasNearClipping;
1328 double m_nearClipping;
1330 bool m_hasFarClipping;
1332 double m_farClipping;
1339 double m_minLineLengthThreshold;
1341 double m_minPolygonAreaThreshold;
1347 unsigned int m_kltMaskBorder;
1349 unsigned int m_kltMaxFeatures;
1351 unsigned int m_kltWinSize;
1353 double m_kltQualityValue;
1355 double m_kltMinDist;
1357 double m_kltHarrisParam;
1359 unsigned int m_kltBlockSize;
1361 unsigned int m_kltPyramidLevels;
1366 int m_depthNormalPclPlaneEstimationMethod;
1368 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1370 double m_depthNormalPclPlaneEstimationRansacThreshold;
1372 unsigned int m_depthNormalSamplingStepX;
1374 unsigned int m_depthNormalSamplingStepY;
1377 unsigned int m_depthDenseSamplingStepX;
1379 unsigned int m_depthDenseSamplingStepY;
1382 vpMe m_projectionErrorMe;
1384 unsigned int m_projectionErrorKernelSize;
1385 std::map<std::string, int> m_nodeMap;
1389 enum vpDataToParseMb
1410 min_line_length_threshold,
1411 min_polygon_area_threshold,
1421 edge_threshold_type,
1438 feature_estimation_method,
1439 PCL_plane_estimation,
1440 PCL_plane_estimation_method,
1441 PCL_plane_estimation_ransac_max_iter,
1442 PCL_plane_estimation_ransac_threshold,
1443 depth_sampling_step,
1444 depth_sampling_step_X,
1445 depth_sampling_step_Y,
1448 depth_dense_sampling_step,
1449 depth_dense_sampling_step_X,
1450 depth_dense_sampling_step_Y,
1453 projection_error_sample_step,
1454 projection_error_kernel_size
1463 m_nodeMap[
"conf"] = conf;
1465 m_nodeMap[
"face"] = face;
1466 m_nodeMap[
"angle_appear"] = angle_appear;
1467 m_nodeMap[
"angle_disappear"] = angle_disappear;
1468 m_nodeMap[
"near_clipping"] = near_clipping;
1469 m_nodeMap[
"far_clipping"] = far_clipping;
1470 m_nodeMap[
"fov_clipping"] = fov_clipping;
1472 m_nodeMap[
"camera"] = camera;
1473 m_nodeMap[
"height"] = height;
1474 m_nodeMap[
"width"] = width;
1475 m_nodeMap[
"u0"] = u0;
1476 m_nodeMap[
"v0"] = v0;
1477 m_nodeMap[
"px"] = px;
1478 m_nodeMap[
"py"] = py;
1480 m_nodeMap[
"lod"] = lod;
1481 m_nodeMap[
"use_lod"] = use_lod;
1482 m_nodeMap[
"min_line_length_threshold"] = min_line_length_threshold;
1483 m_nodeMap[
"min_polygon_area_threshold"] = min_polygon_area_threshold;
1485 m_nodeMap[
"ecm"] = ecm;
1486 m_nodeMap[
"mask"] = mask;
1487 m_nodeMap[
"size"] = size;
1488 m_nodeMap[
"nb_mask"] = nb_mask;
1489 m_nodeMap[
"range"] = range;
1490 m_nodeMap[
"tracking"] = tracking;
1491 m_nodeMap[
"contrast"] = contrast;
1492 m_nodeMap[
"edge_threshold_type"] = edge_threshold_type;
1493 m_nodeMap[
"edge_threshold"] = edge_threshold;
1494 m_nodeMap[
"mu1"] = mu1;
1495 m_nodeMap[
"mu2"] = mu2;
1496 m_nodeMap[
"sample"] = sample;
1497 m_nodeMap[
"step"] = step;
1499 m_nodeMap[
"klt"] = klt;
1500 m_nodeMap[
"mask_border"] = mask_border;
1501 m_nodeMap[
"max_features"] = max_features;
1502 m_nodeMap[
"window_size"] = window_size;
1503 m_nodeMap[
"quality"] = quality;
1504 m_nodeMap[
"min_distance"] = min_distance;
1505 m_nodeMap[
"harris"] = harris;
1506 m_nodeMap[
"size_block"] = size_block;
1507 m_nodeMap[
"pyramid_lvl"] = pyramid_lvl;
1509 m_nodeMap[
"depth_normal"] = depth_normal;
1510 m_nodeMap[
"feature_estimation_method"] = feature_estimation_method;
1511 m_nodeMap[
"PCL_plane_estimation"] = PCL_plane_estimation;
1512 m_nodeMap[
"method"] = PCL_plane_estimation_method;
1513 m_nodeMap[
"ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1514 m_nodeMap[
"ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1515 m_nodeMap[
"sampling_step"] = depth_sampling_step;
1516 m_nodeMap[
"step_X"] = depth_sampling_step_X;
1517 m_nodeMap[
"step_Y"] = depth_sampling_step_Y;
1519 m_nodeMap[
"depth_dense"] = depth_dense;
1520 m_nodeMap[
"sampling_step"] = depth_dense_sampling_step;
1521 m_nodeMap[
"step_X"] = depth_dense_sampling_step_X;
1522 m_nodeMap[
"step_Y"] = depth_dense_sampling_step_Y;
1524 m_nodeMap[
"projection_error"] = projection_error;
1525 m_nodeMap[
"sample_step"] = projection_error_sample_step;
1526 m_nodeMap[
"kernel_size"] = projection_error_kernel_size;
1530 static bool m_call_setlocale;
1533 bool vpMbtXmlGenericParser::Impl::m_call_setlocale =
true;
1581 return m_impl->getDepthNormalFeatureEstimationMethod();
1589 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1597 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1605 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1613 return m_impl->getDepthNormalSamplingStepX();
1621 return m_impl->getDepthNormalSamplingStepY();
1701 return m_impl->getProjectionErrorKernelSize();
1746 m_impl->setDepthDenseSamplingStepX(stepX);
1756 m_impl->setDepthDenseSamplingStepY(stepY);
1767 m_impl->setDepthNormalFeatureEstimationMethod(method);
1777 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1787 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1797 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1807 m_impl->setDepthNormalSamplingStepX(stepX);
1817 m_impl->setDepthNormalSamplingStepY(stepY);
1911 m_impl->setProjectionErrorKernelSize(size);
1921 #elif !defined(VISP_BUILD_SHARED_LIBS)
1923 void dummy_vpMbtXmlGenericParser() { };
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
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)
double getAngleAppear() const
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)
double getKltQuality() const
double getAngleDisappear() const
void setDepthDenseSamplingStepX(unsigned int stepX)
virtual ~vpMbtXmlGenericParser()
void setProjectionErrorKernelSize(const unsigned int &size)
void setKltPyramidLevels(const unsigned int &pL)
void setKltWindowSize(const unsigned int &w)
double getKltMinDistance() const
void setKltMaxFeatures(const unsigned int &mF)
int getDepthNormalPclPlaneEstimationMethod() const
void setAngleAppear(const double &aappear)
@ PROJECTION_ERROR_PARSER
void setKltBlockSize(const unsigned int &bs)
void setKltHarrisParam(const double &hp)
unsigned int getDepthDenseSamplingStepY() const
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void parse(const std::string &filename)
double getNearClippingDistance() const
void setNearClippingDistance(const double &nclip)
void setKltQuality(const double &q)
bool hasNearClippingDistance() const
void getProjectionErrorMe(vpMe &me) const
bool hasFarClippingDistance() const
unsigned int getKltPyramidLevels() const
void setFarClippingDistance(const double &fclip)
double getKltHarrisParam() const
unsigned int getKltWindowSize() const
void setDepthNormalPclPlaneEstimationRansacThreshold(double threshold)
unsigned int getDepthDenseSamplingStepX() const
void setCameraParameters(const vpCameraParameters &cam)
double getFarClippingDistance() const
bool getFovClipping() const
double getLodMinPolygonAreaThreshold() const
void setVerbose(bool verbose)
void setDepthNormalSamplingStepY(unsigned int stepY)
vpLikelihoodThresholdType