Made changes in the stitching log macros: now the function stitchingLogLevel() may...
authorLeonid Beynenson <no@email>
Tue, 24 Jan 2012 11:56:32 +0000 (11:56 +0000)
committerLeonid Beynenson <no@email>
Tue, 24 Jan 2012 11:56:32 +0000 (11:56 +0000)
modules/stitching/include/opencv2/stitching/detail/util.hpp
modules/stitching/src/matchers.cpp
modules/stitching/src/motion_estimators.cpp
modules/stitching/src/util.cpp

index b304761..a2e5a02 100644 (file)
@@ -54,7 +54,7 @@
   #include <iostream>\r
   #include <sstream>\r
   #include <android/log.h>\r
-  #define LOG(msg) \\r
+  #define LOG_STITCHING_MSG(msg) \\r
     do { \\r
         std::stringstream _os; \\r
         _os << msg; \\r
     } while(0);\r
 #else\r
   #include <iostream>\r
-  #define LOG(msg) do { std::cout << msg; std::cout.flush(); } while(0);\r
+  #define LOG_STITCHING_MSG(msg) do { std::cout << msg; std::cout.flush(); } while(0);\r
 #endif\r
 #else\r
-  #define LOG(msg)\r
+  #define LOG_STITCHING_MSG(msg)\r
 #endif\r
 \r
+#define LOG_(_level, _msg)                     \\r
+    do {                                       \\r
+        if ((_level) >= ::cv::detail::stitchingLogLevel()) { \\r
+            LOG_STITCHING_MSG(_msg);           \\r
+        }                                      \\r
+    } while(0)\r
+\r
+\r
+#define LOG(msg) LOG_(1, msg)\r
+#define LOG_CHAT(msg) LOG_(0, msg)\r
+\r
 #define LOGLN(msg) LOG(msg << std::endl)\r
+#define LOGLN_CHAT(msg) LOG_CHAT(msg << std::endl)\r
+\r
+//#if DEBUG_LOG_CHAT\r
+//  #define LOG_CHAT(msg) LOG(msg)\r
+//  #define LOGLN_CHAT(msg) LOGLN(msg)\r
+//#else\r
+//  #define LOG_CHAT(msg) do{}while(0)\r
+//  #define LOGLN_CHAT(msg) do{}while(0)\r
+//#endif\r
 \r
 namespace cv {\r
 namespace detail {\r
@@ -128,6 +148,8 @@ Point CV_EXPORTS resultTl(const std::vector<Point> &corners);
 // Returns random 'count' element subset of the {0,1,...,size-1} set\r
 void CV_EXPORTS selectRandomSubset(int count, int size, std::vector<int> &subset);\r
 \r
+int& CV_EXPORTS stitchingLogLevel();\r
+\r
 } // namespace detail\r
 } // namespace cv\r
 \r
index aa8c0e9..cc1da49 100644 (file)
@@ -491,7 +491,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
         parallel_for(BlockedRange(0, static_cast<int>(near_pairs.size())), body);\r
     else\r
         body(BlockedRange(0, static_cast<int>(near_pairs.size())));\r
-    LOGLN("");\r
+    LOGLN_CHAT("");\r
 }\r
 \r
 \r
index 1d3aae0..acf2ad6 100644 (file)
@@ -171,7 +171,7 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features,
                                   const vector<MatchesInfo> &pairwise_matches,\r
                                   vector<CameraParams> &cameras)\r
 {\r
-    LOG("Bundle adjustment");\r
+    LOG_CHAT("Bundle adjustment");\r
     int64 t = getTickCount();\r
 \r
     num_images_ = static_cast<int>(features.size());\r
@@ -230,16 +230,16 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features,
         if (_err)\r
         {\r
             calcError(err);\r
-            LOG(".");\r
+            LOG_CHAT(".");\r
             iter++;\r
             CvMat tmp = err;\r
             cvCopy(&tmp, _err);\r
         }\r
     }\r
 \r
-    LOGLN("");\r
-    LOGLN("Bundle adjustment, final RMS error: " << sqrt(err.dot(err) / total_num_matches_));\r
-    LOGLN("Bundle adjustment, iterations done: " << iter);\r
+    LOGLN_CHAT("");\r
+    LOGLN_CHAT("Bundle adjustment, final RMS error: " << sqrt(err.dot(err) / total_num_matches_));\r
+    LOGLN_CHAT("Bundle adjustment, iterations done: " << iter);\r
 \r
     obtainRefinedCameraParams(cameras);\r
 \r
@@ -251,7 +251,7 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features,
     for (int i = 0; i < num_images_; ++i)\r
         cameras[i].R = R_inv * cameras[i].R;\r
 \r
-    LOGLN("Bundle adjustment, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
+    LOGLN_CHAT("Bundle adjustment, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 }\r
 \r
 \r
index 3f6cff5..01206aa 100644 (file)
@@ -165,5 +165,11 @@ void selectRandomSubset(int count, int size, vector<int> &subset)
     }\r
 }\r
 \r
+int& stitchingLogLevel()\r
+{\r
+    static int _log_level=1;\r
+    return _log_level;\r
+}\r
+\r
 } // namespace detail\r
 } // namespace cv\r