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),
67 m_depthNormalSamplingStepY(2),
69 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
71 m_projectionErrorMe(), m_projectionErrorKernelSize(2),
72 m_nodeMap(), m_verbose(true)
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)"
172 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
173 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
177 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
178 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
179 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
180 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
184 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
185 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
189 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
190 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
191 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
195 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
196 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
197 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
198 std::cout <<
"ecm : contrast : threshold : " << m_ecm.getThreshold() <<
" (default)" << std::endl;
199 std::cout <<
"ecm : contrast : mu1 : " << m_ecm.getMu1() <<
" (default)" << std::endl;
200 std::cout <<
"ecm : contrast : mu2 : " << m_ecm.getMu2() <<
" (default)" << std::endl;
201 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
204 if (!klt_node && (m_parserType &
KLT_PARSER)) {
205 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
206 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
207 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
208 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
209 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
210 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
211 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
212 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
216 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
217 <<
" (default)" << std::endl;
218 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
219 <<
" (default)" << std::endl;
220 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : "
221 << m_depthNormalPclPlaneEstimationRansacMaxIter <<
" (default)" << std::endl;
222 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
223 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
224 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
226 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
231 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)"
233 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)"
245 void read_camera(
const pugi::xml_node &node)
247 bool u0_node =
false;
248 bool v0_node =
false;
249 bool px_node =
false;
250 bool py_node =
false;
253 double d_u0 = m_cam.get_u0();
254 double d_v0 = m_cam.get_v0();
255 double d_px = m_cam.get_px();
256 double d_py = m_cam.get_py();
258 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
259 if (dataNode.type() == pugi::node_element) {
260 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
261 if (iter_data != m_nodeMap.end()) {
262 switch (iter_data->second) {
264 d_u0 = dataNode.text().as_double();
269 d_v0 = dataNode.text().as_double();
274 d_px = dataNode.text().as_double();
279 d_py = dataNode.text().as_double();
290 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
294 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
296 std::cout <<
"camera : u0 : " << m_cam.get_u0() << std::endl;
299 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
301 std::cout <<
"camera : v0 : " << m_cam.get_v0() << std::endl;
304 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
306 std::cout <<
"camera : px : " << m_cam.get_px() << std::endl;
309 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
311 std::cout <<
"camera : py : " << m_cam.get_py() << std::endl;
320 void read_depth_normal(
const pugi::xml_node &node)
322 bool feature_estimation_method_node =
false;
323 bool PCL_plane_estimation_node =
false;
324 bool sampling_step_node =
false;
326 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
327 if (dataNode.type() == pugi::node_element) {
328 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
329 if (iter_data != m_nodeMap.end()) {
330 switch (iter_data->second) {
331 case feature_estimation_method:
332 m_depthNormalFeatureEstimationMethod =
334 feature_estimation_method_node =
true;
337 case PCL_plane_estimation:
338 read_depth_normal_PCL(dataNode);
339 PCL_plane_estimation_node =
true;
342 case depth_sampling_step:
343 read_depth_normal_sampling_step(dataNode);
344 sampling_step_node =
true;
355 if (!feature_estimation_method_node)
356 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
357 <<
" (default)" << std::endl;
359 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
361 if (!PCL_plane_estimation_node) {
362 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
363 <<
" (default)" << std::endl;
364 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
365 <<
" (default)" << std::endl;
366 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
367 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
370 if (!sampling_step_node) {
371 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
373 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
384 void read_depth_normal_PCL(
const pugi::xml_node &node)
386 bool PCL_plane_estimation_method_node =
false;
387 bool PCL_plane_estimation_ransac_max_iter_node =
false;
388 bool PCL_plane_estimation_ransac_threshold_node =
false;
390 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
391 if (dataNode.type() == pugi::node_element) {
392 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
393 if (iter_data != m_nodeMap.end()) {
394 switch (iter_data->second) {
395 case PCL_plane_estimation_method:
396 m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
397 PCL_plane_estimation_method_node =
true;
400 case PCL_plane_estimation_ransac_max_iter:
401 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
402 PCL_plane_estimation_ransac_max_iter_node =
true;
405 case PCL_plane_estimation_ransac_threshold:
406 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
407 PCL_plane_estimation_ransac_threshold_node =
true;
418 if (!PCL_plane_estimation_method_node)
419 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
420 <<
" (default)" << std::endl;
422 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
425 if (!PCL_plane_estimation_ransac_max_iter_node)
426 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
427 <<
" (default)" << std::endl;
429 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
432 if (!PCL_plane_estimation_ransac_threshold_node)
433 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
434 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
436 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
437 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
446 void read_depth_normal_sampling_step(
const pugi::xml_node &node)
448 bool sampling_step_X_node =
false;
449 bool sampling_step_Y_node =
false;
451 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
452 if (dataNode.type() == pugi::node_element) {
453 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
454 if (iter_data != m_nodeMap.end()) {
455 switch (iter_data->second) {
456 case depth_sampling_step_X:
457 m_depthNormalSamplingStepX = dataNode.text().as_uint();
458 sampling_step_X_node =
true;
461 case depth_sampling_step_Y:
462 m_depthNormalSamplingStepY = dataNode.text().as_uint();
463 sampling_step_Y_node =
true;
474 if (!sampling_step_X_node)
475 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX <<
" (default)"
478 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
480 if (!sampling_step_Y_node)
481 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY <<
" (default)"
484 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
493 void read_depth_dense(
const pugi::xml_node &node)
495 bool sampling_step_node =
false;
497 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
498 if (dataNode.type() == pugi::node_element) {
499 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
500 if (iter_data != m_nodeMap.end()) {
501 switch (iter_data->second) {
502 case depth_dense_sampling_step:
503 read_depth_dense_sampling_step(dataNode);
504 sampling_step_node =
true;
514 if (!sampling_step_node && m_verbose) {
515 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
516 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
525 void read_depth_dense_sampling_step(
const pugi::xml_node &node)
527 bool sampling_step_X_node =
false;
528 bool sampling_step_Y_node =
false;
530 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
531 if (dataNode.type() == pugi::node_element) {
532 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
533 if (iter_data != m_nodeMap.end()) {
534 switch (iter_data->second) {
535 case depth_dense_sampling_step_X:
536 m_depthDenseSamplingStepX = dataNode.text().as_uint();
537 sampling_step_X_node =
true;
540 case depth_dense_sampling_step_Y:
541 m_depthDenseSamplingStepY = dataNode.text().as_uint();
542 sampling_step_Y_node =
true;
553 if (!sampling_step_X_node)
554 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX <<
" (default)"
557 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
559 if (!sampling_step_Y_node)
560 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY <<
" (default)"
563 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
572 void read_ecm(
const pugi::xml_node &node)
574 bool mask_node =
false;
575 bool range_node =
false;
576 bool contrast_node =
false;
577 bool sample_node =
false;
579 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
580 if (dataNode.type() == pugi::node_element) {
581 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
582 if (iter_data != m_nodeMap.end()) {
583 switch (iter_data->second) {
585 read_ecm_mask(dataNode);
590 read_ecm_range(dataNode);
595 read_ecm_contrast(dataNode);
596 contrast_node =
true;
600 read_ecm_sample(dataNode);
613 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
614 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
618 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
621 if (!contrast_node) {
622 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
623 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
624 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
628 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
638 void read_ecm_contrast(
const pugi::xml_node &node)
640 bool edge_threshold_node =
false;
641 bool mu1_node =
false;
642 bool mu2_node =
false;
645 double d_edge_threshold = m_ecm.getThreshold();
646 double d_mu1 = m_ecm.getMu1();
647 double d_mu2 = m_ecm.getMu2();
649 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
650 if (dataNode.type() == pugi::node_element) {
651 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
652 if (iter_data != m_nodeMap.end()) {
653 switch (iter_data->second) {
655 d_edge_threshold = dataNode.text().as_double();
656 edge_threshold_node =
true;
660 d_mu1 = dataNode.text().as_double();
665 d_mu2 = dataNode.text().as_double();
678 m_ecm.setThreshold(d_edge_threshold);
681 if (!edge_threshold_node)
682 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
684 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
687 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
689 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
692 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
694 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
703 void read_ecm_mask(
const pugi::xml_node &node)
705 bool size_node =
false;
706 bool nb_mask_node =
false;
709 unsigned int d_size = m_ecm.getMaskSize();
710 unsigned int d_nb_mask = m_ecm.getMaskNumber();
712 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
713 if (dataNode.type() == pugi::node_element) {
714 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
715 if (iter_data != m_nodeMap.end()) {
716 switch (iter_data->second) {
718 d_size = dataNode.text().as_uint();
723 d_nb_mask = dataNode.text().as_uint();
734 m_ecm.setMaskSize(d_size);
739 "parameter should be different "
740 "from zero in xml file"));
741 m_ecm.setMaskNumber(d_nb_mask);
745 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
747 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
750 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
752 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
761 void read_ecm_range(
const pugi::xml_node &node)
763 bool tracking_node =
false;
766 unsigned int m_range_tracking = m_ecm.getRange();
768 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
769 if (dataNode.type() == pugi::node_element) {
770 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
771 if (iter_data != m_nodeMap.end()) {
772 switch (iter_data->second) {
774 m_range_tracking = dataNode.text().as_uint();
775 tracking_node =
true;
785 m_ecm.setRange(m_range_tracking);
789 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
791 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() << std::endl;
800 void read_ecm_sample(
const pugi::xml_node &node)
802 bool step_node =
false;
805 double d_stp = m_ecm.getSampleStep();
807 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
808 if (dataNode.type() == pugi::node_element) {
809 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
810 if (iter_data != m_nodeMap.end()) {
811 switch (iter_data->second) {
813 d_stp = dataNode.text().as_int();
824 m_ecm.setSampleStep(d_stp);
828 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
830 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
839 void read_face(
const pugi::xml_node &node)
841 bool angle_appear_node =
false;
842 bool angle_disappear_node =
false;
843 bool near_clipping_node =
false;
844 bool far_clipping_node =
false;
845 bool fov_clipping_node =
false;
846 m_hasNearClipping =
false;
847 m_hasFarClipping =
false;
849 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
850 if (dataNode.type() == pugi::node_element) {
851 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
852 if (iter_data != m_nodeMap.end()) {
853 switch (iter_data->second) {
855 m_angleAppear = dataNode.text().as_double();
856 angle_appear_node =
true;
859 case angle_disappear:
860 m_angleDisappear = dataNode.text().as_double();
861 angle_disappear_node =
true;
865 m_nearClipping = dataNode.text().as_double();
866 m_hasNearClipping =
true;
867 near_clipping_node =
true;
871 m_farClipping = dataNode.text().as_double();
872 m_hasFarClipping =
true;
873 far_clipping_node =
true;
877 if (dataNode.text().as_int())
878 m_fovClipping =
true;
880 m_fovClipping =
false;
881 fov_clipping_node =
true;
892 if (!angle_appear_node)
893 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
895 std::cout <<
"face : Angle Appear : " << m_angleAppear << std::endl;
897 if (!angle_disappear_node)
898 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
900 std::cout <<
"face : Angle Disappear : " << m_angleDisappear << std::endl;
902 if (near_clipping_node)
903 std::cout <<
"face : Near Clipping : " << m_nearClipping << std::endl;
905 if (far_clipping_node)
906 std::cout <<
"face : Far Clipping : " << m_farClipping << std::endl;
908 if (fov_clipping_node) {
910 std::cout <<
"face : Fov Clipping : True" << std::endl;
912 std::cout <<
"face : Fov Clipping : False" << std::endl;
922 void read_klt(
const pugi::xml_node &node)
924 bool mask_border_node =
false;
925 bool max_features_node =
false;
926 bool window_size_node =
false;
927 bool quality_node =
false;
928 bool min_distance_node =
false;
929 bool harris_node =
false;
930 bool size_block_node =
false;
931 bool pyramid_lvl_node =
false;
933 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
934 if (dataNode.type() == pugi::node_element) {
935 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
936 if (iter_data != m_nodeMap.end()) {
937 switch (iter_data->second) {
939 m_kltMaskBorder = dataNode.text().as_uint();
940 mask_border_node =
true;
944 m_kltMaxFeatures = dataNode.text().as_uint();
945 max_features_node =
true;
949 m_kltWinSize = dataNode.text().as_uint();
950 window_size_node =
true;
954 m_kltQualityValue = dataNode.text().as_double();
959 m_kltMinDist = dataNode.text().as_double();
960 min_distance_node =
true;
964 m_kltHarrisParam = dataNode.text().as_double();
969 m_kltBlockSize = dataNode.text().as_uint();
970 size_block_node =
true;
974 m_kltPyramidLevels = dataNode.text().as_uint();
975 pyramid_lvl_node =
true;
986 if (!mask_border_node)
987 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
989 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder << std::endl;
991 if (!max_features_node)
992 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
994 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures << std::endl;
996 if (!window_size_node)
997 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
999 std::cout <<
"klt : Windows Size : " << m_kltWinSize << std::endl;
1002 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
1004 std::cout <<
"klt : Quality : " << m_kltQualityValue << std::endl;
1006 if (!min_distance_node)
1007 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
1009 std::cout <<
"klt : Min Distance : " << m_kltMinDist << std::endl;
1012 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
1014 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1016 if (!size_block_node)
1017 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
1019 std::cout <<
"klt : Block Size : " << m_kltBlockSize << std::endl;
1021 if (!pyramid_lvl_node)
1022 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
1024 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1028 void read_lod(
const pugi::xml_node &node)
1030 bool use_lod_node =
false;
1031 bool min_line_length_threshold_node =
false;
1032 bool min_polygon_area_threshold_node =
false;
1034 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1035 if (dataNode.type() == pugi::node_element) {
1036 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1037 if (iter_data != m_nodeMap.end()) {
1038 switch (iter_data->second) {
1040 m_useLod = (dataNode.text().as_int() != 0);
1041 use_lod_node =
true;
1044 case min_line_length_threshold:
1045 m_minLineLengthThreshold = dataNode.text().as_double();
1046 min_line_length_threshold_node =
true;
1049 case min_polygon_area_threshold:
1050 m_minPolygonAreaThreshold = dataNode.text().as_double();
1051 min_polygon_area_threshold_node =
true;
1063 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
1065 std::cout <<
"lod : use lod : " << m_useLod << std::endl;
1067 if (!min_line_length_threshold_node)
1068 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
1070 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1072 if (!min_polygon_area_threshold_node)
1073 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
1075 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1079 void read_projection_error(
const pugi::xml_node &node)
1081 bool step_node =
false;
1082 bool kernel_size_node =
false;
1085 double d_stp = m_projectionErrorMe.getSampleStep();
1086 std::string kernel_size_str;
1088 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1089 if (dataNode.type() == pugi::node_element) {
1090 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1091 if (iter_data != m_nodeMap.end()) {
1092 switch (iter_data->second) {
1093 case projection_error_sample_step:
1094 d_stp = dataNode.text().as_int();
1098 case projection_error_kernel_size:
1099 kernel_size_str = dataNode.text().as_string();
1100 kernel_size_node =
true;
1110 m_projectionErrorMe.setSampleStep(d_stp);
1112 if (kernel_size_str ==
"3x3") {
1113 m_projectionErrorKernelSize = 1;
1114 }
else if (kernel_size_str ==
"5x5") {
1115 m_projectionErrorKernelSize = 2;
1116 }
else if (kernel_size_str ==
"7x7") {
1117 m_projectionErrorKernelSize = 3;
1118 }
else if (kernel_size_str ==
"9x9") {
1119 m_projectionErrorKernelSize = 4;
1120 }
else if (kernel_size_str ==
"11x11") {
1121 m_projectionErrorKernelSize = 5;
1122 }
else if (kernel_size_str ==
"13x13") {
1123 m_projectionErrorKernelSize = 6;
1124 }
else if (kernel_size_str ==
"15x15") {
1125 m_projectionErrorKernelSize = 7;
1127 std::cerr <<
"Unsupported kernel size." << std::endl;
1132 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
1135 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1137 if (!kernel_size_node)
1138 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
1139 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
1141 std::cout <<
"projection_error : kernel_size : " << kernel_size_str << std::endl;
1150 void read_sample_deprecated(
const pugi::xml_node &node)
1152 bool step_node =
false;
1156 double d_stp = m_ecm.getSampleStep();
1158 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1159 if (dataNode.type() == pugi::node_element) {
1160 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1161 if (iter_data != m_nodeMap.end()) {
1162 switch (iter_data->second) {
1164 d_stp = dataNode.text().as_int();
1175 m_ecm.setSampleStep(d_stp);
1179 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
1181 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1183 std::cout <<
" WARNING : This node (sample) is deprecated." << std::endl;
1184 std::cout <<
" It should be moved in the ecm node (ecm : sample)." << std::endl;
1193 void getEdgeMe(
vpMe &moving_edge)
const { moving_edge = m_ecm; }
1200 return m_depthNormalFeatureEstimationMethod;
1206 return m_depthNormalPclPlaneEstimationRansacThreshold;
1235 void setAngleAppear(
const double &aappear) { m_angleAppear = aappear; }
1236 void setAngleDisappear(
const double &adisappear) { m_angleDisappear = adisappear; }
1244 m_depthNormalFeatureEstimationMethod = method;
1249 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1253 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1258 void setEdgeMe(
const vpMe &moving_edge) { m_ecm = moving_edge; }
1268 void setKltQuality(
const double &q) { m_kltQualityValue = q; }
1276 void setVerbose(
bool verbose) { m_verbose = verbose; }
1284 double m_angleAppear;
1286 double m_angleDisappear;
1288 bool m_hasNearClipping;
1290 double m_nearClipping;
1292 bool m_hasFarClipping;
1294 double m_farClipping;
1301 double m_minLineLengthThreshold;
1303 double m_minPolygonAreaThreshold;
1309 unsigned int m_kltMaskBorder;
1311 unsigned int m_kltMaxFeatures;
1313 unsigned int m_kltWinSize;
1315 double m_kltQualityValue;
1317 double m_kltMinDist;
1319 double m_kltHarrisParam;
1321 unsigned int m_kltBlockSize;
1323 unsigned int m_kltPyramidLevels;
1328 int m_depthNormalPclPlaneEstimationMethod;
1330 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1332 double m_depthNormalPclPlaneEstimationRansacThreshold;
1334 unsigned int m_depthNormalSamplingStepX;
1336 unsigned int m_depthNormalSamplingStepY;
1339 unsigned int m_depthDenseSamplingStepX;
1341 unsigned int m_depthDenseSamplingStepY;
1344 vpMe m_projectionErrorMe;
1346 unsigned int m_projectionErrorKernelSize;
1347 std::map<std::string, int> m_nodeMap;
1351 enum vpDataToParseMb {
1371 min_line_length_threshold,
1372 min_polygon_area_threshold,
1398 feature_estimation_method,
1399 PCL_plane_estimation,
1400 PCL_plane_estimation_method,
1401 PCL_plane_estimation_ransac_max_iter,
1402 PCL_plane_estimation_ransac_threshold,
1403 depth_sampling_step,
1404 depth_sampling_step_X,
1405 depth_sampling_step_Y,
1408 depth_dense_sampling_step,
1409 depth_dense_sampling_step_X,
1410 depth_dense_sampling_step_Y,
1413 projection_error_sample_step,
1414 projection_error_kernel_size
1423 m_nodeMap[
"conf"] = conf;
1425 m_nodeMap[
"face"] = face;
1426 m_nodeMap[
"angle_appear"] = angle_appear;
1427 m_nodeMap[
"angle_disappear"] = angle_disappear;
1428 m_nodeMap[
"near_clipping"] = near_clipping;
1429 m_nodeMap[
"far_clipping"] = far_clipping;
1430 m_nodeMap[
"fov_clipping"] = fov_clipping;
1432 m_nodeMap[
"camera"] = camera;
1433 m_nodeMap[
"height"] = height;
1434 m_nodeMap[
"width"] = width;
1435 m_nodeMap[
"u0"] = u0;
1436 m_nodeMap[
"v0"] = v0;
1437 m_nodeMap[
"px"] = px;
1438 m_nodeMap[
"py"] = py;
1440 m_nodeMap[
"lod"] = lod;
1441 m_nodeMap[
"use_lod"] = use_lod;
1442 m_nodeMap[
"min_line_length_threshold"] = min_line_length_threshold;
1443 m_nodeMap[
"min_polygon_area_threshold"] = min_polygon_area_threshold;
1445 m_nodeMap[
"ecm"] = ecm;
1446 m_nodeMap[
"mask"] = mask;
1447 m_nodeMap[
"size"] = size;
1448 m_nodeMap[
"nb_mask"] = nb_mask;
1449 m_nodeMap[
"range"] = range;
1450 m_nodeMap[
"tracking"] = tracking;
1451 m_nodeMap[
"contrast"] = contrast;
1452 m_nodeMap[
"edge_threshold"] = edge_threshold;
1453 m_nodeMap[
"mu1"] = mu1;
1454 m_nodeMap[
"mu2"] = mu2;
1455 m_nodeMap[
"sample"] = sample;
1456 m_nodeMap[
"step"] = step;
1458 m_nodeMap[
"klt"] = klt;
1459 m_nodeMap[
"mask_border"] = mask_border;
1460 m_nodeMap[
"max_features"] = max_features;
1461 m_nodeMap[
"window_size"] = window_size;
1462 m_nodeMap[
"quality"] = quality;
1463 m_nodeMap[
"min_distance"] = min_distance;
1464 m_nodeMap[
"harris"] = harris;
1465 m_nodeMap[
"size_block"] = size_block;
1466 m_nodeMap[
"pyramid_lvl"] = pyramid_lvl;
1468 m_nodeMap[
"depth_normal"] = depth_normal;
1469 m_nodeMap[
"feature_estimation_method"] = feature_estimation_method;
1470 m_nodeMap[
"PCL_plane_estimation"] = PCL_plane_estimation;
1471 m_nodeMap[
"method"] = PCL_plane_estimation_method;
1472 m_nodeMap[
"ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1473 m_nodeMap[
"ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1474 m_nodeMap[
"sampling_step"] = depth_sampling_step;
1475 m_nodeMap[
"step_X"] = depth_sampling_step_X;
1476 m_nodeMap[
"step_Y"] = depth_sampling_step_Y;
1478 m_nodeMap[
"depth_dense"] = depth_dense;
1479 m_nodeMap[
"sampling_step"] = depth_dense_sampling_step;
1480 m_nodeMap[
"step_X"] = depth_dense_sampling_step_X;
1481 m_nodeMap[
"step_Y"] = depth_dense_sampling_step_Y;
1483 m_nodeMap[
"projection_error"] = projection_error;
1484 m_nodeMap[
"sample_step"] = projection_error_sample_step;
1485 m_nodeMap[
"kernel_size"] = projection_error_kernel_size;
1496 if (std::setlocale(LC_ALL,
"C") == NULL) {
1497 std::cerr <<
"Cannot set locale to C" << std::endl;
1542 return m_impl->getDepthNormalFeatureEstimationMethod();
1550 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1558 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1566 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1574 return m_impl->getDepthNormalSamplingStepX();
1582 return m_impl->getDepthNormalSamplingStepY();
1662 return m_impl->getProjectionErrorKernelSize();
1707 m_impl->setDepthDenseSamplingStepX(stepX);
1717 m_impl->setDepthDenseSamplingStepY(stepY);
1728 m_impl->setDepthNormalFeatureEstimationMethod(method);
1738 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1748 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1758 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1768 m_impl->setDepthNormalSamplingStepX(stepX);
1778 m_impl->setDepthNormalSamplingStepY(stepY);
1872 m_impl->setProjectionErrorKernelSize(size);
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)