35 #include <visp3/core/vpConfig.h>
41 #include <visp3/mbt/vpMbtXmlGenericParser.h>
43 #include <pugixml.hpp>
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 class vpMbtXmlGenericParser::Impl
55 m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
56 m_farClipping(false), m_fovClipping(false),
58 m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
62 m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
63 m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
66 m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
67 m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2),
68 m_depthNormalSamplingStepY(2),
70 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
72 m_projectionErrorMe(), m_projectionErrorKernelSize(2),
73 m_nodeMap(), m_verbose(true)
77 if (m_call_setlocale) {
82 if (std::setlocale(LC_ALL,
"C") == NULL) {
83 std::cerr <<
"Cannot set locale to C" << std::endl;
85 m_call_setlocale =
false;
90 void parse(
const std::string &filename)
92 pugi::xml_document doc;
93 if (!doc.load_file(filename.c_str())) {
97 bool camera_node =
false;
98 bool face_node =
false;
99 bool ecm_node =
false;
100 bool klt_node =
false;
101 bool lod_node =
false;
102 bool depth_normal_node =
false;
103 bool depth_dense_node =
false;
104 bool projection_error_node =
false;
106 pugi::xml_node root_node = doc.document_element();
107 for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
108 if (dataNode.type() == pugi::node_element) {
109 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
110 if (iter_data != m_nodeMap.end()) {
111 switch (iter_data->second) {
114 read_camera(dataNode);
142 read_sample_deprecated(dataNode);
154 read_depth_normal(dataNode);
155 depth_normal_node =
true;
161 read_depth_dense(dataNode);
162 depth_dense_node =
true;
166 case projection_error:
168 read_projection_error(dataNode);
169 projection_error_node =
true;
182 if (!projection_error_node) {
183 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
185 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
186 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
191 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
192 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
193 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
194 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
198 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
199 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
203 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
204 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
205 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
209 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
210 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
211 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
212 std::cout <<
"me : contrast : threshold type : " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
213 std::cout <<
"me : contrast : threshold : " << m_ecm.getThreshold() <<
" (default)" << std::endl;
214 std::cout <<
"me : contrast : mu1 : " << m_ecm.getMu1() <<
" (default)" << std::endl;
215 std::cout <<
"me : contrast : mu2 : " << m_ecm.getMu2() <<
" (default)" << std::endl;
216 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
219 if (!klt_node && (m_parserType &
KLT_PARSER)) {
220 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
221 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
222 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
223 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
224 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
225 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
226 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
227 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
231 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
232 <<
" (default)" << std::endl;
233 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
234 <<
" (default)" << std::endl;
235 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : "
236 << m_depthNormalPclPlaneEstimationRansacMaxIter <<
" (default)" << std::endl;
237 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
238 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
239 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
241 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
246 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)"
248 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)"
260 void read_camera(
const pugi::xml_node &node)
262 bool u0_node =
false;
263 bool v0_node =
false;
264 bool px_node =
false;
265 bool py_node =
false;
268 double d_u0 = m_cam.get_u0();
269 double d_v0 = m_cam.get_v0();
270 double d_px = m_cam.get_px();
271 double d_py = m_cam.get_py();
273 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
274 if (dataNode.type() == pugi::node_element) {
275 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
276 if (iter_data != m_nodeMap.end()) {
277 switch (iter_data->second) {
279 d_u0 = dataNode.text().as_double();
284 d_v0 = dataNode.text().as_double();
289 d_px = dataNode.text().as_double();
294 d_py = dataNode.text().as_double();
305 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
309 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
311 std::cout <<
"camera : u0 : " << m_cam.get_u0() << std::endl;
314 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
316 std::cout <<
"camera : v0 : " << m_cam.get_v0() << std::endl;
319 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
321 std::cout <<
"camera : px : " << m_cam.get_px() << std::endl;
324 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
326 std::cout <<
"camera : py : " << m_cam.get_py() << std::endl;
335 void read_depth_normal(
const pugi::xml_node &node)
337 bool feature_estimation_method_node =
false;
338 bool PCL_plane_estimation_node =
false;
339 bool sampling_step_node =
false;
341 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
342 if (dataNode.type() == pugi::node_element) {
343 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
344 if (iter_data != m_nodeMap.end()) {
345 switch (iter_data->second) {
346 case feature_estimation_method:
347 m_depthNormalFeatureEstimationMethod =
349 feature_estimation_method_node =
true;
352 case PCL_plane_estimation:
353 read_depth_normal_PCL(dataNode);
354 PCL_plane_estimation_node =
true;
357 case depth_sampling_step:
358 read_depth_normal_sampling_step(dataNode);
359 sampling_step_node =
true;
370 if (!feature_estimation_method_node)
371 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod
372 <<
" (default)" << std::endl;
374 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
376 if (!PCL_plane_estimation_node) {
377 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
378 <<
" (default)" << std::endl;
379 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
380 <<
" (default)" << std::endl;
381 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
382 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
385 if (!sampling_step_node) {
386 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)"
388 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)"
399 void read_depth_normal_PCL(
const pugi::xml_node &node)
401 bool PCL_plane_estimation_method_node =
false;
402 bool PCL_plane_estimation_ransac_max_iter_node =
false;
403 bool PCL_plane_estimation_ransac_threshold_node =
false;
405 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
406 if (dataNode.type() == pugi::node_element) {
407 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
408 if (iter_data != m_nodeMap.end()) {
409 switch (iter_data->second) {
410 case PCL_plane_estimation_method:
411 m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
412 PCL_plane_estimation_method_node =
true;
415 case PCL_plane_estimation_ransac_max_iter:
416 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
417 PCL_plane_estimation_ransac_max_iter_node =
true;
420 case PCL_plane_estimation_ransac_threshold:
421 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
422 PCL_plane_estimation_ransac_threshold_node =
true;
433 if (!PCL_plane_estimation_method_node)
434 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
435 <<
" (default)" << std::endl;
437 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
440 if (!PCL_plane_estimation_ransac_max_iter_node)
441 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
442 <<
" (default)" << std::endl;
444 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
447 if (!PCL_plane_estimation_ransac_threshold_node)
448 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
449 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
451 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
452 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
461 void read_depth_normal_sampling_step(
const pugi::xml_node &node)
463 bool sampling_step_X_node =
false;
464 bool sampling_step_Y_node =
false;
466 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
467 if (dataNode.type() == pugi::node_element) {
468 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
469 if (iter_data != m_nodeMap.end()) {
470 switch (iter_data->second) {
471 case depth_sampling_step_X:
472 m_depthNormalSamplingStepX = dataNode.text().as_uint();
473 sampling_step_X_node =
true;
476 case depth_sampling_step_Y:
477 m_depthNormalSamplingStepY = dataNode.text().as_uint();
478 sampling_step_Y_node =
true;
489 if (!sampling_step_X_node)
490 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX <<
" (default)"
493 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
495 if (!sampling_step_Y_node)
496 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY <<
" (default)"
499 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
508 void read_depth_dense(
const pugi::xml_node &node)
510 bool sampling_step_node =
false;
512 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
513 if (dataNode.type() == pugi::node_element) {
514 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
515 if (iter_data != m_nodeMap.end()) {
516 switch (iter_data->second) {
517 case depth_dense_sampling_step:
518 read_depth_dense_sampling_step(dataNode);
519 sampling_step_node =
true;
529 if (!sampling_step_node && m_verbose) {
530 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
531 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
540 void read_depth_dense_sampling_step(
const pugi::xml_node &node)
542 bool sampling_step_X_node =
false;
543 bool sampling_step_Y_node =
false;
545 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
546 if (dataNode.type() == pugi::node_element) {
547 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
548 if (iter_data != m_nodeMap.end()) {
549 switch (iter_data->second) {
550 case depth_dense_sampling_step_X:
551 m_depthDenseSamplingStepX = dataNode.text().as_uint();
552 sampling_step_X_node =
true;
555 case depth_dense_sampling_step_Y:
556 m_depthDenseSamplingStepY = dataNode.text().as_uint();
557 sampling_step_Y_node =
true;
568 if (!sampling_step_X_node)
569 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX <<
" (default)"
572 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
574 if (!sampling_step_Y_node)
575 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY <<
" (default)"
578 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
587 void read_ecm(
const pugi::xml_node &node)
589 bool mask_node =
false;
590 bool range_node =
false;
591 bool contrast_node =
false;
592 bool sample_node =
false;
594 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
595 if (dataNode.type() == pugi::node_element) {
596 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
597 if (iter_data != m_nodeMap.end()) {
598 switch (iter_data->second) {
600 read_ecm_mask(dataNode);
605 read_ecm_range(dataNode);
610 read_ecm_contrast(dataNode);
611 contrast_node =
true;
615 read_ecm_sample(dataNode);
628 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
629 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
633 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
636 if (!contrast_node) {
637 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
638 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
639 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
640 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
644 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
654 void read_ecm_contrast(
const pugi::xml_node &node)
656 bool edge_threshold_type_node =
false;
657 bool edge_threshold_node =
false;
658 bool mu1_node =
false;
659 bool mu2_node =
false;
663 double d_edge_threshold = m_ecm.getThreshold();
664 double d_mu1 = m_ecm.getMu1();
665 double d_mu2 = m_ecm.getMu2();
667 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
668 if (dataNode.type() == pugi::node_element) {
669 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
670 if (iter_data != m_nodeMap.end()) {
671 switch (iter_data->second) {
672 case edge_threshold_type:
674 edge_threshold_type_node =
true;
678 d_edge_threshold = dataNode.text().as_int();
679 edge_threshold_node =
true;
683 d_mu1 = dataNode.text().as_double();
688 d_mu2 = dataNode.text().as_double();
701 m_ecm.setLikelihoodThresholdType(d_edge_threshold_type);
702 m_ecm.setThreshold(d_edge_threshold);
705 if (!edge_threshold_type_node)
706 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() <<
" (default)" << std::endl;
708 std::cout <<
"me : contrast : threshold type " << m_ecm.getLikelihoodThresholdType() << std::endl;
710 if (!edge_threshold_node)
711 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
713 std::cout <<
"me : contrast : threshold " << m_ecm.getThreshold() << std::endl;
716 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
718 std::cout <<
"me : contrast : mu1 " << m_ecm.getMu1() << std::endl;
721 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
723 std::cout <<
"me : contrast : mu2 " << m_ecm.getMu2() << std::endl;
732 void read_ecm_mask(
const pugi::xml_node &node)
734 bool size_node =
false;
735 bool nb_mask_node =
false;
738 unsigned int d_size = m_ecm.getMaskSize();
739 unsigned int d_nb_mask = m_ecm.getMaskNumber();
741 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
742 if (dataNode.type() == pugi::node_element) {
743 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
744 if (iter_data != m_nodeMap.end()) {
745 switch (iter_data->second) {
747 d_size = dataNode.text().as_uint();
752 d_nb_mask = dataNode.text().as_uint();
763 m_ecm.setMaskSize(d_size);
768 "parameter should be different "
769 "from zero in xml file"));
770 m_ecm.setMaskNumber(d_nb_mask);
774 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
776 std::cout <<
"me : mask : size : " << m_ecm.getMaskSize() << std::endl;
779 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
781 std::cout <<
"me : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
790 void read_ecm_range(
const pugi::xml_node &node)
792 bool tracking_node =
false;
795 unsigned int m_range_tracking = m_ecm.getRange();
797 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
798 if (dataNode.type() == pugi::node_element) {
799 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
800 if (iter_data != m_nodeMap.end()) {
801 switch (iter_data->second) {
803 m_range_tracking = dataNode.text().as_uint();
804 tracking_node =
true;
814 m_ecm.setRange(m_range_tracking);
818 std::cout <<
"me : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
820 std::cout <<
"me : range : tracking : " << m_ecm.getRange() << std::endl;
829 void read_ecm_sample(
const pugi::xml_node &node)
831 bool step_node =
false;
834 double d_stp = m_ecm.getSampleStep();
836 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
837 if (dataNode.type() == pugi::node_element) {
838 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
839 if (iter_data != m_nodeMap.end()) {
840 switch (iter_data->second) {
842 d_stp = dataNode.text().as_int();
853 m_ecm.setSampleStep(d_stp);
857 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
859 std::cout <<
"me : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
868 void read_face(
const pugi::xml_node &node)
870 bool angle_appear_node =
false;
871 bool angle_disappear_node =
false;
872 bool near_clipping_node =
false;
873 bool far_clipping_node =
false;
874 bool fov_clipping_node =
false;
875 m_hasNearClipping =
false;
876 m_hasFarClipping =
false;
878 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
879 if (dataNode.type() == pugi::node_element) {
880 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
881 if (iter_data != m_nodeMap.end()) {
882 switch (iter_data->second) {
884 m_angleAppear = dataNode.text().as_double();
885 angle_appear_node =
true;
888 case angle_disappear:
889 m_angleDisappear = dataNode.text().as_double();
890 angle_disappear_node =
true;
894 m_nearClipping = dataNode.text().as_double();
895 m_hasNearClipping =
true;
896 near_clipping_node =
true;
900 m_farClipping = dataNode.text().as_double();
901 m_hasFarClipping =
true;
902 far_clipping_node =
true;
906 if (dataNode.text().as_int())
907 m_fovClipping =
true;
909 m_fovClipping =
false;
910 fov_clipping_node =
true;
921 if (!angle_appear_node)
922 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
924 std::cout <<
"face : Angle Appear : " << m_angleAppear << std::endl;
926 if (!angle_disappear_node)
927 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
929 std::cout <<
"face : Angle Disappear : " << m_angleDisappear << std::endl;
931 if (near_clipping_node)
932 std::cout <<
"face : Near Clipping : " << m_nearClipping << std::endl;
934 if (far_clipping_node)
935 std::cout <<
"face : Far Clipping : " << m_farClipping << std::endl;
937 if (fov_clipping_node) {
939 std::cout <<
"face : Fov Clipping : True" << std::endl;
941 std::cout <<
"face : Fov Clipping : False" << std::endl;
951 void read_klt(
const pugi::xml_node &node)
953 bool mask_border_node =
false;
954 bool max_features_node =
false;
955 bool window_size_node =
false;
956 bool quality_node =
false;
957 bool min_distance_node =
false;
958 bool harris_node =
false;
959 bool size_block_node =
false;
960 bool pyramid_lvl_node =
false;
962 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
963 if (dataNode.type() == pugi::node_element) {
964 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
965 if (iter_data != m_nodeMap.end()) {
966 switch (iter_data->second) {
968 m_kltMaskBorder = dataNode.text().as_uint();
969 mask_border_node =
true;
973 m_kltMaxFeatures = dataNode.text().as_uint();
974 max_features_node =
true;
978 m_kltWinSize = dataNode.text().as_uint();
979 window_size_node =
true;
983 m_kltQualityValue = dataNode.text().as_double();
988 m_kltMinDist = dataNode.text().as_double();
989 min_distance_node =
true;
993 m_kltHarrisParam = dataNode.text().as_double();
998 m_kltBlockSize = dataNode.text().as_uint();
999 size_block_node =
true;
1003 m_kltPyramidLevels = dataNode.text().as_uint();
1004 pyramid_lvl_node =
true;
1015 if (!mask_border_node)
1016 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
1018 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder << std::endl;
1020 if (!max_features_node)
1021 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
1023 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures << std::endl;
1025 if (!window_size_node)
1026 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
1028 std::cout <<
"klt : Windows Size : " << m_kltWinSize << std::endl;
1031 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
1033 std::cout <<
"klt : Quality : " << m_kltQualityValue << std::endl;
1035 if (!min_distance_node)
1036 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
1038 std::cout <<
"klt : Min Distance : " << m_kltMinDist << std::endl;
1041 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
1043 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
1045 if (!size_block_node)
1046 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
1048 std::cout <<
"klt : Block Size : " << m_kltBlockSize << std::endl;
1050 if (!pyramid_lvl_node)
1051 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
1053 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
1057 void read_lod(
const pugi::xml_node &node)
1059 bool use_lod_node =
false;
1060 bool min_line_length_threshold_node =
false;
1061 bool min_polygon_area_threshold_node =
false;
1063 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1064 if (dataNode.type() == pugi::node_element) {
1065 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1066 if (iter_data != m_nodeMap.end()) {
1067 switch (iter_data->second) {
1069 m_useLod = (dataNode.text().as_int() != 0);
1070 use_lod_node =
true;
1073 case min_line_length_threshold:
1074 m_minLineLengthThreshold = dataNode.text().as_double();
1075 min_line_length_threshold_node =
true;
1078 case min_polygon_area_threshold:
1079 m_minPolygonAreaThreshold = dataNode.text().as_double();
1080 min_polygon_area_threshold_node =
true;
1092 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
1094 std::cout <<
"lod : use lod : " << m_useLod << std::endl;
1096 if (!min_line_length_threshold_node)
1097 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
1099 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1101 if (!min_polygon_area_threshold_node)
1102 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
1104 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1108 void read_projection_error(
const pugi::xml_node &node)
1110 bool step_node =
false;
1111 bool kernel_size_node =
false;
1114 double d_stp = m_projectionErrorMe.getSampleStep();
1115 std::string kernel_size_str;
1117 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1118 if (dataNode.type() == pugi::node_element) {
1119 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1120 if (iter_data != m_nodeMap.end()) {
1121 switch (iter_data->second) {
1122 case projection_error_sample_step:
1123 d_stp = dataNode.text().as_int();
1127 case projection_error_kernel_size:
1128 kernel_size_str = dataNode.text().as_string();
1129 kernel_size_node =
true;
1139 m_projectionErrorMe.setSampleStep(d_stp);
1141 if (kernel_size_str ==
"3x3") {
1142 m_projectionErrorKernelSize = 1;
1144 else if (kernel_size_str ==
"5x5") {
1145 m_projectionErrorKernelSize = 2;
1147 else if (kernel_size_str ==
"7x7") {
1148 m_projectionErrorKernelSize = 3;
1150 else if (kernel_size_str ==
"9x9") {
1151 m_projectionErrorKernelSize = 4;
1153 else if (kernel_size_str ==
"11x11") {
1154 m_projectionErrorKernelSize = 5;
1156 else if (kernel_size_str ==
"13x13") {
1157 m_projectionErrorKernelSize = 6;
1159 else if (kernel_size_str ==
"15x15") {
1160 m_projectionErrorKernelSize = 7;
1163 std::cerr <<
"Unsupported kernel size." << std::endl;
1168 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)"
1171 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1173 if (!kernel_size_node)
1174 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize * 2 + 1 <<
"x"
1175 << m_projectionErrorKernelSize * 2 + 1 <<
" (default)" << std::endl;
1177 std::cout <<
"projection_error : kernel_size : " << kernel_size_str << std::endl;
1186 void read_sample_deprecated(
const pugi::xml_node &node)
1188 bool step_node =
false;
1192 double d_stp = m_ecm.getSampleStep();
1194 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1195 if (dataNode.type() == pugi::node_element) {
1196 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1197 if (iter_data != m_nodeMap.end()) {
1198 switch (iter_data->second) {
1200 d_stp = dataNode.text().as_int();
1211 m_ecm.setSampleStep(d_stp);
1215 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
1217 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1219 std::cout <<
" WARNING : This node (sample) is deprecated." << std::endl;
1220 std::cout <<
" It should be moved in the ecm node (me : sample)." << std::endl;
1229 void getEdgeMe(
vpMe &moving_edge)
const { moving_edge = m_ecm; }
1236 return m_depthNormalFeatureEstimationMethod;
1242 return m_depthNormalPclPlaneEstimationRansacThreshold;
1271 void setAngleAppear(
const double &aappear) { m_angleAppear = aappear; }
1272 void setAngleDisappear(
const double &adisappear) { m_angleDisappear = adisappear; }
1280 m_depthNormalFeatureEstimationMethod = method;
1285 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1289 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1294 void setEdgeMe(
const vpMe &moving_edge) { m_ecm = moving_edge; }
1304 void setKltQuality(
const double &q) { m_kltQualityValue = q; }
1312 void setVerbose(
bool verbose) { m_verbose = verbose; }
1320 double m_angleAppear;
1322 double m_angleDisappear;
1324 bool m_hasNearClipping;
1326 double m_nearClipping;
1328 bool m_hasFarClipping;
1330 double m_farClipping;
1337 double m_minLineLengthThreshold;
1339 double m_minPolygonAreaThreshold;
1345 unsigned int m_kltMaskBorder;
1347 unsigned int m_kltMaxFeatures;
1349 unsigned int m_kltWinSize;
1351 double m_kltQualityValue;
1353 double m_kltMinDist;
1355 double m_kltHarrisParam;
1357 unsigned int m_kltBlockSize;
1359 unsigned int m_kltPyramidLevels;
1364 int m_depthNormalPclPlaneEstimationMethod;
1366 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1368 double m_depthNormalPclPlaneEstimationRansacThreshold;
1370 unsigned int m_depthNormalSamplingStepX;
1372 unsigned int m_depthNormalSamplingStepY;
1375 unsigned int m_depthDenseSamplingStepX;
1377 unsigned int m_depthDenseSamplingStepY;
1380 vpMe m_projectionErrorMe;
1382 unsigned int m_projectionErrorKernelSize;
1383 std::map<std::string, int> m_nodeMap;
1387 enum vpDataToParseMb
1408 min_line_length_threshold,
1409 min_polygon_area_threshold,
1419 edge_threshold_type,
1436 feature_estimation_method,
1437 PCL_plane_estimation,
1438 PCL_plane_estimation_method,
1439 PCL_plane_estimation_ransac_max_iter,
1440 PCL_plane_estimation_ransac_threshold,
1441 depth_sampling_step,
1442 depth_sampling_step_X,
1443 depth_sampling_step_Y,
1446 depth_dense_sampling_step,
1447 depth_dense_sampling_step_X,
1448 depth_dense_sampling_step_Y,
1451 projection_error_sample_step,
1452 projection_error_kernel_size
1461 m_nodeMap[
"conf"] = conf;
1463 m_nodeMap[
"face"] = face;
1464 m_nodeMap[
"angle_appear"] = angle_appear;
1465 m_nodeMap[
"angle_disappear"] = angle_disappear;
1466 m_nodeMap[
"near_clipping"] = near_clipping;
1467 m_nodeMap[
"far_clipping"] = far_clipping;
1468 m_nodeMap[
"fov_clipping"] = fov_clipping;
1470 m_nodeMap[
"camera"] = camera;
1471 m_nodeMap[
"height"] = height;
1472 m_nodeMap[
"width"] = width;
1473 m_nodeMap[
"u0"] = u0;
1474 m_nodeMap[
"v0"] = v0;
1475 m_nodeMap[
"px"] = px;
1476 m_nodeMap[
"py"] = py;
1478 m_nodeMap[
"lod"] = lod;
1479 m_nodeMap[
"use_lod"] = use_lod;
1480 m_nodeMap[
"min_line_length_threshold"] = min_line_length_threshold;
1481 m_nodeMap[
"min_polygon_area_threshold"] = min_polygon_area_threshold;
1483 m_nodeMap[
"ecm"] = ecm;
1484 m_nodeMap[
"mask"] = mask;
1485 m_nodeMap[
"size"] = size;
1486 m_nodeMap[
"nb_mask"] = nb_mask;
1487 m_nodeMap[
"range"] = range;
1488 m_nodeMap[
"tracking"] = tracking;
1489 m_nodeMap[
"contrast"] = contrast;
1490 m_nodeMap[
"edge_threshold_type"] = edge_threshold_type;
1491 m_nodeMap[
"edge_threshold"] = edge_threshold;
1492 m_nodeMap[
"mu1"] = mu1;
1493 m_nodeMap[
"mu2"] = mu2;
1494 m_nodeMap[
"sample"] = sample;
1495 m_nodeMap[
"step"] = step;
1497 m_nodeMap[
"klt"] = klt;
1498 m_nodeMap[
"mask_border"] = mask_border;
1499 m_nodeMap[
"max_features"] = max_features;
1500 m_nodeMap[
"window_size"] = window_size;
1501 m_nodeMap[
"quality"] = quality;
1502 m_nodeMap[
"min_distance"] = min_distance;
1503 m_nodeMap[
"harris"] = harris;
1504 m_nodeMap[
"size_block"] = size_block;
1505 m_nodeMap[
"pyramid_lvl"] = pyramid_lvl;
1507 m_nodeMap[
"depth_normal"] = depth_normal;
1508 m_nodeMap[
"feature_estimation_method"] = feature_estimation_method;
1509 m_nodeMap[
"PCL_plane_estimation"] = PCL_plane_estimation;
1510 m_nodeMap[
"method"] = PCL_plane_estimation_method;
1511 m_nodeMap[
"ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1512 m_nodeMap[
"ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1513 m_nodeMap[
"sampling_step"] = depth_sampling_step;
1514 m_nodeMap[
"step_X"] = depth_sampling_step_X;
1515 m_nodeMap[
"step_Y"] = depth_sampling_step_Y;
1517 m_nodeMap[
"depth_dense"] = depth_dense;
1518 m_nodeMap[
"sampling_step"] = depth_dense_sampling_step;
1519 m_nodeMap[
"step_X"] = depth_dense_sampling_step_X;
1520 m_nodeMap[
"step_Y"] = depth_dense_sampling_step_Y;
1522 m_nodeMap[
"projection_error"] = projection_error;
1523 m_nodeMap[
"sample_step"] = projection_error_sample_step;
1524 m_nodeMap[
"kernel_size"] = projection_error_kernel_size;
1528 static bool m_call_setlocale;
1531 bool vpMbtXmlGenericParser::Impl::m_call_setlocale =
true;
1579 return m_impl->getDepthNormalFeatureEstimationMethod();
1587 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1595 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1603 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1611 return m_impl->getDepthNormalSamplingStepX();
1619 return m_impl->getDepthNormalSamplingStepY();
1699 return m_impl->getProjectionErrorKernelSize();
1744 m_impl->setDepthDenseSamplingStepX(stepX);
1754 m_impl->setDepthDenseSamplingStepY(stepY);
1765 m_impl->setDepthNormalFeatureEstimationMethod(method);
1775 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1785 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1795 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1805 m_impl->setDepthNormalSamplingStepX(stepX);
1815 m_impl->setDepthNormalSamplingStepY(stepY);
1909 m_impl->setProjectionErrorKernelSize(size);
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