added time measurements into opencv_stitching
authorAlexey Spizhevoy <no@email>
Thu, 19 May 2011 05:59:10 +0000 (05:59 +0000)
committerAlexey Spizhevoy <no@email>
Thu, 19 May 2011 05:59:10 +0000 (05:59 +0000)
modules/stitching/main.cpp
modules/stitching/motion_estimators.cpp

index 569a102..0e0f885 100644 (file)
@@ -30,6 +30,7 @@ void printUsage()
 \r
 int main(int argc, char* argv[])\r
 {\r
+    int64 app_start_time = getTickCount();\r
     cv::setBreakOnError(true);\r
 \r
     vector<string> img_names;\r
@@ -65,6 +66,8 @@ int main(int argc, char* argv[])
         }\r
     }\r
 \r
+    int64 t = getTickCount();\r
+    LOGLN("Parsing params and reading images...");\r
     for (int i = 1; i < argc; ++i)\r
     {\r
         if (string(argv[i]) == "--trygpu")\r
@@ -203,6 +206,7 @@ int main(int argc, char* argv[])
             }\r
         }\r
     }\r
+    LOGLN("Parsing params and reading images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
     int num_images = static_cast<int>(images.size());\r
     if (num_images < 2)\r
@@ -211,17 +215,21 @@ int main(int argc, char* argv[])
         return -1;\r
     }\r
 \r
+    t = getTickCount();\r
     LOGLN("Finding features...");\r
     vector<ImageFeatures> features;\r
     SurfFeaturesFinder finder(trygpu);\r
     finder(images, features);\r
+    LOGLN("Finding features, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
-    LOGLN("Pairwise matching...");\r
+    t = getTickCount();\r
+    LOGLN("Pairwise matching... ");\r
     vector<MatchesInfo> pairwise_matches;\r
     BestOf2NearestMatcher matcher(trygpu);\r
     if (user_match_conf)\r
         matcher = BestOf2NearestMatcher(trygpu, match_conf);\r
     matcher(images, features, pairwise_matches);\r
+    LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
     vector<int> indices = leaveBiggestComponent(images, features, pairwise_matches, conf_thresh);\r
     vector<string> img_names_subset;\r
@@ -236,10 +244,12 @@ int main(int argc, char* argv[])
         return -1;\r
     }\r
 \r
+    t = getTickCount();\r
     LOGLN("Estimating rotations...");\r
     HomographyBasedEstimator estimator;\r
     vector<CameraParams> cameras;\r
     estimator(images, features, pairwise_matches, cameras);\r
+    LOGLN("Estimating rotations, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
     for (size_t i = 0; i < cameras.size(); ++i)\r
     {\r
@@ -249,12 +259,15 @@ int main(int argc, char* argv[])
         LOGLN("Initial focal length " << i << ": " << cameras[i].focal);\r
     }\r
 \r
-    LOGLN("Bundle adjustment...");\r
+    t = getTickCount();\r
+    LOGLN("Bundle adjustment... ");\r
     BundleAdjuster adjuster(ba_space, conf_thresh);\r
     adjuster(images, features, pairwise_matches, cameras);\r
+    LOGLN("Bundle adjustment, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
     if (wave_correct)\r
     {\r
+        t = getTickCount();\r
         LOGLN("Wave correcting...");\r
         vector<Mat> rmats;\r
         for (size_t i = 0; i < cameras.size(); ++i)\r
@@ -262,6 +275,7 @@ int main(int argc, char* argv[])
         waveCorrect(rmats);\r
         for (size_t i = 0; i < cameras.size(); ++i)\r
             cameras[i].R = rmats[i];\r
+        LOGLN("Wave correcting, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
     }\r
 \r
     // Find median focal length\r
@@ -277,6 +291,8 @@ int main(int argc, char* argv[])
     if ((work_megapix > 0 || compose_megapix > 0) \r
         && abs(work_megapix - compose_megapix) > 1e-3)\r
     {\r
+        t = getTickCount();\r
+        LOGLN("Compose scaling...");\r
         for (int i = 0; i < num_images; ++i)\r
         {\r
             Mat full_img = imread(img_names[i]);\r
@@ -291,6 +307,7 @@ int main(int argc, char* argv[])
             cameras[i].focal *= compose_scale / work_scale;\r
         }\r
         camera_focal *= static_cast<float>(compose_scale / work_scale);\r
+        LOGLN("Compose scaling, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
     }\r
 \r
     vector<Mat> masks(num_images);\r
@@ -304,7 +321,8 @@ int main(int argc, char* argv[])
     vector<Mat> masks_warped(num_images);\r
     vector<Mat> images_warped(num_images);\r
 \r
-    LOGLN("Warping images...");\r
+    t = getTickCount();\r
+    LOGLN("Warping images... ");\r
     Ptr<Warper> warper = Warper::createByCameraFocal(camera_focal, warp_type);\r
     for (int i = 0; i < num_images; ++i)\r
     {\r
@@ -314,19 +332,24 @@ int main(int argc, char* argv[])
     vector<Mat> images_f(num_images);\r
     for (int i = 0; i < num_images; ++i)\r
         images_warped[i].convertTo(images_f[i], CV_32F);\r
+    LOGLN("Warping images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
+    t = getTickCount();\r
     LOGLN("Finding seams...");\r
     Ptr<SeamFinder> seam_finder = SeamFinder::createDefault(seam_find_type);\r
     (*seam_finder)(images_f, corners, masks_warped);\r
+    LOGLN("Finding seams, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
+    t = getTickCount();\r
     LOGLN("Blending images...");\r
     Mat result, result_mask;\r
     Ptr<Blender> blender = Blender::createDefault(blend_type);\r
     (*blender)(images_f, corners, masks_warped, result, result_mask);\r
+    LOGLN("Blending images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
 \r
     imwrite(result_name, result);\r
 \r
-    LOGLN("Finished");\r
+    LOGLN("Finished, total time: " << ((getTickCount() - app_start_time) / getTickFrequency()) << " sec");\r
     return 0;\r
 }\r
 \r
index ae72b71..e0c0cb6 100644 (file)
@@ -165,8 +165,8 @@ void BundleAdjuster::estimate(const vector<Mat> &images, const vector<ImageFeatu
             cvCopy( &matErr, _err );
         }
     }
-    LOGLN("BA final error: " << sqrt(err_.dot(err_)));
-    LOGLN("BA iterations done: " << count);
+    LOGLN("Bundle adjustment, final error: " << sqrt(err_.dot(err_)));
+    LOGLN("Bundle adjustment, iteration done: " << count);
 
     // Obtain global motion
     for (int i = 0; i < num_images_; ++i)