diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-28 17:26:46 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-28 17:26:46 +0400 |
commit | a3623a046bdc10f80319c1bedf2740bda072f53a (patch) | |
tree | 78274ab89cf64645bc956ff5225845163ab99849 /source/blender/makesrna/intern/rna_tracking.c | |
parent | 911be02fcd5c818b626482e313cb9f37da2bf054 (diff) |
Camera tracking: merging tracking presets stuff from tomato branch
This commit implements:
- Configurable settings for newly creating tracks
Now it's possible to set tracking algorithm and it's settings for
all newly creating tracks including manual tracks creation and
tracks creation by "Detect Features" operator.
- Moves margin, frames limit and adjust frame inside per-track
settings.
Was request from Francois for this.
- Adjust Frames replaced with menu called Pattern Match where it's
possible to choose between matching pattern from keyframe frame
or from previously tracked frame.
Didn't see somebody used adjust frames values differ from 0 and 1,
and this menu should make things more clear here/
Diffstat (limited to 'source/blender/makesrna/intern/rna_tracking.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_tracking.c | 163 |
1 files changed, 136 insertions, 27 deletions
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index eb3512083aa..a3d043ab6ec 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -53,6 +53,40 @@ #include "WM_api.h" +static void rna_tracking_defaultSettings_levelsUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +{ + MovieClip *clip= (MovieClip*)ptr->id.data; + MovieTracking *tracking= &clip->tracking; + MovieTrackingSettings *settings= &tracking->settings; + + if(settings->default_tracker==TRACKER_KLT) { + int max_pyramid_level_factor= 1 << (settings->default_pyramid_levels - 1); + float search_ratio= 2.3f * max_pyramid_level_factor; + + settings->default_search_size= settings->default_pattern_size*search_ratio; + } +} + +static void rna_tracking_defaultSettings_patternUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +{ + MovieClip *clip= (MovieClip*)ptr->id.data; + MovieTracking *tracking= &clip->tracking; + MovieTrackingSettings *settings= &tracking->settings; + + if(settings->default_search_size<settings->default_pattern_size) + settings->default_search_size= settings->default_pattern_size; +} + +static void rna_tracking_defaultSettings_searchUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +{ + MovieClip *clip= (MovieClip*)ptr->id.data; + MovieTracking *tracking= &clip->tracking; + MovieTrackingSettings *settings= &tracking->settings; + + if(settings->default_pattern_size>settings->default_search_size) + settings->default_pattern_size= settings->default_search_size; +} + static void rna_tracking_tracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { MovieClip *clip= (MovieClip*)ptr->id.data; @@ -232,6 +266,16 @@ static MovieTrackingMarker *rna_trackingTrack_marker_find_frame(MovieTrackingTra #else +static EnumPropertyItem tracker_items[] = { + {TRACKER_KLT, "KLT", 0, "KLT", "Kanade–Lucas–Tomasi tracker which works with most of video clips, a bit slower than SAD"}, + {TRACKER_SAD, "SAD", 0, "SAD", "Sum of Absolute Differences tracker which can be used when MLT tracker fails"}, + {0, NULL, 0, NULL, NULL}}; + +static EnumPropertyItem pattern_match_items[] = { + {TRACK_MATCH_KEYFRAME, "KEYFRAME", 0, "Keyframe", "Track pattern from keyframe to next frame"}, + {TRACK_MATCH_PREVFRAME, "PREV_FRAME", 0, "Previous frame", "Track pattern from current frame to next frame"}, + {0, NULL, 0, NULL, NULL}}; + static int rna_matrix_dimsize_4x4[]= {4, 4}; static void rna_def_trackingSettings(BlenderRNA *brna) @@ -280,27 +324,6 @@ static void rna_def_trackingSettings(BlenderRNA *brna) RNA_def_property_enum_items(prop, speed_items); RNA_def_property_ui_text(prop, "Speed", "Limit speed of tracking to make visual feedback easier (this does not affect the tracking quality)"); - /* limit frames */ - prop= RNA_def_property(srna, "frames_limit", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "frames_limit"); - RNA_def_property_range(prop, 0, SHRT_MAX); - RNA_def_property_ui_text(prop, "Frames Limit", "Every tracking cycle, this amount of frames are tracked"); - - /* adjust frames */ - prop= RNA_def_property(srna, "frames_adjust", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "adjframes"); - RNA_def_property_range(prop, 0, INT_MAX); - RNA_def_property_ui_text(prop, "Adjust Frames", "Automatically re-adjust marker position using position on each N frames. 0 means only keyframed position is used"); - - /* margin */ - prop= RNA_def_property(srna, "margin", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "margin"); - RNA_def_property_range(prop, 0, 300); - RNA_def_property_ui_text(prop, "Margin", "Distance from image boudary at which marker stops tracking"); - /* keyframe_a */ prop= RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -348,6 +371,76 @@ static void rna_def_trackingSettings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, cleanup_items); RNA_def_property_ui_text(prop, "Action", "Cleanup action to execute"); + + /* ** default tracker settings ** */ + prop= RNA_def_property(srna, "show_default_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED); + RNA_def_property_ui_text(prop, "Show Expanded", "Show the expanded in the user interface"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + + /* limit frames */ + prop= RNA_def_property(srna, "default_frames_limit", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "default_frames_limit"); + RNA_def_property_range(prop, 0, SHRT_MAX); + RNA_def_property_ui_text(prop, "Frames Limit", "Every tracking cycle, this amount of frames are tracked"); + + /* pattern match */ + prop= RNA_def_property(srna, "default_pattern_match", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_sdna(prop, NULL, "default_pattern_match"); + RNA_def_property_enum_items(prop, pattern_match_items); + RNA_def_property_ui_text(prop, "Pattern Match", "Track pattern from given frame when tracking marker to next frame"); + + /* margin */ + prop= RNA_def_property(srna, "default_margin", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "default_margin"); + RNA_def_property_range(prop, 0, 300); + RNA_def_property_ui_text(prop, "Margin", "Default distance from image boudary at which marker stops tracking"); + + /* tracking algorithm */ + prop= RNA_def_property(srna, "default_tracker", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_items(prop, tracker_items); + RNA_def_property_update(prop, 0, "rna_tracking_defaultSettings_levelsUpdate"); + RNA_def_property_ui_text(prop, "Tracker", "Default tracking algorithm to use"); + + /* pyramid level for pyramid klt tracking */ + prop= RNA_def_property(srna, "default_pyramid_levels", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "default_pyramid_levels"); + RNA_def_property_range(prop, 1, 16); + RNA_def_property_update(prop, 0, "rna_tracking_defaultSettings_levelsUpdate"); + RNA_def_property_ui_text(prop, "Pyramid levels", "Default number of pyramid levels (increase on blurry footage)"); + + /* minmal correlation - only used for SAD tracker */ + prop= RNA_def_property(srna, "default_correlation_min", PROP_FLOAT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_float_sdna(prop, NULL, "default_minimum_correlation"); + RNA_def_property_range(prop, -1.0f, 1.0f); + RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1, 3); + RNA_def_property_ui_text(prop, "Correlation", "Default minimal value of correlation between matched pattern and reference which is still treated as successful tracking"); + + /* default pattern size */ + prop= RNA_def_property(srna, "default_pattern_size", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "default_pattern_size"); + RNA_def_property_range(prop, 5, 1000); + RNA_def_property_update(prop, 0, "rna_tracking_defaultSettings_patternUpdate"); + RNA_def_property_ui_text(prop, "Pattern Size", "Size of pattern area for newly creating tracks"); + + /* default search size */ + prop= RNA_def_property(srna, "default_search_size", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "default_search_size"); + RNA_def_property_range(prop, 5, 1000); + RNA_def_property_update(prop, 0, "rna_tracking_defaultSettings_searchUpdate"); + RNA_def_property_ui_text(prop, "Search Size", "Size of search area for newly creating tracks"); } static void rna_def_trackingCamera(BlenderRNA *brna) @@ -465,11 +558,6 @@ static void rna_def_trackingTrack(BlenderRNA *brna) FunctionRNA *func; PropertyRNA *parm; - static EnumPropertyItem tracker_items[] = { - {TRACKER_KLT, "KLT", 0, "KLT", "Kanade–Lucas–Tomasi tracker which works with most of video clips, a bit slower than SAD"}, - {TRACKER_SAD, "SAD", 0, "SAD", "Sum of Absolute Differences tracker which can be used when MLT tracker fails"}, - {0, NULL, 0, NULL, NULL}}; - rna_def_trackingMarker(brna); srna= RNA_def_struct(brna, "MovieTrackingTrack", NULL); @@ -514,6 +602,27 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Search Max", "Right-bottom corner of search area in normalized coordinates relative to marker position"); RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerSearch_update"); + /* limit frames */ + prop= RNA_def_property(srna, "frames_limit", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "frames_limit"); + RNA_def_property_range(prop, 0, SHRT_MAX); + RNA_def_property_ui_text(prop, "Frames Limit", "Every tracking cycle, this amount of frames are tracked"); + + /* pattern match */ + prop= RNA_def_property(srna, "pattern_match", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_sdna(prop, NULL, "pattern_match"); + RNA_def_property_enum_items(prop, pattern_match_items); + RNA_def_property_ui_text(prop, "Pattern Match", "Track pattern from given frame when tracking marker to next frame"); + + /* margin */ + prop= RNA_def_property(srna, "margin", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "margin"); + RNA_def_property_range(prop, 0, 300); + RNA_def_property_ui_text(prop, "Margin", "Distance from image boudary at which marker stops tracking"); + /* tracking algorithm */ prop= RNA_def_property(srna, "tracker", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -535,7 +644,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "minimum_correlation"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1, 3); - RNA_def_property_ui_text(prop, "Correlation", "Minimal value of correlation between mathed pattern and reference which is still treated as successful tracking"); + RNA_def_property_ui_text(prop, "Correlation", "Minimal value of correlation between matched pattern and reference which is still treated as successful tracking"); /* markers */ prop= RNA_def_property(srna, "markers", PROP_COLLECTION, PROP_NONE); |