49 #include <visp3/vision/vpXmlConfigParserKeyPoint.h> 54 : m_detectorName(
"ORB"), m_extractorName(
"ORB"), m_matcherName(
"BruteForce-Hamming"), m_matchingFactorThreshold(2.0),
55 m_matchingMethod(ratioDistanceThreshold), m_matchingRatioThreshold(0.85), m_nbRansacIterations(200),
56 m_nbRansacMinInlierCount(100), m_ransacConsensusPercentage(20.0), m_ransacReprojectionError(6.0),
57 m_ransacThreshold(0.01), m_useRansacConsensusPercentage(false), m_useRansacVVS(true)
65 void vpXmlConfigParserKeyPoint::init()
105 void vpXmlConfigParserKeyPoint::readMainClass(xmlDocPtr doc, xmlNodePtr node)
107 bool detector_node =
false;
108 bool extractor_node =
false;
109 bool matcher_node =
false;
111 for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
112 if (dataNode->type == XML_ELEMENT_NODE) {
113 std::map<std::string, int>::iterator iter_data = this->
nodeMap.find((
char *)dataNode->name);
114 if (iter_data !=
nodeMap.end()) {
115 switch (iter_data->second) {
117 this->read_detector(doc, dataNode);
118 detector_node =
true;
122 this->read_extractor(doc, dataNode);
123 extractor_node =
true;
127 this->read_matcher(doc, dataNode);
132 this->read_ransac(doc, dataNode);
142 if (!detector_node) {
143 std::cout <<
"detector: name: " << m_detectorName <<
" (default)" << std::endl;
146 if (!extractor_node) {
147 std::cout <<
"extractor: name: " << m_extractorName <<
" (default)" << std::endl;
151 std::cout <<
"matcher: name: " << m_matcherName <<
" (default)" << std::endl;
161 void vpXmlConfigParserKeyPoint::read_detector(xmlDocPtr doc, xmlNodePtr node)
163 bool detector_name_node =
false;
165 for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
166 if (dataNode->type == XML_ELEMENT_NODE) {
167 std::map<std::string, int>::iterator iter_data = this->
nodeMap.find((
char *)dataNode->name);
168 if (iter_data !=
nodeMap.end()) {
169 switch (iter_data->second) {
172 detector_name_node =
true;
182 if (!detector_name_node)
183 std::cout <<
"detector : Name : " << m_detectorName <<
" (default)" << std::endl;
185 std::cout <<
"detector : Name : " << m_detectorName << std::endl;
194 void vpXmlConfigParserKeyPoint::read_extractor(xmlDocPtr doc, xmlNodePtr node)
196 bool extractor_name_node =
false;
198 for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
199 if (dataNode->type == XML_ELEMENT_NODE) {
200 std::map<std::string, int>::iterator iter_data = this->
nodeMap.find((
char *)dataNode->name);
201 if (iter_data !=
nodeMap.end()) {
202 switch (iter_data->second) {
205 extractor_name_node =
true;
215 if (!extractor_name_node)
216 std::cout <<
"extractor : Name : " << m_extractorName <<
" (default)" << std::endl;
218 std::cout <<
"extractor : Name : " << m_extractorName << std::endl;
227 void vpXmlConfigParserKeyPoint::read_matcher(xmlDocPtr doc, xmlNodePtr node)
229 bool matcher_name_node =
false;
230 bool matching_method_node =
false;
231 std::string matchingMethodName =
"ratioDistanceThreshold";
232 bool matching_factor_threshold_node =
false;
233 bool matching_ratio_threshold_node =
false;
235 for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
236 if (dataNode->type == XML_ELEMENT_NODE) {
237 std::map<std::string, int>::iterator iter_data = this->
nodeMap.find((
char *)dataNode->name);
238 if (iter_data !=
nodeMap.end()) {
239 switch (iter_data->second) {
242 matcher_name_node =
true;
248 std::map<std::string, int>::iterator iter_data2 =
nodeMap.find(matchingMethodName);
249 if (iter_data2 !=
nodeMap.end()) {
250 matching_method_node =
true;
251 switch (iter_data2->second) {
273 matching_method_node =
false;
282 matching_factor_threshold_node =
true;
287 matching_ratio_threshold_node =
true;
297 if (!matcher_name_node)
298 std::cout <<
"matcher : Name : " << m_matcherName <<
" (default)" << std::endl;
300 std::cout <<
"matcher : Name : " << m_matcherName << std::endl;
302 if (!matching_method_node)
303 std::cout <<
"matcher : Filter method : " << matchingMethodName <<
" (default)" << std::endl;
305 std::cout <<
"matcher : Filter method : " << matchingMethodName << std::endl;
307 if (!matching_factor_threshold_node)
308 std::cout <<
"matcher : matching factor threshold : " << m_matchingFactorThreshold <<
" (default)" << std::endl;
310 std::cout <<
"matcher : matching factor threshold : " << m_matchingFactorThreshold << std::endl;
312 if (!matching_ratio_threshold_node)
313 std::cout <<
"matcher : matching ratio threshold : " << m_matchingRatioThreshold <<
" (default)" << std::endl;
315 std::cout <<
"matcher : matching ratio threshold : " << m_matchingRatioThreshold << std::endl;
324 void vpXmlConfigParserKeyPoint::read_ransac(xmlDocPtr doc, xmlNodePtr node)
326 bool use_ransac_vvs_node =
false;
327 bool use_ransac_consensus_percentage_node =
false;
328 bool nb_ransac_iterations_node =
false;
329 bool ransac_reprojection_error_node =
false;
330 bool nb_ransac_min_inlier_count_node =
false;
331 bool ransac_threshold_node =
false;
332 bool ransac_consensus_percentage_node =
false;
334 for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
335 if (dataNode->type == XML_ELEMENT_NODE) {
336 std::map<std::string, int>::iterator iter_data = this->
nodeMap.find((
char *)dataNode->name);
337 if (iter_data !=
nodeMap.end()) {
338 switch (iter_data->second) {
341 use_ransac_vvs_node =
true;
346 use_ransac_consensus_percentage_node =
true;
351 nb_ransac_iterations_node =
true;
356 ransac_reprojection_error_node =
true;
361 nb_ransac_min_inlier_count_node =
true;
366 ransac_threshold_node =
true;
371 ransac_consensus_percentage_node =
true;
381 if (!use_ransac_vvs_node)
382 std::cout <<
"ransac: use ransac vvs pose estimation: " << m_useRansacVVS <<
" (default)" << std::endl;
384 std::cout <<
"ransac: use ransac vvs pose estimation: " << m_useRansacVVS << std::endl;
386 if (!use_ransac_consensus_percentage_node)
387 std::cout <<
"ransac: use consensus percentage: " << m_useRansacConsensusPercentage <<
" (default)" << std::endl;
389 std::cout <<
"ransac: use consensus percentage: " << m_useRansacConsensusPercentage << std::endl;
391 if (!nb_ransac_iterations_node)
392 std::cout <<
"ransac: nb ransac iterations: " << m_nbRansacIterations <<
" (default)" << std::endl;
394 std::cout <<
"ransac: nb ransac iterations: " << m_nbRansacIterations << std::endl;
396 if (!ransac_reprojection_error_node)
397 std::cout <<
"ransac: ransac reprojection error in pixel (for OpenCV " 399 << m_ransacReprojectionError <<
" (default)" << std::endl;
401 std::cout <<
"ransac: ransac reprojection error in pixel (for OpenCV " 403 << m_ransacReprojectionError << std::endl;
405 if (!nb_ransac_min_inlier_count_node)
406 std::cout <<
"ransac: nb ransac min inlier count: " << m_nbRansacMinInlierCount <<
" (default)" << std::endl;
408 std::cout <<
"ransac: nb ransac min inlier count: " << m_nbRansacMinInlierCount << std::endl;
410 if (!ransac_threshold_node)
411 std::cout <<
"ransac: ransac threshold in meter (for ViSP function): " << m_ransacThreshold <<
" (default)" 414 std::cout <<
"ransac: ransac threshold in meter (for ViSP function): " << m_ransacThreshold << std::endl;
416 if (!ransac_consensus_percentage_node)
417 std::cout <<
"ransac: consensus percentage: " << m_ransacConsensusPercentage <<
" (default)" << std::endl;
419 std::cout <<
"ransac: consensus percentage: " << m_ransacConsensusPercentage << std::endl;
422 #elif !defined(VISP_BUILD_SHARED_LIBS) 425 void dummy_vpXmlConfigParserKeyPoint(){};
426 #endif // VISP_HAVE_XML2
void setMainTag(const std::string &tag)
double xmlReadDoubleChild(xmlDocPtr doc, xmlNodePtr node)
int xmlReadIntChild(xmlDocPtr doc, xmlNodePtr node)
vpXmlConfigParserKeyPoint()
std::string xmlReadStringChild(xmlDocPtr doc, xmlNodePtr node)
std::map< std::string, int > nodeMap
void parse(const std::string &filename)
void parse(const std::string &filename)