35 #include <visp3/core/vpConfig.h>
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
43 #if defined(VISP_HAVE_PUGIXML)
44 #include <pugixml.hpp>
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 class vpMbtXmlGenericParser::Impl
56 m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
57 m_farClipping(false), m_fovClipping(false),
59 m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
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),
67 m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
68 m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2),
69 m_depthNormalSamplingStepY(2),
71 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
73 m_projectionErrorMe(), m_projectionErrorKernelSize(2),
74 m_nodeMap(), m_verbose(true)
78 if (m_call_setlocale) {
83 if (std::setlocale(LC_ALL,
"C") ==
nullptr) {
84 std::cerr <<
"Cannot set locale to C" << std::endl;
86 m_call_setlocale =
false;
91 void parse(
const std::string &filename)
93 pugi::xml_document doc;
94 if (!doc.load_file(filename.c_str())) {
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;
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) {
115 read_camera(dataNode);
143 read_sample_deprecated(dataNode);
155 read_depth_normal(dataNode);
156 depth_normal_node =
true;
162 read_depth_dense(dataNode);
163 depth_dense_node =
true;
167 case projection_error:
169 read_projection_error(dataNode);
170 projection_error_node =
true;
183 if (!projection_error_node) {
184 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
186 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
187 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
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;
199 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
200 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
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;
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;
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;
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)"
242 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
247 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)"
249 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)"
261 void read_camera(
const pugi::xml_node &node)
263 bool u0_node =
false;
264 bool v0_node =
false;
265 bool px_node =
false;
266 bool py_node =
false;
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();
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) {
280 d_u0 = dataNode.text().as_double();
285 d_v0 = dataNode.text().as_double();
290 d_px = dataNode.text().as_double();
295 d_py = dataNode.text().as_double();
306 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
310 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
312 std::cout <<
"camera : u0 : " << m_cam.get_u0() << std::endl;
315 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
317 std::cout <<
"camera : v0 : " << m_cam.get_v0() << std::endl;
320 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
322 std::cout <<
"camera : px : " << m_cam.get_px() << std::endl;
325 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
327 std::cout <<
"camera : py : " << m_cam.get_py() << std::endl;
336 void read_depth_normal(
const pugi::xml_node &node)
338 bool feature_estimation_method_node =
false;
339 bool PCL_plane_estimation_node =
false;
340 bool sampling_step_node =
false;
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 =
350 feature_estimation_method_node =
true;
353 case PCL_plane_estimation:
354 read_depth_normal_PCL(dataNode);
355 PCL_plane_estimation_node =
true;
358 case depth_sampling_step:
359 read_depth_normal_sampling_step(dataNode);
360 sampling_step_node =
true;
371 if (!feature_estimation_method_node)
372 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
373 <<
" (default)" << std::endl;
375 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
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;
386 if (!sampling_step_node) {
387 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
389 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
400 void read_depth_normal_PCL(
const pugi::xml_node &node)
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;
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;
416 case PCL_plane_estimation_ransac_max_iter:
417 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
418 PCL_plane_estimation_ransac_max_iter_node =
true;
421 case PCL_plane_estimation_ransac_threshold:
422 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
423 PCL_plane_estimation_ransac_threshold_node =
true;
434 if (!PCL_plane_estimation_method_node)
435 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
436 <<
" (default)" << std::endl;
438 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
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;
445 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
448 if (!PCL_plane_estimation_ransac_threshold_node)
449 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
450 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
452 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
453 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
462 void read_depth_normal_sampling_step(
const pugi::xml_node &node)
464 bool sampling_step_X_node =
false;
465 bool sampling_step_Y_node =
false;
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;
477 case depth_sampling_step_Y:
478 m_depthNormalSamplingStepY = dataNode.text().as_uint();
479 sampling_step_Y_node =
true;
490 if (!sampling_step_X_node)
491 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX <<
" (default)"
494 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
496 if (!sampling_step_Y_node)
497 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY <<
" (default)"
500 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
509 void read_depth_dense(
const pugi::xml_node &node)
511 bool sampling_step_node =
false;
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;
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;
541 void read_depth_dense_sampling_step(
const pugi::xml_node &node)
543 bool sampling_step_X_node =
false;
544 bool sampling_step_Y_node =
false;
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;
556 case depth_dense_sampling_step_Y:
557 m_depthDenseSamplingStepY = dataNode.text().as_uint();
558 sampling_step_Y_node =
true;
569 if (!sampling_step_X_node)
570 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX <<
" (default)"
573 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
575 if (!sampling_step_Y_node)
576 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY <<
" (default)"
579 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
588 void read_ecm(
const pugi::xml_node &node)
590 bool mask_node =
false;
591 bool range_node =
false;
592 bool contrast_node =
false;
593 bool sample_node =
false;
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) {
601 read_ecm_mask(dataNode);
606 read_ecm_range(dataNode);
611 read_ecm_contrast(dataNode);
612 contrast_node =
true;
616 read_ecm_sample(dataNode);
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;
634 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
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;
645 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
655 void read_ecm_contrast(
const pugi::xml_node &node)
657 bool edge_threshold_type_node =
false;
658 bool edge_threshold_node =
false;
659 bool mu1_node =
false;
660 bool mu2_node =
false;
664 double d_edge_threshold = m_ecm.getThreshold();
665 double d_mu1 = m_ecm.getMu1();
666 double d_mu2 = m_ecm.getMu2();
668 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
669 if (dataNode.type() == pugi::node_element) {
670 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
671 if (iter_data != m_nodeMap.end()) {
672 switch (iter_data->second) {
673 case edge_threshold_type:
675 edge_threshold_type_node =
true;
679 d_edge_threshold = dataNode.text().as_int();
680 edge_threshold_node =
true;
684 d_mu1 = dataNode.text().as_double();
689 d_mu2 = dataNode.text().as_double();
702 m_ecm.setLikelihoodThresholdType(d_edge_threshold_type);
703 m_ecm.setThreshold(d_edge_threshold);
706 if (!edge_threshold_type_node)
707 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
709 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << std::endl;
711 if (!edge_threshold_node)
712 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
714 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() << std::endl;
717 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
719 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() << std::endl;
722 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
724 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() << std::endl;
733 void read_ecm_mask(
const pugi::xml_node &node)
735 bool size_node =
false;
736 bool nb_mask_node =
false;
739 unsigned int d_size = m_ecm.getMaskSize();
740 unsigned int d_nb_mask = m_ecm.getMaskNumber();
742 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
743 if (dataNode.type() == pugi::node_element) {
744 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
745 if (iter_data != m_nodeMap.end()) {
746 switch (iter_data->second) {
748 d_size = dataNode.text().as_uint();
753 d_nb_mask = dataNode.text().as_uint();
764 m_ecm.setMaskSize(d_size);
769 "parameter should be different "
770 "from zero in xml file"));
771 m_ecm.setMaskNumber(d_nb_mask);
775 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
777 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() << std::endl;
780 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
782 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
791 void read_ecm_range(
const pugi::xml_node &node)
793 bool tracking_node =
false;
796 unsigned int m_range_tracking = m_ecm.getRange();
798 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
799 if (dataNode.type() == pugi::node_element) {
800 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
801 if (iter_data != m_nodeMap.end()) {
802 switch (iter_data->second) {
804 m_range_tracking = dataNode.text().as_uint();
805 tracking_node =
true;
815 m_ecm.setRange(m_range_tracking);
819 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
821 std::cout <<
"me : range : tracking : " << m_ecm.getRange() << std::endl;
830 void read_ecm_sample(
const pugi::xml_node &node)
832 bool step_node =
false;
835 double d_stp = m_ecm.getSampleStep();
837 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
838 if (dataNode.type() == pugi::node_element) {
839 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
840 if (iter_data != m_nodeMap.end()) {
841 switch (iter_data->second) {
843 d_stp = dataNode.text().as_int();
854 m_ecm.setSampleStep(d_stp);
858 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
860 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
869 void read_face(
const pugi::xml_node &node)
871 bool angle_appear_node =
false;
872 bool angle_disappear_node =
false;
873 bool near_clipping_node =
false;
874 bool far_clipping_node =
false;
875 bool fov_clipping_node =
false;
876 m_hasNearClipping =
false;
877 m_hasFarClipping =
false;
879 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
880 if (dataNode.type() == pugi::node_element) {
881 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
882 if (iter_data != m_nodeMap.end()) {
883 switch (iter_data->second) {
885 m_angleAppear = dataNode.text().as_double();
886 angle_appear_node =
true;
889 case angle_disappear:
890 m_angleDisappear = dataNode.text().as_double();
891 angle_disappear_node =
true;
895 m_nearClipping = dataNode.text().as_double();
896 m_hasNearClipping =
true;
897 near_clipping_node =
true;
901 m_farClipping = dataNode.text().as_double();
902 m_hasFarClipping =
true;
903 far_clipping_node =
true;
907 if (dataNode.text().as_int())
908 m_fovClipping =
true;
910 m_fovClipping =
false;
911 fov_clipping_node =
true;
922 if (!angle_appear_node)
923 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
925 std::cout <<
"face : Angle Appear : " << m_angleAppear << std::endl;
927 if (!angle_disappear_node)
928 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
930 std::cout <<
"face : Angle Disappear : " << m_angleDisappear << std::endl;
932 if (near_clipping_node)
933 std::cout <<
"face : Near Clipping : " << m_nearClipping << std::endl;
935 if (far_clipping_node)
936 std::cout <<
"face : Far Clipping : " << m_farClipping << std::endl;
938 if (fov_clipping_node) {
940 std::cout <<
"face : Fov Clipping : True" << std::endl;
942 std::cout <<
"face : Fov Clipping : False" << std::endl;
952 void read_klt(
const pugi::xml_node &node)
954 bool mask_border_node =
false;
955 bool max_features_node =
false;
956 bool window_size_node =
false;
957 bool quality_node =
false;
958 bool min_distance_node =
false;
959 bool harris_node =
false;
960 bool size_block_node =
false;
961 bool pyramid_lvl_node =
false;
963 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
964 if (dataNode.type() == pugi::node_element) {
965 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
966 if (iter_data != m_nodeMap.end()) {
967 switch (iter_data->second) {
969 m_kltMaskBorder = dataNode.text().as_uint();
970 mask_border_node =
true;
974 m_kltMaxFeatures = dataNode.text().as_uint();
975 max_features_node =
true;
979 m_kltWinSize = dataNode.text().as_uint();
980 window_size_node =
true;
984 m_kltQualityValue = dataNode.text().as_double();
989 m_kltMinDist = dataNode.text().as_double();
990 min_distance_node =
true;
994 m_kltHarrisParam = dataNode.text().as_double();
999 m_kltBlockSize = dataNode.text().as_uint();
1000 size_block_node =
true;
1004 m_kltPyramidLevels = dataNode.text().as_uint();
1005 pyramid_lvl_node =
true;
1016 if (!mask_border_node)
1017 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
1019 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder << std::endl;
1021 if (!max_features_node)
1022 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
1024 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures << std::endl;
1026 if (!window_size_node)
1027 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
1029 std::cout <<
"klt : Windows Size : " << m_kltWinSize << std::endl;
1032 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
1034 std::cout <<
"klt : Quality : " << m_kltQualityValue << std::endl;
1036 if (!min_distance_node)
1037 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
1039 std::cout <<
"klt : Min Distance : " << m_kltMinDist << std::endl;
1042 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
1044 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1046 if (!size_block_node)
1047 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
1049 std::cout <<
"klt : Block Size : " << m_kltBlockSize << std::endl;
1051 if (!pyramid_lvl_node)
1052 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
1054 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1058 void read_lod(
const pugi::xml_node &node)
1060 bool use_lod_node =
false;
1061 bool min_line_length_threshold_node =
false;
1062 bool min_polygon_area_threshold_node =
false;
1064 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1065 if (dataNode.type() == pugi::node_element) {
1066 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1067 if (iter_data != m_nodeMap.end()) {
1068 switch (iter_data->second) {
1070 m_useLod = (dataNode.text().as_int() != 0);
1071 use_lod_node =
true;
1074 case min_line_length_threshold:
1075 m_minLineLengthThreshold = dataNode.text().as_double();
1076 min_line_length_threshold_node =
true;
1079 case min_polygon_area_threshold:
1080 m_minPolygonAreaThreshold = dataNode.text().as_double();
1081 min_polygon_area_threshold_node =
true;
1093 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
1095 std::cout <<
"lod : use lod : " << m_useLod << std::endl;
1097 if (!min_line_length_threshold_node)
1098 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
1100 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1102 if (!min_polygon_area_threshold_node)
1103 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
1105 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1109 void read_projection_error(
const pugi::xml_node &node)
1111 bool step_node =
false;
1112 bool kernel_size_node =
false;
1115 double d_stp = m_projectionErrorMe.getSampleStep();
1116 std::string kernel_size_str;
1118 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1119 if (dataNode.type() == pugi::node_element) {
1120 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1121 if (iter_data != m_nodeMap.end()) {
1122 switch (iter_data->second) {
1123 case projection_error_sample_step:
1124 d_stp = dataNode.text().as_int();
1128 case projection_error_kernel_size:
1129 kernel_size_str = dataNode.text().as_string();
1130 kernel_size_node =
true;
1140 m_projectionErrorMe.setSampleStep(d_stp);
1142 if (kernel_size_str ==
"3x3") {
1143 m_projectionErrorKernelSize = 1;
1145 else if (kernel_size_str ==
"5x5") {
1146 m_projectionErrorKernelSize = 2;
1148 else if (kernel_size_str ==
"7x7") {
1149 m_projectionErrorKernelSize = 3;
1151 else if (kernel_size_str ==
"9x9") {
1152 m_projectionErrorKernelSize = 4;
1154 else if (kernel_size_str ==
"11x11") {
1155 m_projectionErrorKernelSize = 5;
1157 else if (kernel_size_str ==
"13x13") {
1158 m_projectionErrorKernelSize = 6;
1160 else if (kernel_size_str ==
"15x15") {
1161 m_projectionErrorKernelSize = 7;
1164 std::cerr <<
"Unsupported kernel size." << std::endl;
1169 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
1172 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1174 if (!kernel_size_node)
1175 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
1176 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
1178 std::cout <<
"projection_error : kernel_size : " << kernel_size_str << std::endl;
1187 void read_sample_deprecated(
const pugi::xml_node &node)
1189 bool step_node =
false;
1193 double d_stp = m_ecm.getSampleStep();
1195 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1196 if (dataNode.type() == pugi::node_element) {
1197 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1198 if (iter_data != m_nodeMap.end()) {
1199 switch (iter_data->second) {
1201 d_stp = dataNode.text().as_int();
1212 m_ecm.setSampleStep(d_stp);
1216 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
1218 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1220 std::cout <<
" WARNING : This node (sample) is deprecated." << std::endl;
1221 std::cout <<
" It should be moved in the ecm node (me : sample)." << std::endl;
1230 void getEdgeMe(
vpMe &moving_edge)
const { moving_edge = m_ecm; }
1237 return m_depthNormalFeatureEstimationMethod;
1243 return m_depthNormalPclPlaneEstimationRansacThreshold;
1272 void setAngleAppear(
const double &aappear) { m_angleAppear = aappear; }
1273 void setAngleDisappear(
const double &adisappear) { m_angleDisappear = adisappear; }
1281 m_depthNormalFeatureEstimationMethod = method;
1286 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1290 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1295 void setEdgeMe(
const vpMe &moving_edge) { m_ecm = moving_edge; }
1305 void setKltQuality(
const double &q) { m_kltQualityValue = q; }
1313 void setVerbose(
bool verbose) { m_verbose = verbose; }
1321 double m_angleAppear;
1323 double m_angleDisappear;
1325 bool m_hasNearClipping;
1327 double m_nearClipping;
1329 bool m_hasFarClipping;
1331 double m_farClipping;
1338 double m_minLineLengthThreshold;
1340 double m_minPolygonAreaThreshold;
1346 unsigned int m_kltMaskBorder;
1348 unsigned int m_kltMaxFeatures;
1350 unsigned int m_kltWinSize;
1352 double m_kltQualityValue;
1354 double m_kltMinDist;
1356 double m_kltHarrisParam;
1358 unsigned int m_kltBlockSize;
1360 unsigned int m_kltPyramidLevels;
1365 int m_depthNormalPclPlaneEstimationMethod;
1367 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1369 double m_depthNormalPclPlaneEstimationRansacThreshold;
1371 unsigned int m_depthNormalSamplingStepX;
1373 unsigned int m_depthNormalSamplingStepY;
1376 unsigned int m_depthDenseSamplingStepX;
1378 unsigned int m_depthDenseSamplingStepY;
1381 vpMe m_projectionErrorMe;
1383 unsigned int m_projectionErrorKernelSize;
1384 std::map<std::string, int> m_nodeMap;
1388 enum vpDataToParseMb
1409 min_line_length_threshold,
1410 min_polygon_area_threshold,
1420 edge_threshold_type,
1437 feature_estimation_method,
1438 PCL_plane_estimation,
1439 PCL_plane_estimation_method,
1440 PCL_plane_estimation_ransac_max_iter,
1441 PCL_plane_estimation_ransac_threshold,
1442 depth_sampling_step,
1443 depth_sampling_step_X,
1444 depth_sampling_step_Y,
1447 depth_dense_sampling_step,
1448 depth_dense_sampling_step_X,
1449 depth_dense_sampling_step_Y,
1452 projection_error_sample_step,
1453 projection_error_kernel_size
1462 m_nodeMap[
"conf"] = conf;
1464 m_nodeMap[
"face"] = face;
1465 m_nodeMap[
"angle_appear"] = angle_appear;
1466 m_nodeMap[
"angle_disappear"] = angle_disappear;
1467 m_nodeMap[
"near_clipping"] = near_clipping;
1468 m_nodeMap[
"far_clipping"] = far_clipping;
1469 m_nodeMap[
"fov_clipping"] = fov_clipping;
1471 m_nodeMap[
"camera"] = camera;
1472 m_nodeMap[
"height"] = height;
1473 m_nodeMap[
"width"] = width;
1474 m_nodeMap[
"u0"] = u0;
1475 m_nodeMap[
"v0"] = v0;
1476 m_nodeMap[
"px"] = px;
1477 m_nodeMap[
"py"] = py;
1479 m_nodeMap[
"lod"] = lod;
1480 m_nodeMap[
"use_lod"] = use_lod;
1481 m_nodeMap[
"min_line_length_threshold"] = min_line_length_threshold;
1482 m_nodeMap[
"min_polygon_area_threshold"] = min_polygon_area_threshold;
1484 m_nodeMap[
"ecm"] = ecm;
1485 m_nodeMap[
"mask"] = mask;
1486 m_nodeMap[
"size"] = size;
1487 m_nodeMap[
"nb_mask"] = nb_mask;
1488 m_nodeMap[
"range"] = range;
1489 m_nodeMap[
"tracking"] = tracking;
1490 m_nodeMap[
"contrast"] = contrast;
1491 m_nodeMap[
"edge_threshold_type"] = edge_threshold_type;
1492 m_nodeMap[
"edge_threshold"] = edge_threshold;
1493 m_nodeMap[
"mu1"] = mu1;
1494 m_nodeMap[
"mu2"] = mu2;
1495 m_nodeMap[
"sample"] = sample;
1496 m_nodeMap[
"step"] = step;
1498 m_nodeMap[
"klt"] = klt;
1499 m_nodeMap[
"mask_border"] = mask_border;
1500 m_nodeMap[
"max_features"] = max_features;
1501 m_nodeMap[
"window_size"] = window_size;
1502 m_nodeMap[
"quality"] = quality;
1503 m_nodeMap[
"min_distance"] = min_distance;
1504 m_nodeMap[
"harris"] = harris;
1505 m_nodeMap[
"size_block"] = size_block;
1506 m_nodeMap[
"pyramid_lvl"] = pyramid_lvl;
1508 m_nodeMap[
"depth_normal"] = depth_normal;
1509 m_nodeMap[
"feature_estimation_method"] = feature_estimation_method;
1510 m_nodeMap[
"PCL_plane_estimation"] = PCL_plane_estimation;
1511 m_nodeMap[
"method"] = PCL_plane_estimation_method;
1512 m_nodeMap[
"ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1513 m_nodeMap[
"ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1514 m_nodeMap[
"sampling_step"] = depth_sampling_step;
1515 m_nodeMap[
"step_X"] = depth_sampling_step_X;
1516 m_nodeMap[
"step_Y"] = depth_sampling_step_Y;
1518 m_nodeMap[
"depth_dense"] = depth_dense;
1519 m_nodeMap[
"sampling_step"] = depth_dense_sampling_step;
1520 m_nodeMap[
"step_X"] = depth_dense_sampling_step_X;
1521 m_nodeMap[
"step_Y"] = depth_dense_sampling_step_Y;
1523 m_nodeMap[
"projection_error"] = projection_error;
1524 m_nodeMap[
"sample_step"] = projection_error_sample_step;
1525 m_nodeMap[
"kernel_size"] = projection_error_kernel_size;
1529 static bool m_call_setlocale;
1532 bool vpMbtXmlGenericParser::Impl::m_call_setlocale =
true;
1580 return m_impl->getDepthNormalFeatureEstimationMethod();
1588 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1596 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1604 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1612 return m_impl->getDepthNormalSamplingStepX();
1620 return m_impl->getDepthNormalSamplingStepY();
1700 return m_impl->getProjectionErrorKernelSize();
1745 m_impl->setDepthDenseSamplingStepX(stepX);
1755 m_impl->setDepthDenseSamplingStepY(stepY);
1766 m_impl->setDepthNormalFeatureEstimationMethod(method);
1776 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1786 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1796 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1806 m_impl->setDepthNormalSamplingStepX(stepX);
1816 m_impl->setDepthNormalSamplingStepY(stepY);
1910 m_impl->setProjectionErrorKernelSize(size);
1920 #elif !defined(VISP_BUILD_SHARED_LIBS)
1922 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
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)
vpMbtXmlGenericParser(int type=EDGE_PARSER)
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
void init(vpImage< unsigned char > &Iinput, vpImage< unsigned char > &IcannyVisp, vpImage< unsigned char > *p_dIx, vpImage< unsigned char > *p_dIy, vpImage< unsigned char > *p_IcannyimgFilter)
Initialize the different displays.