From 60676dbbe8149dc98824c8e565074d9f4e81f61a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 20 Jul 2016 16:17:57 +0300 Subject: [PATCH] fix build: move LOG macro from stitching public headers --- .../include/opencv2/stitching/detail/util.hpp | 50 ---------------- modules/stitching/src/precomp.hpp | 2 + modules/stitching/src/util_log.hpp | 58 +++++++++++++++++++ samples/cpp/stitching_detailed.cpp | 5 +- 4 files changed, 64 insertions(+), 51 deletions(-) create mode 100644 modules/stitching/src/util_log.hpp diff --git a/modules/stitching/include/opencv2/stitching/detail/util.hpp b/modules/stitching/include/opencv2/stitching/detail/util.hpp index 3845ba59e..e746f5e8b 100644 --- a/modules/stitching/include/opencv2/stitching/detail/util.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/util.hpp @@ -46,56 +46,6 @@ #include #include "opencv2/core.hpp" -#ifndef ENABLE_LOG -#define ENABLE_LOG 0 -#endif - -// TODO remove LOG macros, add logging class -#if ENABLE_LOG -#ifdef ANDROID - #include - #include - #include - #define LOG_STITCHING_MSG(msg) \ - do { \ - Stringstream _os; \ - _os << msg; \ - __android_log_print(ANDROID_LOG_DEBUG, "STITCHING", "%s", _os.str().c_str()); \ - } while(0); -#else - #include - #define LOG_STITCHING_MSG(msg) for(;;) { std::cout << msg; std::cout.flush(); break; } -#endif -#else - #define LOG_STITCHING_MSG(msg) -#endif - -#define LOG_(_level, _msg) \ - for(;;) \ - { \ - using namespace std; \ - if ((_level) >= ::cv::detail::stitchingLogLevel()) \ - { \ - LOG_STITCHING_MSG(_msg); \ - } \ - break; \ - } - - -#define LOG(msg) LOG_(1, msg) -#define LOG_CHAT(msg) LOG_(0, msg) - -#define LOGLN(msg) LOG(msg << std::endl) -#define LOGLN_CHAT(msg) LOG_CHAT(msg << std::endl) - -//#if DEBUG_LOG_CHAT -// #define LOG_CHAT(msg) LOG(msg) -// #define LOGLN_CHAT(msg) LOGLN(msg) -//#else -// #define LOG_CHAT(msg) do{}while(0) -// #define LOGLN_CHAT(msg) do{}while(0) -//#endif - namespace cv { namespace detail { diff --git a/modules/stitching/src/precomp.hpp b/modules/stitching/src/precomp.hpp index 70636b684..eff78cf58 100644 --- a/modules/stitching/src/precomp.hpp +++ b/modules/stitching/src/precomp.hpp @@ -99,4 +99,6 @@ # include "opencv2/stitching/stitching_tegra.hpp" #endif +#include "util_log.hpp" + #endif diff --git a/modules/stitching/src/util_log.hpp b/modules/stitching/src/util_log.hpp new file mode 100644 index 000000000..da454777c --- /dev/null +++ b/modules/stitching/src/util_log.hpp @@ -0,0 +1,58 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef __OPENCV_STITCHING_UTIL_LOG_HPP__ +#define __OPENCV_STITCHING_UTIL_LOG_HPP__ + +#ifndef ENABLE_LOG +#define ENABLE_LOG 0 +#endif + +// TODO remove LOG macros, add logging class +#if ENABLE_LOG +#ifdef ANDROID + #include + #include + #include + #define LOG_STITCHING_MSG(msg) \ + do { \ + Stringstream _os; \ + _os << msg; \ + __android_log_print(ANDROID_LOG_DEBUG, "STITCHING", "%s", _os.str().c_str()); \ + } while(0); +#else + #include + #define LOG_STITCHING_MSG(msg) for(;;) { std::cout << msg; std::cout.flush(); break; } +#endif +#else + #define LOG_STITCHING_MSG(msg) +#endif + +#define LOG_(_level, _msg) \ + for(;;) \ + { \ + using namespace std; \ + if ((_level) >= ::cv::detail::stitchingLogLevel()) \ + { \ + LOG_STITCHING_MSG(_msg); \ + } \ + break; \ + } + + +#define LOG(msg) LOG_(1, msg) +#define LOG_CHAT(msg) LOG_(0, msg) + +#define LOGLN(msg) LOG(msg << std::endl) +#define LOGLN_CHAT(msg) LOG_CHAT(msg << std::endl) + +//#if DEBUG_LOG_CHAT +// #define LOG_CHAT(msg) LOG(msg) +// #define LOGLN_CHAT(msg) LOGLN(msg) +//#else +// #define LOG_CHAT(msg) do{}while(0) +// #define LOGLN_CHAT(msg) do{}while(0) +//#endif + +#endif // __OPENCV_STITCHING_UTIL_LOG_HPP__ diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index 8fc489e87..f333bc6e3 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -56,10 +56,13 @@ #include "opencv2/stitching/detail/matchers.hpp" #include "opencv2/stitching/detail/motion_estimators.hpp" #include "opencv2/stitching/detail/seam_finders.hpp" -#include "opencv2/stitching/detail/util.hpp" #include "opencv2/stitching/detail/warpers.hpp" #include "opencv2/stitching/warpers.hpp" +#define ENABLE_LOG 1 +#define LOG(msg) std::cout << msg +#define LOGLN(msg) std::cout << msg << std::endl + using namespace std; using namespace cv; using namespace cv::detail;