From dfdb09386f025a1c4b7c2b070e0f617dfcf41200 Mon Sep 17 00:00:00 2001 From: 1Hyena Date: Thu, 1 May 2014 20:55:49 +0300 Subject: [PATCH 1/2] Autotuned_index now prints all info into logger instead of couting it. --- modules/flann/include/opencv2/flann/autotuned_index.h | 8 ++++++-- modules/flann/include/opencv2/flann/params.h | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/flann/include/opencv2/flann/autotuned_index.h b/modules/flann/include/opencv2/flann/autotuned_index.h index 8d531753e0..2b9ca91a42 100644 --- a/modules/flann/include/opencv2/flann/autotuned_index.h +++ b/modules/flann/include/opencv2/flann/autotuned_index.h @@ -99,18 +99,22 @@ public: */ virtual void buildIndex() { + std::ostringstream stream; bestParams_ = estimateBuildParams(); + print_params(bestParams_, stream); Logger::info("----------------------------------------------------\n"); Logger::info("Autotuned parameters:\n"); - print_params(bestParams_); + Logger::info("%s", stream.str().c_str()); Logger::info("----------------------------------------------------\n"); bestIndex_ = create_index_by_type(dataset_, bestParams_, distance_); bestIndex_->buildIndex(); speedup_ = estimateSearchParams(bestSearchParams_); + stream.str(std::string()); + print_params(bestSearchParams_, stream); Logger::info("----------------------------------------------------\n"); Logger::info("Search parameters:\n"); - print_params(bestSearchParams_); + Logger::info("%s", stream.str().c_str()); Logger::info("----------------------------------------------------\n"); } diff --git a/modules/flann/include/opencv2/flann/params.h b/modules/flann/include/opencv2/flann/params.h index fc2a906198..9ee5b1c9cc 100644 --- a/modules/flann/include/opencv2/flann/params.h +++ b/modules/flann/include/opencv2/flann/params.h @@ -79,17 +79,15 @@ T get_param(const IndexParams& params, std::string name) } } -inline void print_params(const IndexParams& params) +inline void print_params(const IndexParams& params, std::ostringstream& stream) { IndexParams::const_iterator it; - for(it=params.begin(); it!=params.end(); ++it) { - std::cout << it->first << " : " << it->second << std::endl; + stream << it->first << " : " << it->second << std::endl; } } - } From 6c118ebc514c805be3350c5fd1125933e0ddda18 Mon Sep 17 00:00:00 2001 From: 1Hyena Date: Mon, 12 May 2014 23:01:44 +0300 Subject: [PATCH 2/2] Changed ostringstream to ostream for new print_params and added the old version of print_params for backwards compatibility. --- modules/flann/include/opencv2/flann/params.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/flann/include/opencv2/flann/params.h b/modules/flann/include/opencv2/flann/params.h index 9ee5b1c9cc..b40c39e3d1 100644 --- a/modules/flann/include/opencv2/flann/params.h +++ b/modules/flann/include/opencv2/flann/params.h @@ -79,14 +79,19 @@ T get_param(const IndexParams& params, std::string name) } } -inline void print_params(const IndexParams& params, std::ostringstream& stream) +inline void print_params(const IndexParams& params, std::ostream& stream) { IndexParams::const_iterator it; + for(it=params.begin(); it!=params.end(); ++it) { stream << it->first << " : " << it->second << std::endl; } } +inline void print_params(const IndexParams& params) +{ + print_params(params, std::cout); +} }