[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56934] branches/soc-2011-tomato: Masks tracking operators

Sergey Sharybin sergey.vfx at gmail.com
Mon May 20 23:55:01 CEST 2013


Revision: 56934
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56934
Author:   nazgul
Date:     2013-05-20 21:55:01 +0000 (Mon, 20 May 2013)
Log Message:
-----------
Masks tracking operators

Added an operators which tracks the whole masks
in clip editor. Namely, this operators are tracking
selected splines of active spline layer.

This uses the same exact region tracker as motion
tracker used for ages, just marker is created from
mask spline. Pattern area will match the size of
spline's bounding box (without feather taken into
account!). Search area is currently hardcoded to
1.5x times bigger than marker's pattern area.

Settings for the tracked are used from default
tracker settings (which are in T-panel). So for
this added special panel to mask mode which
contains default tracker settings.

Matching will be ignored and Previous Frame
matching will be used.

Speed is also currently hardcoded to realtime.

This new tracker operators are using the same
shortcuts as regular tracker.

TODO:
  - Feather support.
  - Better deal with search area size.
  - Think of tracking speed control.

This is an experimental feature, might crash or
do not behave as you expect it to behave.

Modified Paths:
--------------
    branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc
    branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.h
    branches/soc-2011-tomato/extern/libmv/libmv-capi.cc
    branches/soc-2011-tomato/extern/libmv/libmv-capi.h
    branches/soc-2011-tomato/extern/libmv/libmv-capi_stub.cc
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c

Modified: branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.cc	2013-05-20 21:55:01 UTC (rev 56934)
@@ -1560,4 +1560,22 @@
   return true;
 }
 
+void ApplyInverseCanonicalHomography(const double x, const double y,
+                                     const double *xs, const double *ys,
+                                     int num_samples_x, int num_samples_y,
+                                     double *warped_position_x,
+                                     double *warped_position_y) {
+  //int num_samples_x, num_samples_y;
+  //PickSampling(xs, ys, xs, ys, &num_samples_x, &num_samples_y);
+
+  // Compute the warp from rectangular coordinates.
+  Mat3 canonical_homography = ComputeCanonicalHomography(xs, ys,
+                                                         num_samples_x,
+                                                         num_samples_y);
+
+  Vec3 warped_position = canonical_homography.inverse() * Vec3(x, y, 1);
+  *warped_position_x = warped_position(0) / warped_position(2);
+  *warped_position_y = warped_position(1) / warped_position(2);
+}
+
 }  // namespace libmv

Modified: branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.h
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.h	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/extern/libmv/libmv/tracking/track_region.h	2013-05-20 21:55:01 UTC (rev 56934)
@@ -151,6 +151,12 @@
                        FloatImage *mask, FloatImage *patch,
                        double *warped_position_x, double *warped_position_y);
 
+ void ApplyInverseCanonicalHomography(const double x, const double y,
+                                      const double *xs, const double *ys,
+                                      int num_samples_x, int num_samples_y,
+                                      double *warped_position_x,
+                                      double *warped_position_y);
+
 }  // namespace libmv
 
 #endif  // LIBMV_TRACKING_TRACK_REGION_H_

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.cc
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.cc	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.cc	2013-05-20 21:55:01 UTC (rev 56934)
@@ -1077,4 +1077,15 @@
 	}
 }
 
+void libmv_ApplyInverseCanonicalHomography(double x, double y,
+                                           const double *xs, const double *ys,
+                                           int num_samples_x, int num_samples_y,
+                                           double *warped_position_x,
+                                           double *warped_position_y)
+{
+	libmv::ApplyInverseCanonicalHomography(x, y, xs, ys,
+	                                       num_samples_x, num_samples_y,
+	                                       warped_position_x, warped_position_y);
+}
+
 #endif

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi.h
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi.h	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi.h	2013-05-20 21:55:01 UTC (rev 56934)
@@ -166,6 +166,12 @@
 void libmv_InvertCameraIntrinsics(const libmv_cameraIntrinsicsOptions *libmv_camera_intrinsics_options,
 			double x, double y, double *x1, double *y1);
 
+void libmv_ApplyInverseCanonicalHomography(double x, double y,
+                                           const double *xs, const double *ys,
+                                           int num_samples_x, int num_samples_y,
+                                           double *warped_position_x,
+                                           double *warped_position_y);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2011-tomato/extern/libmv/libmv-capi_stub.cc
===================================================================
--- branches/soc-2011-tomato/extern/libmv/libmv-capi_stub.cc	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/extern/libmv/libmv-capi_stub.cc	2013-05-20 21:55:01 UTC (rev 56934)
@@ -274,4 +274,14 @@
 	*y1 = (y - principal_y) / focal_length;
 }
 
+void libmv_ApplyInverseCanonicalHomography(double x, double y,
+                                           const double *xs, const double *ys,
+                                           int num_samples_x, int num_samples_y,
+                                           double *warped_position_x,
+                                           double *warped_position_y)
+{
+	*warped_position_x = (double) num_samples_x * 0.5;
+	*warped_position_y = (double) num_samples_y * 0.5;
+}
+
 #endif  // ifndef WITH_LIBMV

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	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2013-05-20 21:55:01 UTC (rev 56934)
@@ -198,6 +198,54 @@
         return clip and sc.mode == 'RECONSTRUCTION' and sc.view == 'CLIP'
 
 
+def _draw_default_tracker_settings(layout, settings):
+        col = layout.column()
+        row = col.row(align=True)
+        label = CLIP_MT_tracking_settings_presets.bl_label
+        row.menu('CLIP_MT_tracking_settings_presets', text=label)
+        row.operator("clip.tracking_settings_preset_add",
+                     text="", icon='ZOOMIN')
+        props = row.operator("clip.tracking_settings_preset_add",
+                             text="", icon='ZOOMOUT')
+        props.remove_active = True
+
+        col.separator()
+
+        row = col.row(align=True)
+        row.prop(settings, "use_default_red_channel",
+                 text="R", toggle=True)
+        row.prop(settings, "use_default_green_channel",
+                 text="G", toggle=True)
+        row.prop(settings, "use_default_blue_channel",
+                 text="B", toggle=True)
+
+        col.separator()
+
+        sub = col.column(align=True)
+        sub.prop(settings, "default_pattern_size")
+        sub.prop(settings, "default_search_size")
+
+        col.label(text="Tracker:")
+        col.prop(settings, "default_motion_model")
+        col.prop(settings, "use_default_brute")
+        col.prop(settings, "use_default_normalization")
+        col.prop(settings, "use_default_mask")
+        col.prop(settings, "default_correlation_min")
+
+        col.separator()
+
+        sub = col.column(align=True)
+        sub.prop(settings, "default_frames_limit")
+        sub.prop(settings, "default_margin")
+
+        col.label(text="Match:")
+        col.prop(settings, "default_pattern_match", text="")
+
+        col.separator()
+        col.operator("clip.track_settings_as_default",
+                     text="Copy From Active Track")
+
+
 class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'TOOLS'
@@ -221,53 +269,29 @@
         row.label(text="Tracking Settings")
 
         if settings.show_default_expanded:
-            col = box.column()
-            row = col.row(align=True)
-            label = CLIP_MT_tracking_settings_presets.bl_label
-            row.menu('CLIP_MT_tracking_settings_presets', text=label)
-            row.operator("clip.tracking_settings_preset_add",
-                         text="", icon='ZOOMIN')
-            props = row.operator("clip.tracking_settings_preset_add",
-                                 text="", icon='ZOOMOUT')
-            props.remove_active = True
+          _draw_default_tracker_settings(box, settings)
 
-            col.separator()
 
-            row = col.row(align=True)
-            row.prop(settings, "use_default_red_channel",
-                     text="R", toggle=True)
-            row.prop(settings, "use_default_green_channel",
-                     text="G", toggle=True)
-            row.prop(settings, "use_default_blue_channel",
-                     text="B", toggle=True)
+class CLIP_PT_tools_default_tracking_settings(Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'TOOLS'
+    bl_label = "Default Settings"
 
-            col.separator()
+    @classmethod
+    def poll(cls, context):
+        sc = context.space_data
+        clip = sc.clip
 
-            sub = col.column(align=True)
-            sub.prop(settings, "default_pattern_size")
-            sub.prop(settings, "default_search_size")
+        return clip and sc.mode == 'MASK'
 
-            col.label(text="Tracker:")
-            col.prop(settings, "default_motion_model")
-            col.prop(settings, "use_default_brute")
-            col.prop(settings, "use_default_normalization")
-            col.prop(settings, "use_default_mask")
-            col.prop(settings, "default_correlation_min")
+    def draw(self, context):
+        layout = self.layout
+        sc = context.space_data
+        clip = sc.clip
+        settings = clip.tracking.settings
+        _draw_default_tracker_settings(layout, settings)
 
-            col.separator()
 
-            sub = col.column(align=True)
-            sub.prop(settings, "default_frames_limit")
-            sub.prop(settings, "default_margin")
-
-            col.label(text="Match:")
-            col.prop(settings, "default_pattern_match", text="")
-
-            col.separator()
-            col.operator("clip.track_settings_as_default",
-                         text="Copy From Active Track")
-
-
 class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'TOOLS'

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h	2013-05-20 21:39:07 UTC (rev 56933)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h	2013-05-20 21:55:01 UTC (rev 56934)
@@ -53,9 +53,11 @@
 void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay);
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list