[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46743] branches/soc-2011-tomato: Add panels for the new planar tracker

Keir Mierle mierle at gmail.com
Thu May 17 19:09:51 CEST 2012


Revision: 46743
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46743
Author:   keir
Date:     2012-05-17 17:09:51 +0000 (Thu, 17 May 2012)
Log Message:
-----------
Add panels for the new planar tracker

This replaces the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:

- The old "tracking algorithm" picker is gone. There is only 1
  algorithm now. We may revisit this later, but I would much
  prefer to have only 1 algorithm. So far no optimization work
  has been done so the speed is not there yet.

- There is now a dropdown to select the motion model. Choices:

  * Translation
  * Translation, rotation
  * Translation, scale
  * Translation, rotation, scale
  * Affine (Not implemented yet)
  * Perspective

  The most stable is the "translation" parameterization. The
  others work but still require some tweaking.

- The old "Hybrid" mode is gone; instead there is a toggle to
  enable or disable translation-only tracker initialization. This
  is the equivalent of the hyrbid mode before, but rewritten to work
  with the new planar tracking modes.

- The pyramid levels setting is gone. At a future date, the planar
  tracker will decide to use pyramids or not automatically. The
  pyramid setting was ultimately a mistake; with the brute force
  initialization it is unnecessary.

Modified Paths:
--------------
    branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc
    branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
    branches/soc-2011-tomato/extern/libmv/libmv-capi.h
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c

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 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc	2012-05-17 17:09:51 UTC (rev 46743)
@@ -499,7 +499,7 @@
                             q2.CornerRelativeToCentroid(i).transpose();
     }
     Mat2 R = OrthogonalProcrustes(correlation_matrix);
-    parameters[2] = acos(R(0, 0));
+    parameters[2] = atan2(R(1, 0), R(0, 0));
 
     std::cout << "correlation_matrix:\n" << correlation_matrix << "\n";
     std::cout << "R:\n" << R << "\n";
@@ -575,7 +575,7 @@
     std::cout << "correlation_matrix:\n" << correlation_matrix << "\n";
     Mat2 R = OrthogonalProcrustes(correlation_matrix);
     std::cout << "R:\n" << R << "\n";
-    parameters[3] = acos(R(0, 0));
+    parameters[3] = atan2(R(1, 0), R(0, 0));
     std::cout << "theta:" << parameters[3] << "\n";
   }
 
@@ -949,6 +949,7 @@
 
   // TODO(keir): Consider removing these options before committing.
   solver_options.numeric_derivative_relative_step_size = 1e-3;
+  solver_options.check_gradients = false;
   solver_options.gradient_check_relative_precision = 1e-10;
   solver_options.minimizer_progress_to_stdout = false;
 

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.cpp	2012-05-17 17:09:51 UTC (rev 46743)
@@ -380,6 +380,7 @@
 	track_region_options.sigma = options->sigma;
 	track_region_options.num_extra_points = 1;
 	track_region_options.image1_mask = NULL;
+	track_region_options.use_brute_initialization = options->use_brute;
 
 	/* Convert from raw float buffers to libmv's FloatImage. */
 	libmv::FloatImage old_patch, new_patch;

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.h
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.h	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.h	2012-05-17 17:09:51 UTC (rev 46743)
@@ -54,6 +54,7 @@
 struct libmv_trackRegionOptions {
   int motion_model;
   int num_iterations;
+  int use_brute;
   double minimum_correlation;
   double sigma;
 };

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2012-05-17 17:09:51 UTC (rev 46743)
@@ -187,10 +187,8 @@
             sub.prop(settings, "default_search_size")
 
             col.label(text="Tracker:")
-            col.prop(settings, "default_tracker", text="")
-
-            if settings.default_tracker == 'KLT':
-                col.prop(settings, "default_pyramid_levels")
+            col.prop(settings, "default_motion_model")
+            col.prop(settings, "default_use_brute")
             col.prop(settings, "default_correlation_min")
 
             col.separator()
@@ -488,10 +486,8 @@
 
         active = clip.tracking.tracks.active
         if active:
-            col.prop(active, "tracker")
-
-            if active.tracker == 'KLT':
-                col.prop(active, "pyramid_levels")
+            col.prop(active, "motion_model")
+            col.prop(active, "use_brute")
             col.prop(active, "correlation_min")
 
             col.separator()

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h	2012-05-17 17:09:51 UTC (rev 46743)
@@ -190,7 +190,6 @@
 #define CLAMP_PAT_POS		2
 #define CLAMP_SEARCH_DIM	3
 #define CLAMP_SEARCH_POS	4
-#define CLAMP_PYRAMID_LEVELS	5
 
 #define TRACK_AREA_NONE		-1
 #define TRACK_AREA_POINT	1

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-05-17 17:09:51 UTC (rev 46743)
@@ -156,11 +156,10 @@
 	tracking->camera.pixel_aspect = 1.0f;
 	tracking->camera.units = CAMERA_UNITS_MM;
 
-	tracking->settings.default_tracker = TRACKER_HYBRID;
+	tracking->settings.default_motion_model = TRACK_MOTION_MODEL_TRANSLATION;
 	tracking->settings.default_minimum_correlation = 0.75;
 	tracking->settings.default_pattern_size = 11;
 	tracking->settings.default_search_size = 61;
-	tracking->settings.default_pyramid_levels = 2;
 	tracking->settings.keyframe1 = 1;
 	tracking->settings.keyframe2 = 30;
 	tracking->settings.dist = 1;
@@ -179,12 +178,7 @@
 	int a;
 	float pat_min[2], pat_max[2];
 	float eff_pat_min[2], eff_pat_max[2];
-	float max_pyramid_level_factor = 1.0;
 
-	if (track->tracker == TRACKER_KLT) {
-		max_pyramid_level_factor = 1 << (track->pyramid_levels - 1);
-	}
-
 	/* XXX: currently search area is global, pattern size is per-marker, so we'll need to
 	 *      find maximal size of pattern to clamp search size nicely
 	 */
@@ -199,13 +193,8 @@
 		DO_MINMAX2(cur_pat_max, pat_min, pat_max);
 	}
 
-	/* compute the effective pattern size, which differs from the fine resolution
-	 * pattern size for the pyramid KLT tracker
-	 */
-	for (a = 0; a < 2; a++) {
-		eff_pat_min[a] = max_pyramid_level_factor * pat_min[a];
-		eff_pat_max[a] = max_pyramid_level_factor * pat_max[a];
-	}
+	copy_v2_v2(eff_pat_min, pat_min);
+	copy_v2_v2(eff_pat_max, pat_max);
 
 	if (event == CLAMP_PAT_DIM) {
 		for (a = 0; a < 2; a++) {
@@ -260,19 +249,12 @@
 			}
 		}
 	}
-	else if (event == CLAMP_PYRAMID_LEVELS || (event == CLAMP_SEARCH_DIM && track->tracker == TRACKER_KLT)) {
+	else if (event == CLAMP_SEARCH_DIM) {
 		float dim[2];
 		sub_v2_v2v2(dim, pat_max, pat_min);
-		{
-			float search_ratio = 2.3f * max_pyramid_level_factor;
-
-			/* resize the search area to something sensible based
-			 * on the number of pyramid levels
-			 */
-			for (a = 0; a < 2; a++) {
-				track->search_min[a] = search_ratio * pat_min[a];
-				track->search_max[a] = search_ratio * pat_max[a];
-			}
+		for (a = 0; a < 2; a++) {
+			track->search_min[a] = pat_min[a];
+			track->search_max[a] = pat_max[a];
 		}
 	}
 }
@@ -320,13 +302,13 @@
 	track = MEM_callocN(sizeof(MovieTrackingTrack), "add_marker_exec track");
 	strcpy(track->name, "Track");
 
-	track->tracker = settings->default_tracker;
-	track->pyramid_levels = settings->default_pyramid_levels;
+	track->motion_model = settings->default_motion_model;
 	track->minimum_correlation = settings->default_minimum_correlation;
 	track->margin = settings->default_margin;
 	track->pattern_match = settings->default_pattern_match;
 	track->frames_limit = settings->default_frames_limit;
 	track->flag = settings->default_flag;
+	track->algorithm_flag = settings->default_algorithm_flag;
 
 	memset(&marker, 0, sizeof(marker));
 	marker.pos[0] = x;
@@ -347,9 +329,6 @@
 
 	BKE_tracking_insert_marker(track, &marker);
 
-	if (track->tracker == TRACKER_KLT)
-		BKE_tracking_clamp_track(track, CLAMP_PYRAMID_LEVELS);
-
 	BLI_addtail(tracksbase, track);
 	BKE_track_unique_name(tracksbase, track);
 
@@ -1754,8 +1733,9 @@
 				patch_new = get_search_floatbuf(destination_ibuf, track, marker, &width, &height);
 
 				/* Configure the tracker */
-				options.motion_model = 0;
-				options.num_iterations = 10;
+				options.motion_model = track->motion_model;
+				options.use_brute = ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_BRUTE) == 0);
+				options.num_iterations = 50;
 				options.minimum_correlation = track->minimum_correlation;
 				options.sigma = 0.9;
 

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-05-17 17:09:51 UTC (rev 46743)
@@ -7122,9 +7122,6 @@
 
 				track= clip->tracking.tracks.first;
 				while (track) {
-					if (track->pyramid_levels==0)
-						track->pyramid_levels= 2;
-
 					if (track->minimum_correlation==0.0f)
 						track->minimum_correlation= 0.75f;
 
@@ -7146,9 +7143,8 @@
 		for (clip= main->movieclip.first; clip; clip= clip->id.next) {
 			MovieTrackingSettings *settings= &clip->tracking.settings;
 
-			if (settings->default_pyramid_levels==0) {
-				settings->default_tracker= TRACKER_KLT;
-				settings->default_pyramid_levels= 2;
+			if (settings->default_pattern_size == 0.0f) {
+				settings->default_motion_model= TRACK_MOTION_MODEL_TRANSLATION;
 				settings->default_minimum_correlation= 0.75;
 				settings->default_pattern_size= 11;
 				settings->default_search_size= 51;

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2012-05-17 16:45:02 UTC (rev 46742)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2012-05-17 17:09:51 UTC (rev 46743)
@@ -668,51 +668,6 @@
 		glEnd();
 	}
 
-	/* pyramid */
-	if (sel && TRACK_VIEW_SELECTED(sc, track) &&
-	    (track->tracker == TRACKER_KLT) &&
-		(marker->flag & MARKER_DISABLED) == 0)
-	{
-		if (track->flag & TRACK_LOCKED) {
-			if (act)
-				UI_ThemeColor(TH_ACT_MARKER);
-			else if (track->pat_flag & SELECT)
-				UI_ThemeColorShade(TH_LOCK_MARKER, 64);
-			else UI_ThemeColor(TH_LOCK_MARKER);
-		}
-		else if (marker->flag & MARKER_DISABLED) {
-			if (act)
-				UI_ThemeColor(TH_ACT_MARKER);
-			else if (track->pat_flag & SELECT)
-				UI_ThemeColorShade(TH_DIS_MARKER, 128);
-			else UI_ThemeColor(TH_DIS_MARKER);
-		}
-		else {
-			if (track->pat_flag & SELECT)
-				glColor3fv(scol);
-			else
-				glColor3fv(col);
-		}
-
-		{
-			int i = 0;
-			glPushMatrix();
-			glEnable(GL_LINE_STIPPLE);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list