Quiet logs in stitching module
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Tue, 9 Oct 2012 15:28:15 +0000 (19:28 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Tue, 9 Oct 2012 15:28:15 +0000 (19:28 +0400)
modules/stitching/include/opencv2/stitching/detail/util.hpp
modules/stitching/src/exposure_compensate.cpp
modules/stitching/src/motion_estimators.cpp
modules/stitching/src/seam_finders.cpp
modules/stitching/src/stitcher.cpp

index bce390b..15cecc7 100644 (file)
@@ -46,7 +46,7 @@
 #include <list>\r
 #include "opencv2/core/core.hpp"\r
 \r
-#define ENABLE_LOG 1\r
+#define ENABLE_LOG 0\r
 \r
 // TODO remove LOG macros, add logging class\r
 #if ENABLE_LOG\r
index 23bc161..39aa316 100644 (file)
@@ -74,7 +74,9 @@ void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &imag
                            const vector<pair<Mat,uchar> > &masks)\r
 {\r
     LOGLN("Exposure compensation...");\r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     CV_Assert(corners.size() == images.size() && images.size() == masks.size());\r
 \r
index bbbc969..9fb33b9 100644 (file)
@@ -105,7 +105,9 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
                                         vector<CameraParams> &cameras)\r
 {\r
     LOGLN("Estimating rotations...");\r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     const int num_images = static_cast<int>(features.size());\r
 \r
@@ -172,7 +174,9 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features,
                                   vector<CameraParams> &cameras)\r
 {\r
     LOG_CHAT("Bundle adjustment");\r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     num_images_ = static_cast<int>(features.size());\r
     features_ = &features[0];\r
@@ -582,7 +586,9 @@ void BundleAdjusterRay::calcJacobian(Mat &jac)
 void waveCorrect(vector<Mat> &rmats, WaveCorrectKind kind)\r
 {\r
     LOGLN("Wave correcting...");\r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     Mat moment = Mat::zeros(3, 3, CV_32F);\r
     for (size_t i = 0; i < rmats.size(); ++i)\r
index 83f053c..44e3a91 100644 (file)
@@ -52,10 +52,12 @@ void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
                               vector<Mat> &masks)\r
 {\r
     LOGLN("Finding seams...");\r
-    if (src.size() == 0) \r
+    if (src.size() == 0)\r
         return;\r
 \r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     images_ = src;\r
     sizes_.resize(src.size());\r
@@ -87,10 +89,12 @@ void VoronoiSeamFinder::find(const vector<Size> &sizes, const vector<Point> &cor
                              vector<Mat> &masks)\r
 {\r
     LOGLN("Finding seams...");\r
-    if (sizes.size() == 0) \r
+    if (sizes.size() == 0)\r
         return;\r
 \r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     sizes_ = sizes;\r
     corners_ = corners;\r
@@ -161,7 +165,9 @@ DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc) {}
 void DpSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, vector<Mat> &masks)\r
 {\r
     LOGLN("Finding seams...");\r
+#if ENABLE_LOG\r
     int64 t = getTickCount();\r
+#endif\r
 \r
     if (src.size() == 0)\r
         return;\r
@@ -700,7 +706,7 @@ void DpSeamFinder::computeCosts(
 {\r
     CV_Assert(states_[comp] & INTERS);\r
 \r
-    // compute costs    \r
+    // compute costs\r
 \r
     float (*diff)(const Mat&, int, int, const Mat&, int, int) = 0;\r
     if (image1.type() == CV_32FC3 && image2.type() == CV_32FC3)\r
@@ -1055,10 +1061,10 @@ public:
     void findInPair(size_t first, size_t second, Rect roi);\r
 \r
 private:\r
-    void setGraphWeightsColor(const Mat &img1, const Mat &img2, \r
+    void setGraphWeightsColor(const Mat &img1, const Mat &img2,\r
                               const Mat &mask1, const Mat &mask2, GCGraph<float> &graph);\r
-    void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, \r
-                                  const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
+    void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,\r
+                                  const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,\r
                                   GCGraph<float> &graph);\r
 \r
     vector<Mat> dx_, dy_;\r
@@ -1148,8 +1154,8 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &
 \r
 \r
 void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(\r
-        const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, \r
-        const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
+        const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,\r
+        const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,\r
         GCGraph<float> &graph)\r
 {\r
     const Size img_size = img1.size();\r
@@ -1177,7 +1183,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
                 float grad = dx1.at<float>(y, x) + dx1.at<float>(y, x + 1) +\r
                              dx2.at<float>(y, x) + dx2.at<float>(y, x + 1) + weight_eps;\r
                 float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +\r
-                                normL2(img1.at<Point3f>(y, x + 1), img2.at<Point3f>(y, x + 1))) / grad + \r
+                                normL2(img1.at<Point3f>(y, x + 1), img2.at<Point3f>(y, x + 1))) / grad +\r
                                weight_eps;\r
                 if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y, x + 1) ||\r
                     !mask2.at<uchar>(y, x) || !mask2.at<uchar>(y, x + 1))\r
@@ -1186,10 +1192,10 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
             }\r
             if (y < img_size.height - 1)\r
             {\r
-                float grad = dy1.at<float>(y, x) + dy1.at<float>(y + 1, x) + \r
+                float grad = dy1.at<float>(y, x) + dy1.at<float>(y + 1, x) +\r
                              dy2.at<float>(y, x) + dy2.at<float>(y + 1, x) + weight_eps;\r
-                float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) + \r
-                                normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad + \r
+                float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +\r
+                                normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad +\r
                                weight_eps;\r
                 if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y + 1, x) ||\r
                     !mask2.at<uchar>(y, x) || !mask2.at<uchar>(y + 1, x))\r
@@ -1271,7 +1277,7 @@ void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)
         setGraphWeightsColor(subimg1, subimg2, submask1, submask2, graph);\r
         break;\r
     case GraphCutSeamFinder::COST_COLOR_GRAD:\r
-        setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2, \r
+        setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,\r
                                  submask1, submask2, graph);\r
         break;\r
     default:\r
@@ -1402,17 +1408,17 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi)
             }\r
         }\r
     }\r
-    \r
+\r
     Mat terminals, leftT, rightT, top, bottom;\r
 \r
     switch (cost_type_)\r
     {\r
     case GraphCutSeamFinder::COST_COLOR:\r
-        setGraphWeightsColor(subimg1, subimg2, submask1, submask2, \r
+        setGraphWeightsColor(subimg1, subimg2, submask1, submask2,\r
                              terminals, leftT, rightT, top, bottom);\r
         break;\r
     case GraphCutSeamFinder::COST_COLOR_GRAD:\r
-        setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2, \r
+        setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,\r
                                  submask1, submask2, terminals, leftT, rightT, top, bottom);\r
         break;\r
     default:\r
@@ -1448,7 +1454,7 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi)
 }\r
 \r
 \r
-void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2, \r
+void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2,\r
                                                  Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)\r
 {\r
     const Size img_size = img1.size();\r
@@ -1540,7 +1546,7 @@ void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img
 \r
 void GraphCutSeamFinderGpu::setGraphWeightsColorGrad(\r
         const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,\r
-        const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
+        const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,\r
         Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)\r
 {\r
     const Size img_size = img1.size();\r
index f8b58d3..99bacf2 100644 (file)
@@ -152,7 +152,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano)
 
     Mat &pano_ = pano.getMatRef();
 
+#if ENABLE_LOG
     int64 t = getTickCount();
+#endif
 
     vector<Point> corners(imgs_.size());
     vector<Mat> masks_warped(imgs_.size());
@@ -201,7 +203,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano)
     masks.clear();
 
     LOGLN("Compositing...");
+#if ENABLE_LOG
     t = getTickCount();
+#endif
 
     Mat img_warped, img_warped_s;
     Mat dilated_mask, seam_mask, mask, mask_warped;
@@ -349,7 +353,9 @@ Stitcher::Status Stitcher::matchImages()
     full_img_sizes_.resize(imgs_.size());
 
     LOGLN("Finding features...");
+#if ENABLE_LOG
     int64 t = getTickCount();
+#endif
 
     for (size_t i = 0; i < imgs_.size(); ++i)
     {
@@ -406,7 +412,9 @@ Stitcher::Status Stitcher::matchImages()
     LOGLN("Finding features, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
 
     LOG("Pairwise matching");
+#if ENABLE_LOG
     t = getTickCount();
+#endif
     (*features_matcher_)(features_, pairwise_matches_, matching_mask_);
     features_matcher_->collectGarbage();
     LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");