35 #include <visp3/core/vpConfig.h>
37 #ifdef VISP_HAVE_PUGIXML
43 #include <visp3/mbt/vpMbtXmlGenericParser.h>
45 #include <pugixml.hpp>
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 class vpMbtXmlGenericParser::Impl
56 m_angleAppear(70), m_angleDisappear(80), m_hasNearClipping(false), m_nearClipping(false), m_hasFarClipping(false),
57 m_farClipping(false), m_fovClipping(false),
59 m_useLod(false), m_minLineLengthThreshold(50.0), m_minPolygonAreaThreshold(2500.0),
63 m_kltMaskBorder(0), m_kltMaxFeatures(0), m_kltWinSize(0), m_kltQualityValue(0.), m_kltMinDist(0.),
64 m_kltHarrisParam(0.), m_kltBlockSize(0), m_kltPyramidLevels(0),
67 m_depthNormalPclPlaneEstimationMethod(2), m_depthNormalPclPlaneEstimationRansacMaxIter(200),
68 m_depthNormalPclPlaneEstimationRansacThreshold(0.001), m_depthNormalSamplingStepX(2), m_depthNormalSamplingStepY(2),
70 m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2),
72 m_projectionErrorMe(), m_projectionErrorKernelSize(2),
78 void parse(
const std::string &filename)
80 pugi::xml_document doc;
81 if (!doc.load_file(filename.c_str())) {
85 bool camera_node =
false;
86 bool face_node =
false;
87 bool ecm_node =
false;
88 bool klt_node =
false;
89 bool lod_node =
false;
90 bool depth_normal_node =
false;
91 bool depth_dense_node =
false;
92 bool projection_error_node =
false;
94 pugi::xml_node root_node = doc.document_element();
95 for (pugi::xml_node dataNode = root_node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
96 if (dataNode.type() == pugi::node_element) {
97 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
98 if (iter_data != m_nodeMap.end()) {
99 switch (iter_data->second) {
102 read_camera(dataNode);
130 read_sample_deprecated(dataNode);
142 read_depth_normal(dataNode);
143 depth_normal_node =
true;
149 read_depth_dense(dataNode);
150 depth_dense_node =
true;
154 case projection_error:
156 read_projection_error(dataNode);
157 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;
239 void read_camera(
const pugi::xml_node &node)
241 bool u0_node =
false;
242 bool v0_node =
false;
243 bool px_node =
false;
244 bool py_node =
false;
247 double d_u0 = m_cam.get_u0();
248 double d_v0 = m_cam.get_v0();
249 double d_px = m_cam.get_px();
250 double d_py = m_cam.get_py();
252 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
253 if (dataNode.type() == pugi::node_element) {
254 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
255 if (iter_data != m_nodeMap.end()) {
256 switch (iter_data->second) {
258 d_u0 = dataNode.text().as_double();
263 d_v0 = dataNode.text().as_double();
268 d_px = dataNode.text().as_double();
273 d_py = dataNode.text().as_double();
284 m_cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0);
287 std::cout <<
"camera : u0 : " << m_cam.get_u0() <<
" (default)" << std::endl;
289 std::cout <<
"camera : u0 : " << m_cam.get_u0() << std::endl;
292 std::cout <<
"camera : v0 : " << m_cam.get_v0() <<
" (default)" << std::endl;
294 std::cout <<
"camera : v0 : " << m_cam.get_v0() << std::endl;
297 std::cout <<
"camera : px : " << m_cam.get_px() <<
" (default)" << std::endl;
299 std::cout <<
"camera : px : " << m_cam.get_px() << std::endl;
302 std::cout <<
"camera : py : " << m_cam.get_py() <<
" (default)" << std::endl;
304 std::cout <<
"camera : py : " << m_cam.get_py() << std::endl;
312 void read_depth_normal(
const pugi::xml_node &node)
314 bool feature_estimation_method_node =
false;
315 bool PCL_plane_estimation_node =
false;
316 bool sampling_step_node =
false;
318 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
319 if (dataNode.type() == pugi::node_element) {
320 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
321 if (iter_data != m_nodeMap.end()) {
322 switch (iter_data->second) {
323 case feature_estimation_method:
324 m_depthNormalFeatureEstimationMethod =
326 feature_estimation_method_node =
true;
329 case PCL_plane_estimation:
330 read_depth_normal_PCL(dataNode);
331 PCL_plane_estimation_node =
true;
334 case depth_sampling_step:
335 read_depth_normal_sampling_step(dataNode);
336 sampling_step_node =
true;
346 if (!feature_estimation_method_node)
347 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod <<
" (default)"
350 std::cout <<
"depth normal : feature_estimation_method : " << m_depthNormalFeatureEstimationMethod << std::endl;
352 if (!PCL_plane_estimation_node) {
353 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
354 <<
" (default)" << std::endl;
355 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
356 <<
" (default)" << std::endl;
357 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
358 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
361 if (!sampling_step_node) {
362 std::cout <<
"depth normal : sampling_step : step_X " << m_depthNormalSamplingStepX <<
" (default)" << std::endl;
363 std::cout <<
"depth normal : sampling_step : step_Y " << m_depthNormalSamplingStepY <<
" (default)" << std::endl;
372 void read_depth_normal_PCL(
const pugi::xml_node &node)
374 bool PCL_plane_estimation_method_node =
false;
375 bool PCL_plane_estimation_ransac_max_iter_node =
false;
376 bool PCL_plane_estimation_ransac_threshold_node =
false;
378 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
379 if (dataNode.type() == pugi::node_element) {
380 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
381 if (iter_data != m_nodeMap.end()) {
382 switch (iter_data->second) {
383 case PCL_plane_estimation_method:
384 m_depthNormalPclPlaneEstimationMethod = dataNode.text().as_int();
385 PCL_plane_estimation_method_node =
true;
388 case PCL_plane_estimation_ransac_max_iter:
389 m_depthNormalPclPlaneEstimationRansacMaxIter = dataNode.text().as_int();
390 PCL_plane_estimation_ransac_max_iter_node =
true;
393 case PCL_plane_estimation_ransac_threshold:
394 m_depthNormalPclPlaneEstimationRansacThreshold = dataNode.text().as_double();
395 PCL_plane_estimation_ransac_threshold_node =
true;
405 if (!PCL_plane_estimation_method_node)
406 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
407 <<
" (default)" << std::endl;
409 std::cout <<
"depth normal : PCL_plane_estimation : method : " << m_depthNormalPclPlaneEstimationMethod
412 if (!PCL_plane_estimation_ransac_max_iter_node)
413 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
414 <<
" (default)" << std::endl;
416 std::cout <<
"depth normal : PCL_plane_estimation : max_iter : " << m_depthNormalPclPlaneEstimationRansacMaxIter
419 if (!PCL_plane_estimation_ransac_threshold_node)
420 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
421 << m_depthNormalPclPlaneEstimationRansacThreshold <<
" (default)" << std::endl;
423 std::cout <<
"depth normal : PCL_plane_estimation : ransac_threshold : "
424 << m_depthNormalPclPlaneEstimationRansacThreshold << std::endl;
432 void read_depth_normal_sampling_step(
const pugi::xml_node &node)
434 bool sampling_step_X_node =
false;
435 bool sampling_step_Y_node =
false;
437 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
438 if (dataNode.type() == pugi::node_element) {
439 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
440 if (iter_data != m_nodeMap.end()) {
441 switch (iter_data->second) {
442 case depth_sampling_step_X:
443 m_depthNormalSamplingStepX = dataNode.text().as_uint();
444 sampling_step_X_node =
true;
447 case depth_sampling_step_Y:
448 m_depthNormalSamplingStepY = dataNode.text().as_uint();
449 sampling_step_Y_node =
true;
459 if (!sampling_step_X_node)
460 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX <<
" (default)" << std::endl;
462 std::cout <<
"depth normal : sampling_step : step_X : " << m_depthNormalSamplingStepX << std::endl;
464 if (!sampling_step_Y_node)
465 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY <<
" (default)" << std::endl;
467 std::cout <<
"depth normal : sampling_step : step_Y : " << m_depthNormalSamplingStepY << std::endl;
475 void read_depth_dense(
const pugi::xml_node &node)
477 bool sampling_step_node =
false;
479 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
480 if (dataNode.type() == pugi::node_element) {
481 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
482 if (iter_data != m_nodeMap.end()) {
483 switch (iter_data->second) {
484 case depth_dense_sampling_step:
485 read_depth_dense_sampling_step(dataNode);
486 sampling_step_node =
true;
496 if (!sampling_step_node) {
497 std::cout <<
"depth dense : sampling_step : step_X " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
498 std::cout <<
"depth dense : sampling_step : step_Y " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
507 void read_depth_dense_sampling_step(
const pugi::xml_node &node)
509 bool sampling_step_X_node =
false;
510 bool sampling_step_Y_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_X:
518 m_depthDenseSamplingStepX = dataNode.text().as_uint();
519 sampling_step_X_node =
true;
522 case depth_dense_sampling_step_Y:
523 m_depthDenseSamplingStepY = dataNode.text().as_uint();
524 sampling_step_Y_node =
true;
534 if (!sampling_step_X_node)
535 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX <<
" (default)" << std::endl;
537 std::cout <<
"depth dense : sampling_step : step_X : " << m_depthDenseSamplingStepX << std::endl;
539 if (!sampling_step_Y_node)
540 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY <<
" (default)" << std::endl;
542 std::cout <<
"depth dense : sampling_step : step_Y : " << m_depthDenseSamplingStepY << std::endl;
550 void read_ecm(
const pugi::xml_node &node)
552 bool mask_node =
false;
553 bool range_node =
false;
554 bool contrast_node =
false;
555 bool sample_node =
false;
557 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
558 if (dataNode.type() == pugi::node_element) {
559 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
560 if (iter_data != m_nodeMap.end()) {
561 switch (iter_data->second) {
563 read_ecm_mask(dataNode);
568 read_ecm_range(dataNode);
573 read_ecm_contrast(dataNode);
574 contrast_node =
true;
578 read_ecm_sample(dataNode);
590 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
591 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
595 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
598 if (!contrast_node) {
599 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
600 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
601 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
605 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
614 void read_ecm_contrast(
const pugi::xml_node &node)
616 bool edge_threshold_node =
false;
617 bool mu1_node =
false;
618 bool mu2_node =
false;
621 double d_edge_threshold = m_ecm.getThreshold();
622 double d_mu1 = m_ecm.getMu1();
623 double d_mu2 = m_ecm.getMu2();
625 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
626 if (dataNode.type() == pugi::node_element) {
627 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
628 if (iter_data != m_nodeMap.end()) {
629 switch (iter_data->second) {
631 d_edge_threshold = dataNode.text().as_double();
632 edge_threshold_node =
true;
636 d_mu1 = dataNode.text().as_double();
641 d_mu2 = dataNode.text().as_double();
654 m_ecm.setThreshold(d_edge_threshold);
656 if (!edge_threshold_node)
657 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() <<
" (default)" << std::endl;
659 std::cout <<
"ecm : contrast : threshold " << m_ecm.getThreshold() << std::endl;
662 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() <<
" (default)" << std::endl;
664 std::cout <<
"ecm : contrast : mu1 " << m_ecm.getMu1() << std::endl;
667 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() <<
" (default)" << std::endl;
669 std::cout <<
"ecm : contrast : mu2 " << m_ecm.getMu2() << std::endl;
677 void read_ecm_mask(
const pugi::xml_node &node)
679 bool size_node =
false;
680 bool nb_mask_node =
false;
683 unsigned int d_size = m_ecm.getMaskSize();
684 unsigned int d_nb_mask = m_ecm.getMaskNumber();
686 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
687 if (dataNode.type() == pugi::node_element) {
688 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
689 if (iter_data != m_nodeMap.end()) {
690 switch (iter_data->second) {
692 d_size = dataNode.text().as_uint();
697 d_nb_mask = dataNode.text().as_uint();
708 m_ecm.setMaskSize(d_size);
713 "parameter should be different "
714 "from zero in xml file"));
715 m_ecm.setMaskNumber(d_nb_mask);
718 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() <<
" (default)" << std::endl;
720 std::cout <<
"ecm : mask : size : " << m_ecm.getMaskSize() << std::endl;
723 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() <<
" (default)" << std::endl;
725 std::cout <<
"ecm : mask : nb_mask : " << m_ecm.getMaskNumber() << std::endl;
733 void read_ecm_range(
const pugi::xml_node &node)
735 bool tracking_node =
false;
738 unsigned int m_range_tracking = m_ecm.getRange();
740 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
741 if (dataNode.type() == pugi::node_element) {
742 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
743 if (iter_data != m_nodeMap.end()) {
744 switch (iter_data->second) {
746 m_range_tracking = dataNode.text().as_uint();
747 tracking_node =
true;
757 m_ecm.setRange(m_range_tracking);
760 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() <<
" (default)" << std::endl;
762 std::cout <<
"ecm : range : tracking : " << m_ecm.getRange() << std::endl;
770 void read_ecm_sample(
const pugi::xml_node &node)
772 bool step_node =
false;
775 double d_stp = m_ecm.getSampleStep();
777 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
778 if (dataNode.type() == pugi::node_element) {
779 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
780 if (iter_data != m_nodeMap.end()) {
781 switch (iter_data->second) {
783 d_stp = dataNode.text().as_int();
794 m_ecm.setSampleStep(d_stp);
797 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
799 std::cout <<
"ecm : sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
807 void read_face(
const pugi::xml_node &node)
809 bool angle_appear_node =
false;
810 bool angle_disappear_node =
false;
811 bool near_clipping_node =
false;
812 bool far_clipping_node =
false;
813 bool fov_clipping_node =
false;
814 m_hasNearClipping =
false;
815 m_hasFarClipping =
false;
817 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
818 if (dataNode.type() == pugi::node_element) {
819 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
820 if (iter_data != m_nodeMap.end()) {
821 switch (iter_data->second) {
823 m_angleAppear = dataNode.text().as_double();
824 angle_appear_node =
true;
827 case angle_disappear:
828 m_angleDisappear = dataNode.text().as_double();
829 angle_disappear_node =
true;
833 m_nearClipping = dataNode.text().as_double();
834 m_hasNearClipping =
true;
835 near_clipping_node =
true;
839 m_farClipping = dataNode.text().as_double();
840 m_hasFarClipping =
true;
841 far_clipping_node =
true;
845 if (dataNode.text().as_int())
846 m_fovClipping =
true;
848 m_fovClipping =
false;
849 fov_clipping_node =
true;
859 if (!angle_appear_node)
860 std::cout <<
"face : Angle Appear : " << m_angleAppear <<
" (default)" << std::endl;
862 std::cout <<
"face : Angle Appear : " << m_angleAppear << std::endl;
864 if (!angle_disappear_node)
865 std::cout <<
"face : Angle Disappear : " << m_angleDisappear <<
" (default)" << std::endl;
867 std::cout <<
"face : Angle Disappear : " << m_angleDisappear << std::endl;
869 if (near_clipping_node)
870 std::cout <<
"face : Near Clipping : " << m_nearClipping << std::endl;
872 if (far_clipping_node)
873 std::cout <<
"face : Far Clipping : " << m_farClipping << std::endl;
875 if (fov_clipping_node) {
877 std::cout <<
"face : Fov Clipping : True" << std::endl;
879 std::cout <<
"face : Fov Clipping : False" << std::endl;
888 void read_klt(
const pugi::xml_node &node)
890 bool mask_border_node =
false;
891 bool max_features_node =
false;
892 bool window_size_node =
false;
893 bool quality_node =
false;
894 bool min_distance_node =
false;
895 bool harris_node =
false;
896 bool size_block_node =
false;
897 bool pyramid_lvl_node =
false;
899 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
900 if (dataNode.type() == pugi::node_element) {
901 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
902 if (iter_data != m_nodeMap.end()) {
903 switch (iter_data->second) {
905 m_kltMaskBorder = dataNode.text().as_uint();
906 mask_border_node =
true;
910 m_kltMaxFeatures = dataNode.text().as_uint();
911 max_features_node =
true;
915 m_kltWinSize = dataNode.text().as_uint();
916 window_size_node =
true;
920 m_kltQualityValue = dataNode.text().as_double();
925 m_kltMinDist = dataNode.text().as_double();
926 min_distance_node =
true;
930 m_kltHarrisParam = dataNode.text().as_double();
935 m_kltBlockSize = dataNode.text().as_uint();
936 size_block_node =
true;
940 m_kltPyramidLevels = dataNode.text().as_uint();
941 pyramid_lvl_node =
true;
951 if (!mask_border_node)
952 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder <<
" (default)" << std::endl;
954 std::cout <<
"klt : Mask Border : " << m_kltMaskBorder << std::endl;
956 if (!max_features_node)
957 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures <<
" (default)" << std::endl;
959 std::cout <<
"klt : Max Features : " << m_kltMaxFeatures << std::endl;
961 if (!window_size_node)
962 std::cout <<
"klt : Windows Size : " << m_kltWinSize <<
" (default)" << std::endl;
964 std::cout <<
"klt : Windows Size : " << m_kltWinSize << std::endl;
967 std::cout <<
"klt : Quality : " << m_kltQualityValue <<
" (default)" << std::endl;
969 std::cout <<
"klt : Quality : " << m_kltQualityValue << std::endl;
971 if (!min_distance_node)
972 std::cout <<
"klt : Min Distance : " << m_kltMinDist <<
" (default)" << std::endl;
974 std::cout <<
"klt : Min Distance : " << m_kltMinDist << std::endl;
977 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam <<
" (default)" << std::endl;
979 std::cout <<
"klt : Harris Parameter : " << m_kltHarrisParam << std::endl;
981 if (!size_block_node)
982 std::cout <<
"klt : Block Size : " << m_kltBlockSize <<
" (default)" << std::endl;
984 std::cout <<
"klt : Block Size : " << m_kltBlockSize << std::endl;
986 if (!pyramid_lvl_node)
987 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels <<
" (default)" << std::endl;
989 std::cout <<
"klt : Pyramid Levels : " << m_kltPyramidLevels << std::endl;
992 void read_lod(
const pugi::xml_node &node)
994 bool use_lod_node =
false;
995 bool min_line_length_threshold_node =
false;
996 bool min_polygon_area_threshold_node =
false;
998 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
999 if (dataNode.type() == pugi::node_element) {
1000 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1001 if (iter_data != m_nodeMap.end()) {
1002 switch (iter_data->second) {
1004 m_useLod = (dataNode.text().as_int() != 0);
1005 use_lod_node =
true;
1008 case min_line_length_threshold:
1009 m_minLineLengthThreshold = dataNode.text().as_double();
1010 min_line_length_threshold_node =
true;
1013 case min_polygon_area_threshold:
1014 m_minPolygonAreaThreshold = dataNode.text().as_double();
1015 min_polygon_area_threshold_node =
true;
1026 std::cout <<
"lod : use lod : " << m_useLod <<
" (default)" << std::endl;
1028 std::cout <<
"lod : use lod : " << m_useLod << std::endl;
1030 if (!min_line_length_threshold_node)
1031 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold <<
" (default)" << std::endl;
1033 std::cout <<
"lod : min line length threshold : " << m_minLineLengthThreshold << std::endl;
1035 if (!min_polygon_area_threshold_node)
1036 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold <<
" (default)" << std::endl;
1038 std::cout <<
"lod : min polygon area threshold : " << m_minPolygonAreaThreshold << std::endl;
1041 void read_projection_error(
const pugi::xml_node &node)
1043 bool step_node =
false;
1044 bool kernel_size_node =
false;
1047 double d_stp = m_projectionErrorMe.getSampleStep();
1048 std::string kernel_size_str;
1050 for (pugi::xml_node dataNode = node.first_child(); dataNode; dataNode = dataNode.next_sibling()) {
1051 if (dataNode.type() == pugi::node_element) {
1052 std::map<std::string, int>::const_iterator iter_data = m_nodeMap.find(dataNode.name());
1053 if (iter_data != m_nodeMap.end()) {
1054 switch (iter_data->second) {
1055 case projection_error_sample_step:
1056 d_stp = dataNode.text().as_int();
1060 case projection_error_kernel_size:
1061 kernel_size_str = dataNode.text().as_string();
1062 kernel_size_node =
true;
1072 m_projectionErrorMe.setSampleStep(d_stp);
1074 if (kernel_size_str ==
"3x3") {
1075 m_projectionErrorKernelSize = 1;
1076 }
else if (kernel_size_str ==
"5x5") {
1077 m_projectionErrorKernelSize = 2;
1078 }
else if (kernel_size_str ==
"7x7") {
1079 m_projectionErrorKernelSize = 3;
1080 }
else if (kernel_size_str ==
"9x9") {
1081 m_projectionErrorKernelSize = 4;
1082 }
else if (kernel_size_str ==
"11x11") {
1083 m_projectionErrorKernelSize = 5;
1084 }
else if (kernel_size_str ==
"13x13") {
1085 m_projectionErrorKernelSize = 6;
1086 }
else if (kernel_size_str ==
"15x15") {
1087 m_projectionErrorKernelSize = 7;
1089 std::cerr <<
"Unsupported kernel size." << std::endl;
1093 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() <<
" (default)" << std::endl;
1095 std::cout <<
"projection_error : sample_step : " << m_projectionErrorMe.getSampleStep() << std::endl;
1097 if (!kernel_size_node)
1098 std::cout <<
"projection_error : kernel_size : " << m_projectionErrorKernelSize*2+1 <<
"x"
1099 << m_projectionErrorKernelSize*2+1 <<
" (default)" << std::endl;
1101 std::cout <<
"projection_error : kernel_size : " << kernel_size_str << std::endl;
1109 void read_sample_deprecated(
const pugi::xml_node &node)
1111 bool step_node =
false;
1115 double d_stp = m_ecm.getSampleStep();
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) {
1123 d_stp = dataNode.text().as_int();
1134 m_ecm.setSampleStep(d_stp);
1137 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() <<
" (default)" << std::endl;
1139 std::cout <<
"[DEPRECATED] sample : sample_step : " << m_ecm.getSampleStep() << std::endl;
1141 std::cout <<
" WARNING : This node (sample) is deprecated." << std::endl;
1142 std::cout <<
" It should be moved in the ecm node (ecm : sample)." << std::endl;
1150 void getEdgeMe(
vpMe &moving_edge)
const { moving_edge = m_ecm; }
1157 return m_depthNormalFeatureEstimationMethod;
1162 return m_depthNormalPclPlaneEstimationRansacMaxIter;
1166 return m_depthNormalPclPlaneEstimationRansacThreshold;
1195 void setAngleAppear(
const double &aappear) { m_angleAppear = aappear; }
1196 void setAngleDisappear(
const double &adisappear) { m_angleDisappear = adisappear; }
1204 m_depthNormalFeatureEstimationMethod = method;
1208 m_depthNormalPclPlaneEstimationMethod = method;
1212 m_depthNormalPclPlaneEstimationRansacMaxIter = maxIter;
1216 m_depthNormalPclPlaneEstimationRansacThreshold = threshold;
1221 void setEdgeMe(
const vpMe &moving_edge) { m_ecm = moving_edge; }
1231 void setKltQuality(
const double &q) { m_kltQualityValue = q; }
1245 double m_angleAppear;
1247 double m_angleDisappear;
1249 bool m_hasNearClipping;
1251 double m_nearClipping;
1253 bool m_hasFarClipping;
1255 double m_farClipping;
1262 double m_minLineLengthThreshold;
1264 double m_minPolygonAreaThreshold;
1270 unsigned int m_kltMaskBorder;
1272 unsigned int m_kltMaxFeatures;
1274 unsigned int m_kltWinSize;
1276 double m_kltQualityValue;
1278 double m_kltMinDist;
1280 double m_kltHarrisParam;
1282 unsigned int m_kltBlockSize;
1284 unsigned int m_kltPyramidLevels;
1289 int m_depthNormalPclPlaneEstimationMethod;
1291 int m_depthNormalPclPlaneEstimationRansacMaxIter;
1293 double m_depthNormalPclPlaneEstimationRansacThreshold;
1295 unsigned int m_depthNormalSamplingStepX;
1297 unsigned int m_depthNormalSamplingStepY;
1300 unsigned int m_depthDenseSamplingStepX;
1302 unsigned int m_depthDenseSamplingStepY;
1305 vpMe m_projectionErrorMe;
1307 unsigned int m_projectionErrorKernelSize;
1308 std::map<std::string, int> m_nodeMap;
1310 enum vpDataToParseMb {
1330 min_line_length_threshold,
1331 min_polygon_area_threshold,
1357 feature_estimation_method,
1358 PCL_plane_estimation,
1359 PCL_plane_estimation_method,
1360 PCL_plane_estimation_ransac_max_iter,
1361 PCL_plane_estimation_ransac_threshold,
1362 depth_sampling_step,
1363 depth_sampling_step_X,
1364 depth_sampling_step_Y,
1367 depth_dense_sampling_step,
1368 depth_dense_sampling_step_X,
1369 depth_dense_sampling_step_Y,
1372 projection_error_sample_step,
1373 projection_error_kernel_size
1382 m_nodeMap[
"conf"] = conf;
1384 m_nodeMap[
"face"] = face;
1385 m_nodeMap[
"angle_appear"] = angle_appear;
1386 m_nodeMap[
"angle_disappear"] = angle_disappear;
1387 m_nodeMap[
"near_clipping"] = near_clipping;
1388 m_nodeMap[
"far_clipping"] = far_clipping;
1389 m_nodeMap[
"fov_clipping"] = fov_clipping;
1391 m_nodeMap[
"camera"] = camera;
1392 m_nodeMap[
"height"] = height;
1393 m_nodeMap[
"width"] = width;
1394 m_nodeMap[
"u0"] = u0;
1395 m_nodeMap[
"v0"] = v0;
1396 m_nodeMap[
"px"] = px;
1397 m_nodeMap[
"py"] = py;
1399 m_nodeMap[
"lod"] = lod;
1400 m_nodeMap[
"use_lod"] = use_lod;
1401 m_nodeMap[
"min_line_length_threshold"] = min_line_length_threshold;
1402 m_nodeMap[
"min_polygon_area_threshold"] = min_polygon_area_threshold;
1404 m_nodeMap[
"ecm"] = ecm;
1405 m_nodeMap[
"mask"] = mask;
1406 m_nodeMap[
"size"] = size;
1407 m_nodeMap[
"nb_mask"] = nb_mask;
1408 m_nodeMap[
"range"] = range;
1409 m_nodeMap[
"tracking"] = tracking;
1410 m_nodeMap[
"contrast"] = contrast;
1411 m_nodeMap[
"edge_threshold"] = edge_threshold;
1412 m_nodeMap[
"mu1"] = mu1;
1413 m_nodeMap[
"mu2"] = mu2;
1414 m_nodeMap[
"sample"] = sample;
1415 m_nodeMap[
"step"] = step;
1417 m_nodeMap[
"klt"] = klt;
1418 m_nodeMap[
"mask_border"] = mask_border;
1419 m_nodeMap[
"max_features"] = max_features;
1420 m_nodeMap[
"window_size"] = window_size;
1421 m_nodeMap[
"quality"] = quality;
1422 m_nodeMap[
"min_distance"] = min_distance;
1423 m_nodeMap[
"harris"] = harris;
1424 m_nodeMap[
"size_block"] = size_block;
1425 m_nodeMap[
"pyramid_lvl"] = pyramid_lvl;
1427 m_nodeMap[
"depth_normal"] = depth_normal;
1428 m_nodeMap[
"feature_estimation_method"] = feature_estimation_method;
1429 m_nodeMap[
"PCL_plane_estimation"] = PCL_plane_estimation;
1430 m_nodeMap[
"method"] = PCL_plane_estimation_method;
1431 m_nodeMap[
"ransac_max_iter"] = PCL_plane_estimation_ransac_max_iter;
1432 m_nodeMap[
"ransac_threshold"] = PCL_plane_estimation_ransac_threshold;
1433 m_nodeMap[
"sampling_step"] = depth_sampling_step;
1434 m_nodeMap[
"step_X"] = depth_sampling_step_X;
1435 m_nodeMap[
"step_Y"] = depth_sampling_step_Y;
1437 m_nodeMap[
"depth_dense"] = depth_dense;
1438 m_nodeMap[
"sampling_step"] = depth_dense_sampling_step;
1439 m_nodeMap[
"step_X"] = depth_dense_sampling_step_X;
1440 m_nodeMap[
"step_Y"] = depth_dense_sampling_step_Y;
1442 m_nodeMap[
"projection_error"] = projection_error;
1443 m_nodeMap[
"sample_step"] = projection_error_sample_step;
1444 m_nodeMap[
"kernel_size"] = projection_error_kernel_size;
1447 #endif // DOXYGEN_SHOULD_SKIP_THIS
1455 if (std::setlocale(LC_ALL,
"C") == NULL) {
1456 std::cerr <<
"Cannot set locale to C" << std::endl;
1472 m_impl->parse(filename);
1480 return m_impl->getAngleAppear();
1488 return m_impl->getAngleDisappear();
1493 m_impl->getCameraParameters(cam);
1501 m_impl->getEdgeMe(ecm);
1509 return m_impl->getDepthDenseSamplingStepX();
1517 return m_impl->getDepthDenseSamplingStepY();
1525 return m_impl->getDepthNormalFeatureEstimationMethod();
1533 return m_impl->getDepthNormalPclPlaneEstimationMethod();
1541 return m_impl->getDepthNormalPclPlaneEstimationRansacMaxIter();
1549 return m_impl->getDepthNormalPclPlaneEstimationRansacThreshold();
1557 return m_impl->getDepthNormalSamplingStepX();
1565 return m_impl->getDepthNormalSamplingStepY();
1573 return m_impl->getFarClippingDistance();
1581 return m_impl->getFovClipping();
1589 return m_impl->getKltBlockSize();
1597 return m_impl->getKltHarrisParam();
1605 return m_impl->getKltMaskBorder();
1613 return m_impl->getKltMaxFeatures();
1621 return m_impl->getKltMinDistance();
1629 return m_impl->getKltPyramidLevels();
1637 return m_impl->getKltQuality();
1645 return m_impl->getKltWindowSize();
1653 return m_impl->getLodState();
1661 return m_impl->getLodMinLineLengthThreshold();
1669 return m_impl->getLodMinPolygonAreaThreshold();
1677 return m_impl->getNearClippingDistance();
1685 m_impl->getProjectionErrorMe(me);
1690 return m_impl->getProjectionErrorKernelSize();
1700 return m_impl->hasFarClippingDistance();
1710 return m_impl->hasNearClippingDistance();
1720 m_impl->setAngleAppear(aappear);
1730 m_impl->setAngleDisappear(adisappear);
1740 m_impl->setCameraParameters(cam);
1750 m_impl->setDepthDenseSamplingStepX(stepX);
1760 m_impl->setDepthDenseSamplingStepY(stepY);
1770 m_impl->setDepthNormalFeatureEstimationMethod(method);
1780 m_impl->setDepthNormalPclPlaneEstimationMethod(method);
1790 m_impl->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
1800 m_impl->setDepthNormalPclPlaneEstimationRansacThreshold(threshold);
1810 m_impl->setDepthNormalSamplingStepX(stepX);
1820 m_impl->setDepthNormalSamplingStepY(stepY);
1830 m_impl->setEdgeMe(ecm);
1840 m_impl->setFarClippingDistance(fclip);
1850 m_impl->setKltBlockSize(bs);
1860 m_impl->setKltHarrisParam(hp);
1870 m_impl->setKltMaskBorder(mb);
1880 m_impl->setKltMaxFeatures(mF);
1890 m_impl->setKltMinDistance(mD);
1900 m_impl->setKltPyramidLevels(pL);
1910 m_impl->setKltQuality(q);
1920 m_impl->setKltWindowSize(w);
1930 m_impl->setNearClippingDistance(nclip);
1940 m_impl->setProjectionErrorMe(me);
1950 m_impl->setProjectionErrorKernelSize(size);
1953 #elif !defined(VISP_BUILD_SHARED_LIBS)
1956 void dummy_vpMbtXmlGenericParser(){};