[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46747] branches/soc-2011-tomato/extern/ libmv: For the planar tracker, initialize the warp from the four correspondences after

Keir Mierle mierle at gmail.com
Thu May 17 23:26:07 CEST 2012


Revision: 46747
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46747
Author:   keir
Date:     2012-05-17 21:26:06 +0000 (Thu, 17 May 2012)
Log Message:
-----------
For the planar tracker, initialize the warp from the four correspondences after
brute force translation search.

Modified Paths:
--------------
    branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc
    branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp

Modified: branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc	2012-05-17 20:21:26 UTC (rev 46746)
+++ branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc	2012-05-17 21:26:06 UTC (rev 46747)
@@ -398,7 +398,7 @@
 struct TranslationWarp {
   TranslationWarp(const double *x1, const double *y1,
                   const double *x2, const double *y2) {
-    Vec2 t = Quad(x2, y2).Centroid() - Quad(x1, y1).Centroid() ;
+    Vec2 t = Quad(x2, y2).Centroid() - Quad(x1, y1).Centroid();
     parameters[0] = t[0];
     parameters[1] = t[1];
   }
@@ -908,19 +908,6 @@
   }
   // TODO(keir): Check quads to ensure there is some area.
 
-  // Prepare the initial warp parameters from the four correspondences.
-  Warp warp(x1, y1, x2, y2);
-
-  // Decide how many samples to use in the x and y dimensions.
-  int num_samples_x;
-  int num_samples_y;
-  PickSampling(x1, y1, x2, y2, &num_samples_x, &num_samples_y);
-
-  // Compute the warp from rectangular coordinates.
-  Mat3 canonical_homography = ComputeCanonicalHomography(x1, y1,
-                                                         num_samples_x,
-                                                         num_samples_y);
-
   // Prepare the image and gradient.
   Array3Df image_and_gradient1;
   Array3Df image_and_gradient2;
@@ -938,8 +925,22 @@
                                          image2,
                                          options.num_extra_points,
                                          x1, y1, x2, y2);
+    for (int i = 0; i < 4; ++i) {
+      LG << "P" << i << ": (" << x1[i] << ", " << y1[i] << "); brute ("
+         << x2[i] << ", " << y2[i] << "); (dx, dy): (" << (x2[i] - x1[i]) << ", "
+         << (y2[i] - y1[i]) << ").";
+    }
   }
 
+  // Prepare the initial warp parameters from the four correspondences.
+  // Note: This must happen after the brute initialization runs.
+  Warp warp(x1, y1, x2, y2);
+
+  // Decide how many samples to use in the x and y dimensions.
+  int num_samples_x;
+  int num_samples_y;
+  PickSampling(x1, y1, x2, y2, &num_samples_x, &num_samples_y);
+
   ceres::Solver::Options solver_options;
   solver_options.linear_solver_type = ceres::DENSE_QR;
   solver_options.max_num_iterations = options.max_iterations;
@@ -957,6 +958,11 @@
   BoundaryCheckingCallback<Warp> callback(image2, warp, x1, y1);
   solver_options.callbacks.push_back(&callback);
 
+  // Compute the warp from rectangular coordinates.
+  Mat3 canonical_homography = ComputeCanonicalHomography(x1, y1,
+                                                         num_samples_x,
+                                                         num_samples_y);
+
   // Construct the warp cost function. AutoDiffCostFunction takes ownership.
   WarpCostFunctor<Warp> *warp_cost_function =
       new WarpCostFunctor<Warp>(options,

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2012-05-17 20:21:26 UTC (rev 46746)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2012-05-17 21:26:06 UTC (rev 46747)
@@ -400,8 +400,7 @@
 	if (track_region_result.termination == libmv::TrackRegionResult::PARAMETER_TOLERANCE ||
 	    track_region_result.termination == libmv::TrackRegionResult::FUNCTION_TOLERANCE  ||
 	    track_region_result.termination == libmv::TrackRegionResult::GRADIENT_TOLERANCE  ||
-	    track_region_result.termination == libmv::TrackRegionResult::NO_CONVERGENCE      ||
-	    track_region_result.termination == libmv::TrackRegionResult::INSUFFICIENT_CORRELATION)
+	    track_region_result.termination == libmv::TrackRegionResult::NO_CONVERGENCE)
 	{
 		tracking_result = true;
 	}




More information about the Bf-blender-cvs mailing list