Camera tracking integration
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 26 Oct 2011 09:54:10 +0000 (09:54 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 26 Oct 2011 09:54:10 +0000 (09:54 +0000)
===========================

Other fixes for issues pointed by Brecht.

release/scripts/presets/tracking_track_color/default.py
release/scripts/presets/tracking_track_color/far_plane.py
release/scripts/presets/tracking_track_color/near_plane.py
release/scripts/startup/bl_operators/clip.py
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_ui/space_clip.py
source/blender/blenkernel/intern/tracking.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/makesrna/intern/rna_tracking.c

index 264846cd93d735dc6d52147238e9136ec20cfb58..3213d6e0c835f5e30392b677f4b33158bc83094e 100644 (file)
@@ -1,5 +1,5 @@
 import bpy
-track = bpy.context.edit_movieclip.tracking.active_track
+track = bpy.context.edit_movieclip.tracking.tracks.active
 
 track.color = (0.0, 0.0, 0.0)
 track.use_custom_color = False
index 533df6a0a176515d9f06d73225bfe9c6c6e98c37..579d55626428d9888daa4bfb059b87d0e88529a4 100644 (file)
@@ -1,5 +1,5 @@
 import bpy
-track = bpy.context.edit_movieclip.tracking.active_track
+track = bpy.context.edit_movieclip.tracking.tracks.active
 
 track.color = (0.0, 0.0, 1.0)
 track.use_custom_color = True
index 32ba28bc675046210a76622e17bd8d064f3b3b5c..790429ce7a101861daf7bce45c1b77c76fd27d8c 100644 (file)
@@ -1,5 +1,5 @@
 import bpy
-track = bpy.context.edit_movieclip.tracking.active_track
+track = bpy.context.edit_movieclip.tracking.tracks.active
 
 track.color = (0.0, 1.0, 0.0)
 track.use_custom_color = True
index 238f20158aff973f6ea64a0e3c6b39c243a5d715..14d9d7237d22227a9d088e12863081eeee117ad9 100644 (file)
@@ -25,6 +25,8 @@ from bpy_extras.io_utils import unpack_list
 
 
 class CLIP_OT_track_to_empty(Operator):
+    """Create an Empty object which will be copying movement of active track"""
+
     bl_idname = "clip.track_to_empty"
     bl_label = "2D Track to Empty"
     bl_options = {'UNDO', 'REGISTER'}
@@ -67,6 +69,8 @@ class CLIP_OT_track_to_empty(Operator):
 
 
 class CLIP_OT_bundles_to_mesh(Operator):
+    """Create vertex cloud using coordinates of bundles"""
+
     bl_idname = "clip.bundles_to_mesh"
     bl_label = "Bundles to Mesh"
     bl_options = {'UNDO', 'REGISTER'}
@@ -104,6 +108,8 @@ class CLIP_OT_bundles_to_mesh(Operator):
 
 
 class CLIP_OT_delete_proxy(Operator):
+    """Delete movie clip proxy files from the hard drive"""
+
     bl_idname = "clip.delete_proxy"
     bl_label = "Delete Proxy"
     bl_options = {'UNDO', 'REGISTER'}
@@ -172,6 +178,8 @@ class CLIP_OT_delete_proxy(Operator):
 
 
 class CLIP_OT_set_viewport_background(Operator):
+    """Set current movie clip as a camera background in 3D viewport"""
+
     bl_idname = "clip.set_viewport_background"
     bl_label = "Set as Background"
     bl_options = {'UNDO', 'REGISTER'}
@@ -217,6 +225,8 @@ class CLIP_OT_set_viewport_background(Operator):
 
 
 class CLIP_OT_constraint_to_fcurve(Operator):
+    """Create F-Curves for object which will copy object's movement caused by this constraint"""
+
     bl_idname = "clip.constraint_to_fcurve"
     bl_label = "Constraint to F-Curve"
     bl_options = {'UNDO', 'REGISTER'}
index c2fe18fc5c73371015d54dc4538919ada5449ea3..940123e6645e9d9a4c5b74de77bdb3095bc4d8bf 100644 (file)
@@ -347,7 +347,7 @@ class AddPresetTrackingTrackColor(AddPresetBase, Operator):
     preset_menu = "CLIP_MT_track_color_presets"
 
     preset_defines = [
-        "track = bpy.context.edit_movieclip.tracking.active_track"
+        "track = bpy.context.edit_movieclip.tracking.tracks"
     ]
 
     preset_values = [
index fc17cdefb747a0f2ab721ead771e02a735355f40..2569a23db47ce2f00498211984b862e7273e09a4 100644 (file)
@@ -153,14 +153,14 @@ class CLIP_PT_tools_solving(Panel):
         clip = context.space_data.clip
         settings = clip.tracking.settings
 
-        col = layout.column(align=True)
-        col.prop(settings, "keyframe_a")
-        col.prop(settings, "keyframe_b")
-
         col = layout.column(align=True)
         col.operator("clip.solve_camera")
         col.operator("clip.clear_solution")
 
+        col = layout.column(align=True)
+        col.prop(settings, "keyframe_a")
+        col.prop(settings, "keyframe_b")
+
 
 class CLIP_PT_tools_cleanup(Panel):
     bl_space_type = 'CLIP_EDITOR'
@@ -179,12 +179,12 @@ class CLIP_PT_tools_cleanup(Panel):
         clip = context.space_data.clip
         settings = clip.tracking.settings
 
+        layout.operator("clip.clean_tracks")
+
         layout.prop(settings, 'clean_frames', text="Frames")
         layout.prop(settings, 'clean_error', text="Error")
         layout.prop(settings, 'clean_action', text="")
 
-        layout.operator("clip.clean_tracks")
-
 
 class CLIP_PT_tools_geometry(Panel):
     bl_space_type = 'CLIP_EDITOR'
@@ -231,9 +231,11 @@ class CLIP_PT_tools_orientation(Panel):
         row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
         row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
 
+        layout.separator()
+
         col = layout.column()
-        col.prop(settings, "distance")
         col.operator("clip.set_scale")
+        col.prop(settings, "distance")
 
 
 class CLIP_PT_tools_grease_pencil(Panel):
@@ -300,10 +302,10 @@ class CLIP_PT_track(Panel):
 
         layout.template_track(sc, "scopes")
 
-        row = layout.row()
-        row.prop(act_track, "use_red_channel", text="Red")
-        row.prop(act_track, "use_green_channel", text="Green")
-        row.prop(act_track, "use_blue_channel", text="Blue")
+        row = layout.row(align=True)
+        row.prop(act_track, "use_red_channel", text="R", toggle=True)
+        row.prop(act_track, "use_green_channel", text="G", toggle=True)
+        row.prop(act_track, "use_blue_channel", text="B", toggle=True)
 
         layout.separator()
 
index 7bdc9d6b48b668b145a3a95857e62876a005ed09..f30718ad7c41dfa43d4051e21badf79a6ad1249e 100644 (file)
@@ -1194,7 +1194,7 @@ static struct libmv_Tracks *create_libmv_tracks(MovieTracking *tracking, int wid
        return tracks;
 }
 
-static int retrive_libmv_reconstruct(MovieTracking *tracking, struct libmv_Reconstruction *libmv_reconstruction)
+static int retrieve_libmv_reconstruct(MovieTracking *tracking, struct libmv_Reconstruction *libmv_reconstruction)
 {
        int tracknr= 0;
        int sfra= INT_MAX, efra= INT_MIN, a, origin_set= 0;
@@ -1306,7 +1306,7 @@ float BKE_tracking_solve_reconstruction(MovieTracking *tracking, int width, int
 
                tracking->reconstruction.error= error;
 
-               if(!retrive_libmv_reconstruct(tracking, reconstruction))
+               if(!retrieve_libmv_reconstruct(tracking, reconstruction))
                        error= -1.f;
 
                libmv_destroyReconstruction(reconstruction);
@@ -1546,7 +1546,7 @@ static int point_in_layer(bGPDlayer *layer, float x, float y)
        return 0;
 }
 
-static void retrive_libmv_features(MovieTracking *tracking, struct libmv_Features *features,
+static void retrieve_libmv_features(MovieTracking *tracking, struct libmv_Features *features,
                        int framenr, int width, int height, bGPDlayer *layer)
 {
 #ifdef WITH_LIBMV
@@ -1588,7 +1588,7 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ImBuf *ibuf,
 
        MEM_freeN(pixels);
 
-       retrive_libmv_features(tracking, features, framenr, ibuf->x, ibuf->y, layer);
+       retrieve_libmv_features(tracking, features, framenr, ibuf->x, ibuf->y, layer);
 
        libmv_destroyFeatures(features);
 #endif
@@ -1605,7 +1605,7 @@ void BKE_tracking_detect_moravec(MovieTracking *tracking, ImBuf *ibuf,
 
        MEM_freeN(pixels);
 
-       retrive_libmv_features(tracking, features, framenr, ibuf->x, ibuf->y, layer);
+       retrieve_libmv_features(tracking, features, framenr, ibuf->x, ibuf->y, layer);
 
        libmv_destroyFeatures(features);
 #endif
index 913ef8c797c375bddafcaf9071d3b82fb393eaa0..099ba6ffe60fec3613b7331d076a392d6912d2de 100644 (file)
@@ -1225,7 +1225,19 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip)
        }
 }
 
-static void track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwards)
+static int track_markers_check_direction(int backwards, int curfra, int efra)
+{
+       if(backwards) {
+               if(curfra<efra) return 0;
+       }
+       else {
+               if(curfra>efra) return 0;
+       }
+
+       return 1;
+}
+
+static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwards)
 {
        SpaceClip *sc= CTX_wm_space_clip(C);
        MovieClip *clip= ED_space_clip(sc);
@@ -1269,6 +1281,8 @@ static void track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwar
        tmj->scene= scene;
        tmj->main= CTX_data_main(C);
        tmj->screen= CTX_wm_screen(C);
+
+       return track_markers_check_direction(backwards, tmj->sfra, tmj->efra);
 }
 
 static void track_markers_startjob(void *tmv, short *stop, short *do_update, float *progress)
@@ -1358,6 +1372,9 @@ static int track_markers_exec(bContext *C, wmOperator *op)
                else efra= MIN2(efra, sfra+settings->frames_limit);
        }
 
+       if(!track_markers_check_direction(backwards, framenr, efra))
+               return OPERATOR_CANCELLED;
+
        track_init_markers(sc, clip);
 
        /* do not disable tracks due to threshold when tracking frame-by-frame */
@@ -1406,7 +1423,11 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
                return track_markers_exec(C, op);
 
        tmj= MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data");
-       track_markers_initjob(C, tmj, backwards);
+       if(!track_markers_initjob(C, tmj, backwards)) {
+               track_markers_freejob(tmj);
+
+               return OPERATOR_CANCELLED;
+       }
 
        /* setup job */
        steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", WM_JOB_PROGRESS);
@@ -1465,7 +1486,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
        ot->flag= OPTYPE_UNDO;
 
        /* properties */
-       RNA_def_boolean(ot->srna, "backwards", 0, "Backwards", "Do backwards tarcking");
+       RNA_def_boolean(ot->srna, "backwards", 0, "Backwards", "Do backwards tracking");
        RNA_def_boolean(ot->srna, "sequence", 0, "Track Sequence", "Track marker during image sequence rather than single image");
 }
 
@@ -1767,7 +1788,7 @@ static int set_origin_exec(bContext *C, wmOperator *op)
        DAG_id_tag_update(&parent->id, OB_RECALC_OB);
 
        WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip);
-       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
        return OPERATOR_FINISHED;
 }
@@ -1776,7 +1797,7 @@ void CLIP_OT_set_origin(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Set Origin";
-       ot->description= "Set active marker as origin";
+       ot->description= "Set active marker as origin by moving camera (or it's parent if present) in 3d space";
        ot->idname= "CLIP_OT_set_origin";
 
        /* api callbacks */
@@ -1919,7 +1940,7 @@ static int set_floor_exec(bContext *C, wmOperator *op)
        DAG_id_tag_update(&parent->id, OB_RECALC_OB);
 
        WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip);
-       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
        return OPERATOR_FINISHED;
 }
@@ -1928,7 +1949,7 @@ void CLIP_OT_set_floor(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Set Floor";
-       ot->description= "Set floor using 3 selected bundles";
+       ot->description= "Set floor based on 3 selected bundles by moving camera (or it's parent if present) in 3d space";
        ot->idname= "CLIP_OT_set_floor";
 
        /* api callbacks */
@@ -1939,7 +1960,7 @@ void CLIP_OT_set_floor(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-/********************** set origin operator *********************/
+/********************** set axis operator *********************/
 
 static int set_axis_exec(bContext *C, wmOperator *op)
 {
@@ -1951,7 +1972,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
        int axis= RNA_enum_get(op->ptr, "axis");
 
        if(count_selected_bundles(C)!=1) {
-               BKE_report(op->reports, RPT_ERROR, "Track with bundle should be selected to define X-axis");
+               BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis");
 
                return OPERATOR_CANCELLED;
        }
@@ -1973,7 +1994,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
        DAG_id_tag_update(&parent->id, OB_RECALC_OB);
 
        WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip);
-       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
        return OPERATOR_FINISHED;
 }
@@ -1988,7 +2009,7 @@ void CLIP_OT_set_axis(wmOperatorType *ot)
 
        /* identifiers */
        ot->name= "Set Axis";
-       ot->description= "Set direction of scene axis";
+       ot->description= "Set direction of scene axis rotating camera (or it's parent if present) and assuming selected track lies on real axis joining it with the origin";
        ot->idname= "CLIP_OT_set_axis";
 
        /* api callbacks */
@@ -2048,7 +2069,7 @@ static int set_scale_exec(bContext *C, wmOperator *op)
                DAG_id_tag_update(&parent->id, OB_RECALC_OB);
 
                WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip);
-               WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+               WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        }
 
        return OPERATOR_FINISHED;
@@ -2070,7 +2091,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Set Scale";
-       ot->description= "Set scale of scene";
+       ot->description= "Set scale of scene by scaling camera (or it's parent if present)";
        ot->idname= "CLIP_OT_set_scale";
 
        /* api callbacks */
@@ -2864,8 +2885,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
                if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) {
                        int ok= 1;
 
-                       ok&= is_track_clean(track, frames, action==TRACKING_CLEAN_DELETE_SEGMENT);
-                       ok&= error == 0.f || (track->flag&TRACK_HAS_BUNDLE)==0  || track->error < error;
+                       ok= (is_track_clean(track, frames, action==TRACKING_CLEAN_DELETE_SEGMENT)) &&
+                           (error == 0.f || (track->flag&TRACK_HAS_BUNDLE)==0  || track->error < error);
 
                        if(!ok) {
                                if(action==TRACKING_CLEAN_SELECT) {
@@ -2918,9 +2939,9 @@ static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
 void CLIP_OT_clean_tracks(wmOperatorType *ot)
 {
        static EnumPropertyItem actions_items[] = {
-                       {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select un-clean tracks"},
-                       {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete un-clean tracks"},
-                       {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete un-clean segments of tracks"},
+                       {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"},
+                       {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete unclean tracks"},
+                       {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"},
                        {0, NULL, 0, NULL, NULL}
        };
 
@@ -2938,7 +2959,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       RNA_def_int(ot->srna, "frames", 0, 0, INT_MAX, "Tracked Frames", "Affect on tracks which are tracked less than specified amount of frames", 0, INT_MAX);
-       RNA_def_float(ot->srna, "error", 0.0f, 0.f, FLT_MAX, "Reprojection Error", "Affect on tracks with have got larger reprojection error", 0.f, 100.0f);
+       RNA_def_int(ot->srna, "frames", 0, 0, INT_MAX, "Tracked Frames", "Effect on tracks which are tracked less than specified amount of frames", 0, INT_MAX);
+       RNA_def_float(ot->srna, "error", 0.0f, 0.f, FLT_MAX, "Reprojection Error", "Effect on tracks with have got larger reprojection error", 0.f, 100.0f);
        RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Cleanup action to execute");
 }
index 14509ad3d7be1da8e198ad4f9a91f4880e15be23..72c9c697d1555bf8c057eab5c60b5ccb6b055b5e 100644 (file)
@@ -504,7 +504,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
        RNA_def_property_array(prop, 3);
        RNA_def_property_float_sdna(prop, NULL, "bundle_pos");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Bundle", "Position of bundle reconstructed from this tarck");
+       RNA_def_property_ui_text(prop, "Bundle", "Position of bundle reconstructed from this track");
 
        /* hide */
        prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);