35 #include <visp3/core/vpConfig.h>
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
43 #include <pugixml.hpp>
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 class vpMbtXmlGenericParser::Impl
54 m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
55 m_farClipping(false), m_fovClipping(false),
57 m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
61 m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
62 m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
65 m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
66 m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2), m_depthNormalSamplingStepY(2),
68 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
70 m_projectionErrorMe(), m_projectionErrorKernelSize(2),
77 void parse(
const std::string &filename)
79 pugi::xml_document doc;
80 if (!doc.load_file(filename.c_str())) {
84 bool camera_node =
false;
85 bool face_node =
false;
86 bool ecm_node =
false;
87 bool klt_node =
false;
88 bool lod_node =
false;
89 bool depth_normal_node =
false;
90 bool depth_dense_node =
false;
91 bool projection_error_node =
false;
93 pugi::xml_node root_node = doc.document_element();
94 for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
95 if (dataNode.type() == pugi::node_element) {
96 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
97 if (iter_data != m_nodeMap.end()) {
98 switch (iter_data->second) {
101 read_camera(dataNode);
129 read_sample_deprecated(dataNode);
141 read_depth_normal(dataNode);
142 depth_normal_node =
true;
148 read_depth_dense(dataNode);
149 depth_dense_node =
true;
153 case projection_error:
155 read_projection_error(dataNode);
156 projection_error_node =
true;
169 if (!projection_error_node) {
170 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)" << std::endl;
171 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 <<
"x"
172 << m_projectionErrorKernelSize*2+1 <<
" (default)" << std::endl;
176 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
177 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
178 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
179 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
183 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
184 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
188 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
189 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
190 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
194 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
195 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
196 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
197 std::cout <<
"ecm : contrast : threshold : " << m_ecm.getThreshold() <<
" (default)" << std::endl;
198 std::cout <<
"ecm : contrast : mu1 : " << m_ecm.getMu1() <<
" (default)" << std::endl;
199 std::cout <<
"ecm : contrast : mu2 : " << m_ecm.getMu2() <<
" (default)" << std::endl;
200 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
203 if (!klt_node && (m_parserType &
KLT_PARSER)) {
204 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
205 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
206 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
207 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
208 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
209 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
210 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
211 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
215 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod <<
" (default)"
217 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
218 <<
" (default)" << std::endl;
219 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
220 <<
" (default)" << std::endl;
221 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
222 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
223 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)" << std::endl;
224 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)" << std::endl;
228 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
229 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
240 void read_camera(
const pugi::xml_node &node)
242 bool u0_node =
false;
243 bool v0_node =
false;
244 bool px_node =
false;
245 bool py_node =
false;
248 double d_u0 = m_cam.get_u0();
249 double d_v0 = m_cam.get_v0();
250 double d_px = m_cam.get_px();
251 double d_py = m_cam.get_py();
253 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
254 if (dataNode.type() == pugi::node_element) {
255 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
256 if (iter_data != m_nodeMap.end()) {
257 switch (iter_data->second) {
259 d_u0 = dataNode.text().as_double();
264 d_v0 = dataNode.text().as_double();
269 d_px = dataNode.text().as_double();
274 d_py = dataNode.text().as_double();
285 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
289 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
291 std::cout <<
"camera : u0 : " << m_cam.get_u0() << std::endl;
294 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
296 std::cout <<
"camera : v0 : " << m_cam.get_v0() << std::endl;
299 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
301 std::cout <<
"camera : px : " << m_cam.get_px() << std::endl;
304 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
306 std::cout <<
"camera : py : " << m_cam.get_py() << std::endl;
315 void read_depth_normal(
const pugi::xml_node &node)
317 bool feature_estimation_method_node =
false;
318 bool PCL_plane_estimation_node =
false;
319 bool sampling_step_node =
false;
321 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
322 if (dataNode.type() == pugi::node_element) {
323 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
324 if (iter_data != m_nodeMap.end()) {
325 switch (iter_data->second) {
326 case feature_estimation_method:
327 m_depthNormalFeatureEstimationMethod =
329 feature_estimation_method_node =
true;
332 case PCL_plane_estimation:
333 read_depth_normal_PCL(dataNode);
334 PCL_plane_estimation_node =
true;
337 case depth_sampling_step:
338 read_depth_normal_sampling_step(dataNode);
339 sampling_step_node =
true;
350 if (!feature_estimation_method_node)
351 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod <<
" (default)"
354 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
356 if (!PCL_plane_estimation_node) {
357 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
358 <<
" (default)" << std::endl;
359 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
360 <<
" (default)" << std::endl;
361 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
362 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
365 if (!sampling_step_node) {
366 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)" << std::endl;
367 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)" << std::endl;
377 void read_depth_normal_PCL(
const pugi::xml_node &node)
379 bool PCL_plane_estimation_method_node =
false;
380 bool PCL_plane_estimation_ransac_max_iter_node =
false;
381 bool PCL_plane_estimation_ransac_threshold_node =
false;
383 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
384 if (dataNode.type() == pugi::node_element) {
385 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
386 if (iter_data != m_nodeMap.end()) {
387 switch (iter_data->second) {
388 case PCL_plane_estimation_method:
389 m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
390 PCL_plane_estimation_method_node =
true;
393 case PCL_plane_estimation_ransac_max_iter:
394 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
395 PCL_plane_estimation_ransac_max_iter_node =
true;
398 case PCL_plane_estimation_ransac_threshold:
399 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
400 PCL_plane_estimation_ransac_threshold_node =
true;
411 if (!PCL_plane_estimation_method_node)
412 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
413 <<
" (default)" << std::endl;
415 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
418 if (!PCL_plane_estimation_ransac_max_iter_node)
419 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
420 <<
" (default)" << std::endl;
422 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
425 if (!PCL_plane_estimation_ransac_threshold_node)
426 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
427 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
429 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
430 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
439 void read_depth_normal_sampling_step(
const pugi::xml_node &node)
441 bool sampling_step_X_node =
false;
442 bool sampling_step_Y_node =
false;
444 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
445 if (dataNode.type() == pugi::node_element) {
446 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
447 if (iter_data != m_nodeMap.end()) {
448 switch (iter_data->second) {
449 case depth_sampling_step_X:
450 m_depthNormalSamplingStepX = dataNode.text().as_uint();
451 sampling_step_X_node =
true;
454 case depth_sampling_step_Y:
455 m_depthNormalSamplingStepY = dataNode.text().as_uint();
456 sampling_step_Y_node =
true;
467 if (!sampling_step_X_node)
468 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX <<
" (default)" << std::endl;
470 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
472 if (!sampling_step_Y_node)
473 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY <<
" (default)" << std::endl;
475 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
484 void read_depth_dense(
const pugi::xml_node &node)
486 bool sampling_step_node =
false;
488 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
489 if (dataNode.type() == pugi::node_element) {
490 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
491 if (iter_data != m_nodeMap.end()) {
492 switch (iter_data->second) {
493 case depth_dense_sampling_step:
494 read_depth_dense_sampling_step(dataNode);
495 sampling_step_node =
true;
505 if (!sampling_step_node && m_verbose) {
506 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
507 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
516 void read_depth_dense_sampling_step(
const pugi::xml_node &node)
518 bool sampling_step_X_node =
false;
519 bool sampling_step_Y_node =
false;
521 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
522 if (dataNode.type() == pugi::node_element) {
523 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
524 if (iter_data != m_nodeMap.end()) {
525 switch (iter_data->second) {
526 case depth_dense_sampling_step_X:
527 m_depthDenseSamplingStepX = dataNode.text().as_uint();
528 sampling_step_X_node =
true;
531 case depth_dense_sampling_step_Y:
532 m_depthDenseSamplingStepY = dataNode.text().as_uint();
533 sampling_step_Y_node =
true;
544 if (!sampling_step_X_node)
545 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
547 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
549 if (!sampling_step_Y_node)
550 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
552 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
561 void read_ecm(
const pugi::xml_node &node)
563 bool mask_node =
false;
564 bool range_node =
false;
565 bool contrast_node =
false;
566 bool sample_node =
false;
568 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
569 if (dataNode.type() == pugi::node_element) {
570 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
571 if (iter_data != m_nodeMap.end()) {
572 switch (iter_data->second) {
574 read_ecm_mask(dataNode);
579 read_ecm_range(dataNode);
584 read_ecm_contrast(dataNode);
585 contrast_node =
true;
589 read_ecm_sample(dataNode);
602 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
603 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
607 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
610 if (!contrast_node) {
611 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
612 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
613 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
617 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
627 void read_ecm_contrast(
const pugi::xml_node &node)
629 bool edge_threshold_node =
false;
630 bool mu1_node =
false;
631 bool mu2_node =
false;
634 double d_edge_threshold = m_ecm.getThreshold();
635 double d_mu1 = m_ecm.getMu1();
636 double d_mu2 = m_ecm.getMu2();
638 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
639 if (dataNode.type() == pugi::node_element) {
640 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
641 if (iter_data != m_nodeMap.end()) {
642 switch (iter_data->second) {
644 d_edge_threshold = dataNode.text().as_double();
645 edge_threshold_node =
true;
649 d_mu1 = dataNode.text().as_double();
654 d_mu2 = dataNode.text().as_double();
667 m_ecm.setThreshold(d_edge_threshold);
670 if (!edge_threshold_node)
671 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
673 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
676 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
678 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
681 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
683 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
692 void read_ecm_mask(
const pugi::xml_node &node)
694 bool size_node =
false;
695 bool nb_mask_node =
false;
698 unsigned int d_size = m_ecm.getMaskSize();
699 unsigned int d_nb_mask = m_ecm.getMaskNumber();
701 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
702 if (dataNode.type() == pugi::node_element) {
703 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
704 if (iter_data != m_nodeMap.end()) {
705 switch (iter_data->second) {
707 d_size = dataNode.text().as_uint();
712 d_nb_mask = dataNode.text().as_uint();
723 m_ecm.setMaskSize(d_size);
728 "parameter should be different "
729 "from zero in xml file"));
730 m_ecm.setMaskNumber(d_nb_mask);
734 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
736 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
739 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
741 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
750 void read_ecm_range(
const pugi::xml_node &node)
752 bool tracking_node =
false;
755 unsigned int m_range_tracking = m_ecm.getRange();
757 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
758 if (dataNode.type() == pugi::node_element) {
759 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
760 if (iter_data != m_nodeMap.end()) {
761 switch (iter_data->second) {
763 m_range_tracking = dataNode.text().as_uint();
764 tracking_node =
true;
774 m_ecm.setRange(m_range_tracking);
778 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
780 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() << std::endl;
789 void read_ecm_sample(
const pugi::xml_node &node)
791 bool step_node =
false;
794 double d_stp = m_ecm.getSampleStep();
796 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
797 if (dataNode.type() == pugi::node_element) {
798 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
799 if (iter_data != m_nodeMap.end()) {
800 switch (iter_data->second) {
802 d_stp = dataNode.text().as_int();
813 m_ecm.setSampleStep(d_stp);
817 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
819 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
828 void read_face(
const pugi::xml_node &node)
830 bool angle_appear_node =
false;
831 bool angle_disappear_node =
false;
832 bool near_clipping_node =
false;
833 bool far_clipping_node =
false;
834 bool fov_clipping_node =
false;
835 m_hasNearClipping =
false;
836 m_hasFarClipping =
false;
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 m_angleAppear = dataNode.text().as_double();
845 angle_appear_node =
true;
848 case angle_disappear:
849 m_angleDisappear = dataNode.text().as_double();
850 angle_disappear_node =
true;
854 m_nearClipping = dataNode.text().as_double();
855 m_hasNearClipping =
true;
856 near_clipping_node =
true;
860 m_farClipping = dataNode.text().as_double();
861 m_hasFarClipping =
true;
862 far_clipping_node =
true;
866 if (dataNode.text().as_int())
867 m_fovClipping =
true;
869 m_fovClipping =
false;
870 fov_clipping_node =
true;
881 if (!angle_appear_node)
882 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
884 std::cout <<
"face : Angle Appear : " << m_angleAppear << std::endl;
886 if (!angle_disappear_node)
887 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
889 std::cout <<
"face : Angle Disappear : " << m_angleDisappear << std::endl;
891 if (near_clipping_node)
892 std::cout <<
"face : Near Clipping : " << m_nearClipping << std::endl;
894 if (far_clipping_node)
895 std::cout <<
"face : Far Clipping : " << m_farClipping << std::endl;
897 if (fov_clipping_node) {
899 std::cout <<
"face : Fov Clipping : True" << std::endl;
901 std::cout <<
"face : Fov Clipping : False" << std::endl;
911 void read_klt(
const pugi::xml_node &node)
913 bool mask_border_node =
false;
914 bool max_features_node =
false;
915 bool window_size_node =
false;
916 bool quality_node =
false;
917 bool min_distance_node =
false;
918 bool harris_node =
false;
919 bool size_block_node =
false;
920 bool pyramid_lvl_node =
false;
922 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
923 if (dataNode.type() == pugi::node_element) {
924 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
925 if (iter_data != m_nodeMap.end()) {
926 switch (iter_data->second) {
928 m_kltMaskBorder = dataNode.text().as_uint();
929 mask_border_node =
true;
933 m_kltMaxFeatures = dataNode.text().as_uint();
934 max_features_node =
true;
938 m_kltWinSize = dataNode.text().as_uint();
939 window_size_node =
true;
943 m_kltQualityValue = dataNode.text().as_double();
948 m_kltMinDist = dataNode.text().as_double();
949 min_distance_node =
true;
953 m_kltHarrisParam = dataNode.text().as_double();
958 m_kltBlockSize = dataNode.text().as_uint();
959 size_block_node =
true;
963 m_kltPyramidLevels = dataNode.text().as_uint();
964 pyramid_lvl_node =
true;
975 if (!mask_border_node)
976 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
978 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder << std::endl;
980 if (!max_features_node)
981 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
983 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures << std::endl;
985 if (!window_size_node)
986 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
988 std::cout <<
"klt : Windows Size : " << m_kltWinSize << std::endl;
991 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
993 std::cout <<
"klt : Quality : " << m_kltQualityValue << std::endl;
995 if (!min_distance_node)
996 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
998 std::cout <<
"klt : Min Distance : " << m_kltMinDist << std::endl;
1001 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
1003 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1005 if (!size_block_node)
1006 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
1008 std::cout <<
"klt : Block Size : " << m_kltBlockSize << std::endl;
1010 if (!pyramid_lvl_node)
1011 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
1013 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1017 void read_lod(
const pugi::xml_node &node)
1019 bool use_lod_node =
false;
1020 bool min_line_length_threshold_node =
false;
1021 bool min_polygon_area_threshold_node =
false;
1023 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1024 if (dataNode.type() == pugi::node_element) {
1025 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1026 if (iter_data != m_nodeMap.end()) {
1027 switch (iter_data->second) {
1029 m_useLod = (dataNode.text().as_int() != 0);
1030 use_lod_node =
true;
1033 case min_line_length_threshold:
1034 m_minLineLengthThreshold = dataNode.text().as_double();
1035 min_line_length_threshold_node =
true;
1038 case min_polygon_area_threshold:
1039 m_minPolygonAreaThreshold = dataNode.text().as_double();
1040 min_polygon_area_threshold_node =
true;
1052 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
1054 std::cout <<
"lod : use lod : " << m_useLod << std::endl;
1056 if (!min_line_length_threshold_node)
1057 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
1059 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1061 if (!min_polygon_area_threshold_node)
1062 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
1064 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1068 void read_projection_error(
const pugi::xml_node &node)
1070 bool step_node =
false;
1071 bool kernel_size_node =
false;
1074 double d_stp = m_projectionErrorMe.getSampleStep();
1075 std::string kernel_size_str;
1077 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1078 if (dataNode.type() == pugi::node_element) {
1079 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1080 if (iter_data != m_nodeMap.end()) {
1081 switch (iter_data->second) {
1082 case projection_error_sample_step:
1083 d_stp = dataNode.text().as_int();
1087 case projection_error_kernel_size:
1088 kernel_size_str = dataNode.text().as_string();
1089 kernel_size_node =
true;
1099 m_projectionErrorMe.setSampleStep(d_stp);
1101 if (kernel_size_str ==
"3x3") {
1102 m_projectionErrorKernelSize = 1;
1103 }
else if (kernel_size_str ==
"5x5") {
1104 m_projectionErrorKernelSize = 2;
1105 }
else if (kernel_size_str ==
"7x7") {
1106 m_projectionErrorKernelSize = 3;
1107 }
else if (kernel_size_str ==
"9x9") {
1108 m_projectionErrorKernelSize = 4;
1109 }
else if (kernel_size_str ==
"11x11") {
1110 m_projectionErrorKernelSize = 5;
1111 }
else if (kernel_size_str ==
"13x13") {
1112 m_projectionErrorKernelSize = 6;
1113 }
else if (kernel_size_str ==
"15x15") {
1114 m_projectionErrorKernelSize = 7;
1116 std::cerr <<
"Unsupported kernel size." << std::endl;
1121 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)" << std::endl;
1123 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1125 if (!kernel_size_node)
1126 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 <<
"x"
1127 << m_projectionErrorKernelSize*2+1 <<
" (default)" << std::endl;
1129 std::cout <<
"projection_error : kernel_size : " << kernel_size_str << std::endl;
1138 void read_sample_deprecated(
const pugi::xml_node &node)
1140 bool step_node =
false;
1144 double d_stp = m_ecm.getSampleStep();
1146 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1147 if (dataNode.type() == pugi::node_element) {
1148 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1149 if (iter_data != m_nodeMap.end()) {
1150 switch (iter_data->second) {
1152 d_stp = dataNode.text().as_int();
1163 m_ecm.setSampleStep(d_stp);
1167 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
1169 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1171 std::cout <<
" WARNING : This node (sample) is deprecated." << std::endl;
1172 std::cout <<
" It should be moved in the ecm node (ecm : sample)." << std::endl;
1181 void getEdgeMe(
vpMe &moving_edge)
const { moving_edge = m_ecm; }
1188 return m_depthNormalFeatureEstimationMethod;
1193 return m_depthNormalPclPlaneEstimationRansacMaxIter;
1197 return m_depthNormalPclPlaneEstimationRansacThreshold;
1226 void setAngleAppear(
const double &aappear) { m_angleAppear = aappear; }
1227 void setAngleDisappear(
const double &adisappear) { m_angleDisappear = adisappear; }
1235 m_depthNormalFeatureEstimationMethod = method;
1239 m_depthNormalPclPlaneEstimationMethod = method;
1243 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1247 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1252 void setEdgeMe(
const vpMe &moving_edge) { m_ecm = moving_edge; }
1262 void setKltQuality(
const double &q) { m_kltQualityValue = q; }
1270 void setVerbose(
bool verbose) { m_verbose = verbose; }
1278 double m_angleAppear;
1280 double m_angleDisappear;
1282 bool m_hasNearClipping;
1284 double m_nearClipping;
1286 bool m_hasFarClipping;
1288 double m_farClipping;
1295 double m_minLineLengthThreshold;
1297 double m_minPolygonAreaThreshold;
1303 unsigned int m_kltMaskBorder;
1305 unsigned int m_kltMaxFeatures;
1307 unsigned int m_kltWinSize;
1309 double m_kltQualityValue;
1311 double m_kltMinDist;
1313 double m_kltHarrisParam;
1315 unsigned int m_kltBlockSize;
1317 unsigned int m_kltPyramidLevels;
1322 int m_depthNormalPclPlaneEstimationMethod;
1324 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1326 double m_depthNormalPclPlaneEstimationRansacThreshold;
1328 unsigned int m_depthNormalSamplingStepX;
1330 unsigned int m_depthNormalSamplingStepY;
1333 unsigned int m_depthDenseSamplingStepX;
1335 unsigned int m_depthDenseSamplingStepY;
1338 vpMe m_projectionErrorMe;
1340 unsigned int m_projectionErrorKernelSize;
1341 std::map<std::string, int> m_nodeMap;
1345 enum vpDataToParseMb {
1365 min_line_length_threshold,
1366 min_polygon_area_threshold,
1392 feature_estimation_method,
1393 PCL_plane_estimation,
1394 PCL_plane_estimation_method,
1395 PCL_plane_estimation_ransac_max_iter,
1396 PCL_plane_estimation_ransac_threshold,
1397 depth_sampling_step,
1398 depth_sampling_step_X,
1399 depth_sampling_step_Y,
1402 depth_dense_sampling_step,
1403 depth_dense_sampling_step_X,
1404 depth_dense_sampling_step_Y,
1407 projection_error_sample_step,
1408 projection_error_kernel_size
1417 m_nodeMap[
"conf"] = conf;
1419 m_nodeMap[
"face"] = face;
1420 m_nodeMap[
"angle_appear"] = angle_appear;
1421 m_nodeMap[
"angle_disappear"] = angle_disappear;
1422 m_nodeMap[
"near_clipping"] = near_clipping;
1423 m_nodeMap[
"far_clipping"] = far_clipping;
1424 m_nodeMap[
"fov_clipping"] = fov_clipping;
1426 m_nodeMap[
"camera"] = camera;
1427 m_nodeMap[
"height"] = height;
1428 m_nodeMap[
"width"] = width;
1429 m_nodeMap[
"u0"] = u0;
1430 m_nodeMap[
"v0"] = v0;
1431 m_nodeMap[
"px"] = px;
1432 m_nodeMap[
"py"] = py;
1434 m_nodeMap[
"lod"] = lod;
1435 m_nodeMap[
"use_lod"] = use_lod;
1436 m_nodeMap[
"min_line_length_threshold"] = min_line_length_threshold;
1437 m_nodeMap[
"min_polygon_area_threshold"] = min_polygon_area_threshold;
1439 m_nodeMap[
"ecm"] = ecm;
1440 m_nodeMap[
"mask"] = mask;
1441 m_nodeMap[
"size"] = size;
1442 m_nodeMap[
"nb_mask"] = nb_mask;
1443 m_nodeMap[
"range"] = range;
1444 m_nodeMap[
"tracking"] = tracking;
1445 m_nodeMap[
"contrast"] = contrast;
1446 m_nodeMap[
"edge_threshold"] = edge_threshold;
1447 m_nodeMap[
"mu1"] = mu1;
1448 m_nodeMap[
"mu2"] = mu2;
1449 m_nodeMap[
"sample"] = sample;
1450 m_nodeMap[
"step"] = step;
1452 m_nodeMap[
"klt"] = klt;
1453 m_nodeMap[
"mask_border"] = mask_border;
1454 m_nodeMap[
"max_features"] = max_features;
1455 m_nodeMap[
"window_size"] = window_size;
1456 m_nodeMap[
"quality"] = quality;
1457 m_nodeMap[
"min_distance"] = min_distance;
1458 m_nodeMap[
"harris"] = harris;
1459 m_nodeMap[
"size_block"] = size_block;
1460 m_nodeMap[
"pyramid_lvl"] = pyramid_lvl;
1462 m_nodeMap[
"depth_normal"] = depth_normal;
1463 m_nodeMap[
"feature_estimation_method"] = feature_estimation_method;
1464 m_nodeMap[
"PCL_plane_estimation"] = PCL_plane_estimation;
1465 m_nodeMap[
"method"] = PCL_plane_estimation_method;
1466 m_nodeMap[
"ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1467 m_nodeMap[
"ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1468 m_nodeMap[
"sampling_step"] = depth_sampling_step;
1469 m_nodeMap[
"step_X"] = depth_sampling_step_X;
1470 m_nodeMap[
"step_Y"] = depth_sampling_step_Y;
1472 m_nodeMap[
"depth_dense"] = depth_dense;
1473 m_nodeMap[
"sampling_step"] = depth_dense_sampling_step;
1474 m_nodeMap[
"step_X"] = depth_dense_sampling_step_X;
1475 m_nodeMap[
"step_Y"] = depth_dense_sampling_step_Y;
1477 m_nodeMap[
"projection_error"] = projection_error;
1478 m_nodeMap[
"sample_step"] = projection_error_sample_step;
1479 m_nodeMap[
"kernel_size"] = projection_error_kernel_size;
1490 if (std::setlocale(LC_ALL,
"C") == NULL) {
1491 std::cerr <<
"Cannot set locale to C" << std::endl;
1507 m_impl->parse(filename);
1515 return m_impl->getAngleAppear();
1523 return m_impl->getAngleDisappear();
1528 m_impl->getCameraParameters(cam);
1536 m_impl->getEdgeMe(ecm);
1544 return m_impl->getDepthDenseSamplingStepX();
1552 return m_impl->getDepthDenseSamplingStepY();
1560 return m_impl->getDepthNormalFeatureEstimationMethod();
1568 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1576 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1584 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1592 return m_impl->getDepthNormalSamplingStepX();
1600 return m_impl->getDepthNormalSamplingStepY();
1608 return m_impl->getFarClippingDistance();
1616 return m_impl->getFovClipping();
1624 return m_impl->getKltBlockSize();
1632 return m_impl->getKltHarrisParam();
1640 return m_impl->getKltMaskBorder();
1648 return m_impl->getKltMaxFeatures();
1656 return m_impl->getKltMinDistance();
1664 return m_impl->getKltPyramidLevels();
1672 return m_impl->getKltQuality();
1680 return m_impl->getKltWindowSize();
1688 return m_impl->getLodState();
1696 return m_impl->getLodMinLineLengthThreshold();
1704 return m_impl->getLodMinPolygonAreaThreshold();
1712 return m_impl->getNearClippingDistance();
1720 m_impl->getProjectionErrorMe(me);
1725 return m_impl->getProjectionErrorKernelSize();
1735 return m_impl->hasFarClippingDistance();
1745 return m_impl->hasNearClippingDistance();
1755 m_impl->setAngleAppear(aappear);
1765 m_impl->setAngleDisappear(adisappear);
1775 m_impl->setCameraParameters(cam);
1785 m_impl->setDepthDenseSamplingStepX(stepX);
1795 m_impl->setDepthDenseSamplingStepY(stepY);
1805 m_impl->setDepthNormalFeatureEstimationMethod(method);
1815 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1825 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1835 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1845 m_impl->setDepthNormalSamplingStepX(stepX);
1855 m_impl->setDepthNormalSamplingStepY(stepY);
1865 m_impl->setEdgeMe(ecm);
1875 m_impl->setFarClippingDistance(fclip);
1885 m_impl->setKltBlockSize(bs);
1895 m_impl->setKltHarrisParam(hp);
1905 m_impl->setKltMaskBorder(mb);
1915 m_impl->setKltMaxFeatures(mF);
1925 m_impl->setKltMinDistance(mD);
1935 m_impl->setKltPyramidLevels(pL);
1945 m_impl->setKltQuality(q);
1955 m_impl->setKltWindowSize(w);
1965 m_impl->setNearClippingDistance(nclip);
1975 m_impl->setProjectionErrorMe(me);
1985 m_impl->setProjectionErrorKernelSize(size);
1995 m_impl->setVerbose(verbose);
Generic class defining intrinsic camera parameters.
error that can be emited 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)